Move the dynamic input into a macro

This commit is contained in:
Gregoo 2025-01-29 15:12:10 +01:00
parent f32ea0b1b3
commit cc87495aba
2 changed files with 17 additions and 9 deletions

View File

@ -15,3 +15,18 @@
{{ text }} {{ text }}
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}
{% macro input(id, html_id, url, value) %}
<input class="form-control form-control-sm flex-shrink-1" type="text" value="{% if value %}{{ value }}{% endif %}"
{% if g.login.is_authenticated() %}
onchange="change_part_missing_amount(this, '{{ id }}', '{{ html_id }}', '{{ url }}')"
{% else %}
disabled
{% endif %}
autocomplete="off">
{% if g.login.is_authenticated() %}
<span id="status-part-{{ id }}-{{ html_id }}" class="input-group-text ri-save-line"></span>
{% else %}
<span class="input-group-text ri-prohibited-line"></span>
{% endif %}
{% endmacro %}

View File

@ -1,3 +1,4 @@
{% import 'macro/form.html' as form %}
{% import 'macro/table.html' as table %} {% import 'macro/table.html' as table %}
<div class="table-responsive-sm"> <div class="table-responsive-sm">
@ -32,15 +33,7 @@
{{ item.fields.total_missing }} {{ item.fields.total_missing }}
{% else %} {% else %}
<div class="input-group"> <div class="input-group">
{% if g.login.is_authenticated() %} {{ form.input(item.fields.id, item.html_id(), item.url_for_missing(), item.fields.total_missing) }}
<input class="form-control form-control-sm flex-shrink-1" type="text" {% if item.fields.total_missing %}value="{{ item.fields.total_missing }}"{% endif %}
onchange="change_part_missing_amount(this, '{{ item.fields.id }}', '{{ item.html_id() }}', '{{ item.url_for_missing() }}')" autocomplete="off">
<span id="status-part-{{ item.fields.id }}-{{ item.html_id() }}" class="input-group-text ri-save-line"></span>
{% else %}
<input class="form-control form-control-sm" type="text" {% if item.fields.total_missing %}value="{{ item.fields.total_missing }}"{% endif %}
disabled autocomplete="off">
<span class="input-group-text ri-prohibited-line"></span>
{% endif %}
</div> </div>
{% endif %} {% endif %}
</td> </td>