Refactor user form to replace select elements with dropdown rendering for supervisor and location, enhancing consistency and maintainability.
This commit is contained in:
parent
be9e4afb4d
commit
50786cf41f
1 changed files with 17 additions and 24 deletions
|
@ -12,8 +12,8 @@
|
|||
active: document.querySelector("input[name='activeCheck']").checked,
|
||||
last_name: document.querySelector("input[name='lastName']").value,
|
||||
first_name: document.querySelector("input[name='firstName']").value,
|
||||
supervisor_id: parseInt(document.querySelector("select[name='supervisor']").value) || null,
|
||||
location_id: parseInt(document.querySelector("select[name='location']").value) || null
|
||||
supervisor_id: parseInt(document.querySelector("input[name='supervisor']").value) || null,
|
||||
location_id: parseInt(document.querySelector("input[name='location']").value) || null
|
||||
};
|
||||
|
||||
try {
|
||||
|
@ -97,31 +97,24 @@
|
|||
|
||||
<div class="row mt-2">
|
||||
<div class="col-6">
|
||||
<label for="supervisor" class="form-label">
|
||||
Supervisor
|
||||
{% if user.supervisor %}
|
||||
{{ links.entry_link('user', user.supervisor_id) }}
|
||||
{% endif %}
|
||||
</label>
|
||||
<select class="form-select" id="supervisor" name="supervisor"
|
||||
value="{{ supervisor.id if supervisor else '' }}"{% if not user.active %} disabled readonly{% endif %}>
|
||||
<option>-</option>
|
||||
{% for supervisor in users %}
|
||||
<option value="{{ supervisor.id }}"{% if supervisor.id==user.supervisor_id %} selected{% endif %}>
|
||||
{{ supervisor.identifier }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{{ dropdowns.render_dropdown(
|
||||
id='supervisor',
|
||||
list=users,
|
||||
label='Supervisor',
|
||||
current_item=user.supervisor if user.supervisor else None,
|
||||
entry_link='user',
|
||||
enabled=user.active
|
||||
) }}
|
||||
</div>
|
||||
|
||||
<div class="col-6">
|
||||
<label for="location" class="form-label">Location</label>
|
||||
<select class="form-select" id="location" name="location"{% if not user.active %} disabled readonly{% endif %}>
|
||||
<option>-</option>
|
||||
{% for location in rooms %}
|
||||
<option value="{{ location.id }}"{% if location.id==user.location_id %} selected{% endif %}>{{
|
||||
location.identifier }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{{ dropdowns.render_dropdown(
|
||||
id='location',
|
||||
list=rooms,
|
||||
label='Location',
|
||||
current_item=user.location if user.location else None,
|
||||
enabled=user.active
|
||||
) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-4">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue