Enhance dropdown functionality in worklog template by adding contact selection and enabling/disabling based on log completion status; refactor contact ID handling for consistency.
This commit is contained in:
parent
69a4a19587
commit
b0de4561bf
2 changed files with 18 additions and 4 deletions
|
@ -1,4 +1,6 @@
|
||||||
{% macro render_dropdown(id, list, label, current_item = None, entry_link = None) %}
|
{% import "fragments/_link_fragment.html" as links %}
|
||||||
|
|
||||||
|
{% macro render_dropdown(id, list, label, current_item = None, entry_link = None, enabled = True) %}
|
||||||
<label for="{{ id }}" class="form-label">
|
<label for="{{ id }}" class="form-label">
|
||||||
{{ label }}
|
{{ label }}
|
||||||
{% if entry_link %}
|
{% if entry_link %}
|
||||||
|
@ -7,7 +9,7 @@
|
||||||
</label>
|
</label>
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<button class="btn btn-outline-dark dropdown-toggle w-100" type="button" data-bs-toggle="dropdown"
|
<button class="btn btn-outline-dark dropdown-toggle w-100" type="button" data-bs-toggle="dropdown"
|
||||||
data-inv-value="{{ current_item.id if current_item else '' }}" id="{{ id }}Button">
|
data-inv-value="{{ current_item.id if current_item else '' }}" id="{{ id }}Button"{% if not enabled %} disabled{% endif %}>
|
||||||
{{ current_item.identifier if current_item else '-' }}
|
{{ current_item.identifier if current_item else '-' }}
|
||||||
</button>
|
</button>
|
||||||
<input type="hidden" name="{{ id }}" id="{{ id }}" value="{{ current_item.id if current_item else '' }}">
|
<input type="hidden" name="{{ id }}" id="{{ id }}" value="{{ current_item.id if current_item else '' }}">
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
complete: document.querySelector("input[name='complete']").checked,
|
complete: document.querySelector("input[name='complete']").checked,
|
||||||
analysis: document.querySelector("input[name='analysis']").checked,
|
analysis: document.querySelector("input[name='analysis']").checked,
|
||||||
followup: document.querySelector("input[name='followup']").checked,
|
followup: document.querySelector("input[name='followup']").checked,
|
||||||
contact_id: parseInt(document.querySelector("select[name='contact']").value) || null,
|
contact_id: parseInt(document.querySelector("input[name='contact']").value) || null,
|
||||||
work_item_id: parseInt(document.querySelector("input[name='item']").value) || null,
|
work_item_id: parseInt(document.querySelector("input[name='item']").value) || null,
|
||||||
updates: updates
|
updates: updates
|
||||||
};
|
};
|
||||||
|
@ -153,6 +153,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
|
{#
|
||||||
<label for="contact" class="form-label">
|
<label for="contact" class="form-label">
|
||||||
Contact
|
Contact
|
||||||
{% if log.contact_id %}
|
{% if log.contact_id %}
|
||||||
|
@ -167,13 +168,24 @@
|
||||||
</option>
|
</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
#}
|
||||||
|
{{ dropdowns.render_dropdown(
|
||||||
|
id='contact',
|
||||||
|
list=users,
|
||||||
|
label='Contact',
|
||||||
|
current_item=log.contact,
|
||||||
|
entry_link='user',
|
||||||
|
enabled = not log.complete
|
||||||
|
) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
{{ dropdowns.render_dropdown(
|
{{ dropdowns.render_dropdown(
|
||||||
id='item',
|
id='item',
|
||||||
list=items,
|
list=items,
|
||||||
label='Work Item',
|
label='Work Item',
|
||||||
current_item=log.work_item
|
current_item=log.work_item,
|
||||||
|
entry_link='inventory_item',
|
||||||
|
enabled = not log.complete
|
||||||
) }}
|
) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue