2025-02-04 19:35:14 +01:00
|
|
|
{% macro checkbox(name, id, prefix, url, checked, parent=none, delete=false) %}
|
2025-01-17 14:36:48 +01:00
|
|
|
{% if g.login.is_authenticated() %}
|
2025-02-04 19:35:14 +01:00
|
|
|
<input class="form-check-input" type="checkbox" id="{{ prefix }}-{{ id }}" {% if checked %}checked{% endif %}
|
2025-01-29 16:14:52 +01:00
|
|
|
{% if not delete %}
|
2025-02-04 19:35:14 +01:00
|
|
|
data-changer-id="{{ id }}" data-changer-prefix="{{ prefix }}" data-changer-url="{{ url }}" {% if parent %}data-changer-parent="{{ parent }}"{% endif %}
|
2025-01-29 16:14:52 +01:00
|
|
|
{% else %}
|
|
|
|
disabled
|
|
|
|
{% endif %}
|
|
|
|
autocomplete="off">
|
2025-02-04 19:35:14 +01:00
|
|
|
<label class="form-check-label flex-grow-1 ms-1" for="{{ prefix }}-{{ id }}">
|
|
|
|
{{ name }} <i id="status-{{ prefix }}-{{ id }}"></i>
|
2025-01-17 11:03:00 +01:00
|
|
|
</label>
|
2025-01-17 14:36:48 +01:00
|
|
|
{% else %}
|
2025-02-04 19:35:14 +01:00
|
|
|
<input class="form-check-input text-reset" type="checkbox" {% if checked %}checked{% endif %} disabled>
|
|
|
|
{{ name }}
|
2025-01-17 11:03:00 +01:00
|
|
|
{% endif %}
|
|
|
|
{% endmacro %}
|
2025-01-29 15:12:10 +01:00
|
|
|
|
2025-02-04 17:03:39 +01:00
|
|
|
{% macro input(name, id, prefix, url, value, all=none, read_only=none, icon=none, suffix=none, date=false) %}
|
2025-01-29 15:57:19 +01:00
|
|
|
{% if all or read_only %}
|
|
|
|
{{ value }}
|
|
|
|
{% else %}
|
|
|
|
<label class="visually-hidden" for="{{ prefix }}-{{ id }}">{{ name }}</label>
|
|
|
|
<div class="input-group">
|
2025-02-04 17:03:39 +01:00
|
|
|
{% if icon %}<span class="input-group-text"><i class="ri-{{ icon }} me-1"></i><span class="ms-1 d-none d-md-inline"> {{ name }}</span></span>{% endif %}
|
2025-01-29 15:57:19 +01:00
|
|
|
<input class="form-control form-control-sm flex-shrink-1" type="text" id="{{ prefix }}-{{ id }}" value="{% if value %}{{ value }}{% endif %}"
|
2025-01-29 16:14:52 +01:00
|
|
|
{% if g.login.is_authenticated() %}
|
2025-01-29 15:58:41 +01:00
|
|
|
data-changer-id="{{ id }}" data-changer-prefix="{{ prefix }}" data-changer-url="{{ url }}"
|
2025-02-04 17:03:39 +01:00
|
|
|
{% if date %}data-changer-date="true"{% endif %}
|
2025-01-29 16:14:52 +01:00
|
|
|
{% else %}
|
|
|
|
disabled
|
|
|
|
{% endif %}
|
|
|
|
autocomplete="off">
|
2025-02-04 17:03:39 +01:00
|
|
|
{% if suffix %}<span class="input-group-text d-none d-md-inline">{{ suffix }}</span>{% endif %}
|
2025-01-29 16:14:52 +01:00
|
|
|
{% if g.login.is_authenticated() %}
|
2025-01-29 15:57:19 +01:00
|
|
|
<span id="status-{{ prefix }}-{{ id }}" class="input-group-text ri-save-line"></span>
|
2025-01-29 16:14:52 +01:00
|
|
|
<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>
|
2025-01-29 15:57:19 +01:00
|
|
|
{% endif %}
|
|
|
|
</div>
|
2025-01-29 15:12:10 +01:00
|
|
|
{% endif %}
|
|
|
|
{% endmacro %}
|
2025-02-03 16:46:45 +01:00
|
|
|
|
2025-02-04 19:05:38 +01:00
|
|
|
{% macro select(name, id, prefix, url, value, metadata_list, nullable=true, icon=none, delete=false) %}
|
2025-02-03 16:46:45 +01:00
|
|
|
{% if g.login.is_authenticated() %}
|
2025-02-04 19:05:38 +01:00
|
|
|
<label class="visually-hidden" for="{{ prefix }}-{{ id }}">{{ name }}</label>
|
2025-02-03 16:46:45 +01:00
|
|
|
<div class="input-group">
|
2025-02-04 17:03:39 +01:00
|
|
|
{% if icon %}<span class="input-group-text"><i class="ri-{{ icon }} me-1"></i><span class="ms-1 d-none d-md-inline"> {{ name }}</span></span>{% endif %}
|
2025-02-04 19:05:38 +01:00
|
|
|
<select id="{{ prefix }}-{{ id }}" class="form-select"
|
2025-02-03 16:46:45 +01:00
|
|
|
{% if not delete %}
|
2025-02-04 19:05:38 +01:00
|
|
|
data-changer-id="{{ id }}" data-changer-prefix="{{ prefix }}" data-changer-url="{{ url }}"
|
2025-02-03 16:46:45 +01:00
|
|
|
{% else %}
|
|
|
|
disabled
|
|
|
|
{% endif %}
|
|
|
|
autocomplete="off">
|
2025-02-04 19:05:38 +01:00
|
|
|
{% if nullable %}<option value="" {% if value is none %}selected{% endif %}><i>None</i></option>{% endif %}
|
2025-02-03 16:46:45 +01:00
|
|
|
{% for metadata in metadata_list %}
|
2025-02-04 19:05:38 +01:00
|
|
|
<option value="{{ metadata.fields.id }}" {% if metadata.fields.id == value %}selected{% endif %}>{{ metadata.fields.name }}</option>
|
2025-02-03 16:46:45 +01:00
|
|
|
{% endfor %}
|
|
|
|
</select>
|
2025-02-04 19:05:38 +01:00
|
|
|
<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>
|
2025-02-03 16:46:45 +01:00
|
|
|
</div>
|
|
|
|
{% endif %}
|
|
|
|
{% endmacro %}
|