Fix private subtags affecting public subtag display

This commit is contained in:
Tim Van Baak 2021-02-21 21:17:48 -08:00
parent 2a45ad1a1b
commit be9f4fefc2
1 changed files with 29 additions and 18 deletions

View File

@ -35,30 +35,39 @@ window.onload = function () {
{%- endmacro %} {%- endmacro %}
{% macro make_tab_page(tab, selected) %} {% macro make_tab_page(tab, selected) %}
{%- set tags = [] -%}
{%- for tag in tab.tags %}{% if edit or not tag.options.private -%}
{% set _ = tags.append(tag) %}
{%- endif -%}{%- endfor -%}
<div id="{{ tab.name }}-page" class="tab-page{% if selected %} tab-page-selected{% endif %}"> <div id="{{ tab.name }}-page" class="tab-page{% if selected %} tab-page-selected{% endif %}">
<table id="{{ tab.name }}-page-table" class="page-table"> <table id="{{ tab.name }}-page-table" class="page-table">
{% for tag in tab.tags %} {% for tag in tags -%}
{%- if not tag.options.private or edit -%}
{% set classes = [] %} {%- set classes = [] -%}
{% if tab.options.hide_names %}{% set classes = classes + ['hide-tag-name'] %}{% endif %} {%- if tab.options.hide_names %}{% set classes = classes + ['hide-tag-name'] %}{% endif -%}
{% if tag.options.private and edit %}{% set classes = classes + ['private-tag'] %}{% endif %} {%- if tag.options.private %}{% set classes = classes + ['private-tag'] %}{% endif -%}
<tr{% if classes %} class="{{ ' '.join(classes) }}"{% endif %}> <tr{% if classes %} class="{{ ' '.join(classes) }}"{% endif %}>
<td>{{ tag.name }}</td> <td>{{ tag.name }}</td>
<td>{{ make_tag_value(tag) }}</td> <td>{{ make_tag_value(tag) }}</td>
</tr> </tr>
{%- endif -%}
{% for subtag in tag.subtags %} {%- set subtags = [] -%}
{%- if (not tag.options.private and not subtag.options.private) or edit -%} {%- for subtag in tag.subtags %}{% if edit or not subtag.options.private -%}
{% set classes = [] %} {% set _ = subtags.append(subtag) %}
{% if tab.options.hide_names %}{% set classes = classes + ['hide-tag-name'] %}{% endif %} {%- endif -%}{%- endfor -%}
{% if (tag.options.private or subtag.options.private) and edit %}{% set classes = classes + ['private-tag'] %}{% endif %}
{%- for subtag in subtags -%}
{%- set classes = [] -%}
{%- if tab.options.hide_names %}{% set classes = classes + ['hide-tag-name'] %}{% endif -%}
{%- if tag.options.private or subtag.options.private %}{% set classes = classes + ['private-tag'] %}{% endif -%}
<tr{% if classes %} class="{{ ' '.join(classes) }}"{% endif %}> <tr{% if classes %} class="{{ ' '.join(classes) }}"{% endif %}>
<td>{% if loop.last %}&#9492;{% else %}&#9500;{% endif %} {{ subtag.name }}</td> <td>{% if loop.last %}&#9492;{% else %}&#9500;{% endif %} {{ subtag.name }}</td>
<td>{{ make_tag_value(subtag) }}</td> <td>{{ make_tag_value(subtag) }}</td>
</tr> </tr>
{%- endif -%} {%- endfor -%}
{% endfor %}
{% endfor %} {%- endfor -%}
</table> </table>
</div> </div>
{% endmacro %} {% endmacro %}
@ -75,16 +84,18 @@ window.onload = function () {
{# TODO: tab.priority support #} {# TODO: tab.priority support #}
{% block page_content %} {% block page_content %}
{%- set tabs = [] -%}
{%- for tab in document %}{% if edit or not tab.options.private -%}
{% set _ = tabs.append(tab) %}
{%- endif -%}{%- endfor -%}
<div id="tabs"> <div id="tabs">
{%- if index and edit -%} {%- if index and edit -%}
<div id="new-document" class="tab"><a href="/new/">new</a></div> <div id="new-document" class="tab"><a href="/new/">new</a></div>
{%- endif -%} {%- endif -%}
{%- for tab in document -%} {%- for tab in tabs -%}
{%- if not tab.options.private or edit-%}
{{ make_content_tab(tab, loop.first) }} {{ make_content_tab(tab, loop.first) }}
{%- endif -%}
{%- endfor -%} {%- endfor -%}
{%- if not index -%} {%- if not index -%}
@ -95,7 +106,7 @@ window.onload = function () {
{%- endif -%} {%- endif -%}
</div> </div>
{% for tab in document -%} {% for tab in tabs -%}
{{ make_tab_page(tab, loop.first) }} {{ make_tab_page(tab, loop.first) }}
{%- endfor -%} {%- endfor -%}
{% endblock page_content %} {% endblock page_content %}