Make form.checkbox generic
This commit is contained in:
parent
e022a6bc1e
commit
9e709039c5
@ -1,19 +1,18 @@
|
|||||||
{% macro checkbox(item, metadata, parent=none, delete=false) %}
|
{% macro checkbox(name, id, prefix, url, checked, parent=none, delete=false) %}
|
||||||
{% if g.login.is_authenticated() %}
|
{% if g.login.is_authenticated() %}
|
||||||
{% set prefix=metadata.as_dataset() %}
|
<input class="form-check-input" type="checkbox" id="{{ prefix }}-{{ id }}" {% if checked %}checked{% endif %}
|
||||||
<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="{{ item.fields.id }}" data-changer-prefix="{{ prefix }}" data-changer-url="{{ metadata.url_for_set_state(item.fields.id) }}" {% if parent %}data-changer-parent="{{ parent }}"{% endif %}
|
data-changer-id="{{ id }}" data-changer-prefix="{{ prefix }}" data-changer-url="{{ url }}" {% if parent %}data-changer-parent="{{ parent }}"{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
disabled
|
disabled
|
||||||
{% endif %}
|
{% endif %}
|
||||||
autocomplete="off">
|
autocomplete="off">
|
||||||
<label class="form-check-label flex-grow-1 ms-1" for="{{ prefix }}-{{ item.fields.id }}">
|
<label class="form-check-label flex-grow-1 ms-1" for="{{ prefix }}-{{ id }}">
|
||||||
{{ metadata.fields.name }} <i id="status-{{ prefix }}-{{ item.fields.id }}"></i>
|
{{ name }} <i id="status-{{ prefix }}-{{ id }}"></i>
|
||||||
</label>
|
</label>
|
||||||
{% else %}
|
{% else %}
|
||||||
<input class="form-check-input text-reset" type="checkbox" {% if item.fields[metadata.as_column()] %}checked{% endif %} disabled>
|
<input class="form-check-input text-reset" type="checkbox" {% if checked %}checked{% endif %} disabled>
|
||||||
{{ text }}
|
{{ name }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
|
@ -83,7 +83,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="d-flex list-group-item {% if not solo %}p-1{% endif %} text-nowrap">{{ form.checkbox(item, status, parent='set', delete=delete) }}</li>
|
<li class="d-flex list-group-item {% if not solo %}p-1{% endif %} text-nowrap">{{ form.checkbox(status.fields.name, item.fields.id, status.as_dataset(), status.url_for_set_state(item.fields.id), item.fields[status.as_column()], parent='set', delete=delete) }}</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<ul class="list-group list-group-flush">
|
<ul class="list-group list-group-flush">
|
||||||
{% if brickset_owners | length %}
|
{% if brickset_owners | length %}
|
||||||
{% for owner in brickset_owners %}
|
{% for owner in brickset_owners %}
|
||||||
<li class="d-flex list-group-item list-group-item-action text-nowrap">{{ form.checkbox(item, owner, delete=delete) }}</li>
|
<li class="d-flex list-group-item list-group-item-action text-nowrap">{{ form.checkbox(owner.fields.name, item.fields.id, owner.as_dataset(), owner.url_for_set_state(item.fields.id), item.fields[owner.as_column()], delete=delete) }}</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<li class="list-group-item list-group-item-action text-center"><i class="ri-error-warning-line"></i> No owner found.</li>
|
<li class="list-group-item list-group-item-action text-center"><i class="ri-error-warning-line"></i> No owner found.</li>
|
||||||
@ -47,7 +47,7 @@
|
|||||||
<ul class="list-group list-group-flush">
|
<ul class="list-group list-group-flush">
|
||||||
{% if brickset_tags | length %}
|
{% if brickset_tags | length %}
|
||||||
{% for tag in brickset_tags %}
|
{% for tag in brickset_tags %}
|
||||||
<li class="d-flex list-group-item list-group-item-action text-nowrap">{{ form.checkbox(item, tag, delete=delete) }}</li>
|
<li class="d-flex list-group-item list-group-item-action text-nowrap">{{ form.checkbox(tag.fields.name, item.fields.id, tag.as_dataset(), tag.url_for_set_state(item.fields.id), item.fields[tag.as_column()], delete=delete) }}</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<li class="list-group-item list-group-item-action text-center"><i class="ri-error-warning-line"></i> No tag found.</li>
|
<li class="list-group-item list-group-item-action text-center"><i class="ri-error-warning-line"></i> No tag found.</li>
|
||||||
|
Loading…
Reference in New Issue
Block a user