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 }}
|
||||
{% if entry_link %}
|
||||
|
@ -7,7 +9,7 @@
|
|||
</label>
|
||||
<div class="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 '-' }}
|
||||
</button>
|
||||
<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,
|
||||
analysis: document.querySelector("input[name='analysis']").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,
|
||||
updates: updates
|
||||
};
|
||||
|
@ -153,6 +153,7 @@
|
|||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
{#
|
||||
<label for="contact" class="form-label">
|
||||
Contact
|
||||
{% if log.contact_id %}
|
||||
|
@ -167,13 +168,24 @@
|
|||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
#}
|
||||
{{ dropdowns.render_dropdown(
|
||||
id='contact',
|
||||
list=users,
|
||||
label='Contact',
|
||||
current_item=log.contact,
|
||||
entry_link='user',
|
||||
enabled = not log.complete
|
||||
) }}
|
||||
</div>
|
||||
<div class="col-4">
|
||||
{{ dropdowns.render_dropdown(
|
||||
id='item',
|
||||
list=items,
|
||||
label='Work Item',
|
||||
current_item=log.work_item
|
||||
current_item=log.work_item,
|
||||
entry_link='inventory_item',
|
||||
enabled = not log.complete
|
||||
) }}
|
||||
</div>
|
||||
<div class="col-4">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue