66 lines
3.4 KiB
HTML
66 lines
3.4 KiB
HTML
{% macro checkbox(item, metadata, parent=none, delete=false) %}
|
|
{% if g.login.is_authenticated() %}
|
|
{% 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 %}
|
|
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 %}
|
|
{% else %}
|
|
disabled
|
|
{% endif %}
|
|
autocomplete="off">
|
|
<label class="form-check-label flex-grow-1 ms-1" for="{{ prefix }}-{{ item.fields.id }}">
|
|
{{ metadata.fields.name }} <i id="status-{{ prefix }}-{{ item.fields.id }}" class="mb-1"></i>
|
|
</label>
|
|
{% else %}
|
|
<input class="form-check-input text-reset" type="checkbox" {% if item.fields[metadata.as_column()] %}checked{% endif %} disabled>
|
|
{{ text }}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro input(name, id, prefix, url, value, all=none, read_only=none) %}
|
|
{% if all or read_only %}
|
|
{{ value }}
|
|
{% else %}
|
|
<label class="visually-hidden" for="{{ prefix }}-{{ id }}">{{ name }}</label>
|
|
<div class="input-group">
|
|
<input class="form-control form-control-sm flex-shrink-1" type="text" id="{{ prefix }}-{{ id }}" value="{% if value %}{{ value }}{% endif %}"
|
|
{% if g.login.is_authenticated() %}
|
|
data-changer-id="{{ id }}" data-changer-prefix="{{ prefix }}" data-changer-url="{{ url }}"
|
|
{% else %}
|
|
disabled
|
|
{% endif %}
|
|
autocomplete="off">
|
|
{% if g.login.is_authenticated() %}
|
|
<span id="status-{{ prefix }}-{{ id }}" class="input-group-text ri-save-line"></span>
|
|
<button id="clear-{{ prefix }}-{{ id }}" type="button" class="btn btn-sm btn-light btn-outline-danger border"><i class="ri-eraser-line"></i></button>
|
|
{% else %}
|
|
<span class="input-group-text ri-prohibited-line"></span>
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro select(name, item, field, metadata_list, nullable=true, icon=none, delete=false) %}
|
|
{% if g.login.is_authenticated() %}
|
|
{% set prefix=metadata_list.as_prefix() %}
|
|
<label class="visually-hidden" for="{{ prefix }}-{{ item.fields.id }}">{{ name }}</label>
|
|
<div class="input-group">
|
|
{% if icon %}<span class="input-group-text"><i class="ri-{{ icon }}"></i></span>{% endif %}
|
|
<select id="{{ prefix }}-{{ item.fields.id }}" class="form-select"
|
|
{% if not delete %}
|
|
data-changer-id="{{ item.fields.id }}" data-changer-prefix="{{ prefix }}" data-changer-url="{{ metadata_list.url_for_set_state(item.fields.id) }}"
|
|
{% else %}
|
|
disabled
|
|
{% endif %}
|
|
autocomplete="off">
|
|
{% if nullable %}<option value="" {% if item.fields[field] is none %}selected{% endif %}><i>None</i></option>{% endif %}
|
|
{% for metadata in metadata_list %}
|
|
<option value="{{ metadata.fields.id }}" {% if metadata.fields.id == item.fields[field] %}selected{% endif %}>{{ metadata.fields.name }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
<span id="status-{{ prefix }}-{{ item.fields.id }}" class="input-group-text ri-save-line"></span>
|
|
<button id="clear-{{ prefix }}-{{ item.fields.id }}" type="button" class="btn btn-sm btn-light btn-outline-danger border"><i class="ri-eraser-line"></i></button>
|
|
</div>
|
|
{% endif %}
|
|
{% endmacro %}
|