Move the checkbox logic inside the macro
This commit is contained in:
parent
3a6e1ac9c9
commit
a6f0bdafa0
@ -1,17 +1,18 @@
|
|||||||
{% macro checkbox(prefix, id, text, url, checked, delete=false) %}
|
{% macro checkbox(item, metadata, delete=false) %}
|
||||||
{% if g.login.is_authenticated() %}
|
{% if g.login.is_authenticated() %}
|
||||||
<input class="form-check-input" type="checkbox" id="{{ prefix }}-{{ id }}" {% if checked %}checked{% endif %}
|
{% set prefix=metadata.as_dataset() %}
|
||||||
|
<input class="form-check-input" type="checkbox" id="{{ prefix }}-{{ item.fields.id }}" {% if item.fields[metadata.as_column()] %}checked{% endif %}
|
||||||
{% if not delete %}
|
{% if not delete %}
|
||||||
data-changer-id="{{ id }}" data-changer-prefix="{{ prefix }}" data-changer-url="{{ url }}" data-changer-parent="set"
|
data-changer-id="{{ item.fields.id }}" data-changer-prefix="{{ prefix }}" data-changer-url="{{ metadata.url_for_set_state(item.fields.id) }}" data-changer-parent="set"
|
||||||
{% else %}
|
{% else %}
|
||||||
disabled
|
disabled
|
||||||
{% endif %}
|
{% endif %}
|
||||||
autocomplete="off">
|
autocomplete="off">
|
||||||
<label class="form-check-label" for="{{ prefix }}-{{ id }}">
|
<label class="form-check-label" for="{{ prefix }}-{{ item.fields.id }}">
|
||||||
{{ text }} <i id="status-{{ prefix }}-{{ id }}" class="mb-1"></i>
|
{{ metadata.fields.name }} <i id="status-{{ prefix }}-{{ item.fields.id }}" class="mb-1"></i>
|
||||||
</label>
|
</label>
|
||||||
{% else %}
|
{% else %}
|
||||||
<input class="form-check-input text-reset" type="checkbox" {% if checked %}checked{% endif %} disabled>
|
<input class="form-check-input text-reset" type="checkbox" {% if item.fields[metadata.as_column()] %}checked{% endif %} disabled>
|
||||||
{{ text }}
|
{{ text }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
@ -29,9 +29,7 @@
|
|||||||
{% if not tiny and brickset_statuses | length %}
|
{% if not tiny and brickset_statuses | length %}
|
||||||
<ul class="list-group list-group-flush card-check border-bottom-0">
|
<ul class="list-group list-group-flush card-check border-bottom-0">
|
||||||
{% for status in brickset_statuses %}
|
{% for status in brickset_statuses %}
|
||||||
<li class="list-group-item {% if not solo %}p-1{% endif %}">
|
<li class="list-group-item {% if not solo %}p-1{% endif %}">{{ form.checkbox(item, status, delete=delete) }}</li>
|
||||||
{{ form.checkbox(status.as_dataset(), item.fields.id, status.fields.name, status.url_for_set_state(item.fields.id), item.fields[status.as_column()], delete=delete) }}
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
Reference in New Issue
Block a user