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

View File

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