Add worklog form fields and enhance templates for better data handling

- Introduced worklog form fields for start and end timestamps, contact, work item, completion status, follow-up, analysis, and notes.
- Updated worklog.html to include a save button and improved layout.
- Enhanced datalist.js for dynamic data binding between input fields and datalists.
- Refactored inventory.html and user.html for consistency and readability.
- Added form.html template for future use.
This commit is contained in:
Yaro Kasear 2025-06-11 11:33:56 -05:00
parent 189f73b7c2
commit 795b23fbae
8 changed files with 265 additions and 172 deletions

View file

@ -9,10 +9,12 @@
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('index') }}">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-house" viewBox="0 0 16 16">
<path d="M8.707 1.5a1 1 0 0 0-1.414 0L.646 8.146a.5.5 0 0 0 .708.708L2 8.207V13.5A1.5 1.5 0 0 0 3.5 15h9a1.5 1.5 0 0 0 1.5-1.5V8.207l.646.647a.5.5 0 0 0 .708-.708L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293zM13 7.207V13.5a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5V7.207l5-5z"/>
</svg>
</a></li>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-house"
viewBox="0 0 16 16">
<path
d="M8.707 1.5a1 1 0 0 0-1.414 0L.646 8.146a.5.5 0 0 0 .708.708L2 8.207V13.5A1.5 1.5 0 0 0 3.5 15h9a1.5 1.5 0 0 0 1.5-1.5V8.207l.646.647a.5.5 0 0 0 .708-.708L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293zM13 7.207V13.5a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5V7.207l5-5z" />
</svg>
</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('main.list_inventory') }}">Inventory</a></li>
<li class="breadcrumb-item active">{{ item.identifier }}</li>
</ol>
@ -23,7 +25,8 @@
<div class="row">
<div class="col-6">
<label for="timestamp" class="form-label">Date Entered</label>
<input type="date" class="form-control" name="timestamp" value="{{ item.timestamp.date().isoformat() }}">
<input type="date" class="form-control" name="timestamp"
value="{{ item.timestamp.date().isoformat() }}">
</div>
<div class="col-6">
<label for="identifier" class="form-label">Identifier</label>
@ -33,25 +36,29 @@
<div class="row">
<div class="col-4">
<label for="inventory_name" class="form-label">Inventory #</label>
<input type="text" class="form-control" name="inventory_name" placeholder="-" value="{{ item.inventory_name if item.inventory_name else '' }}">
<input type="text" class="form-control" name="inventory_name" placeholder="-"
value="{{ item.inventory_name if item.inventory_name else '' }}">
</div>
<div class="col-4">
<label for="serial" class="form-label">Serial #</label>
<input type="text" class="form-control" name="serial" placeholder="-" value="{{ item.serial if item.serial else '' }}">
<input type="text" class="form-control" name="serial" placeholder="-"
value="{{ item.serial if item.serial else '' }}">
</div>
<div class="col-4">
<label for="barcode" class="form-label">Bar Code #</label>
<input type="text" class="form-control" name="barcode" placeholder="-" value="{{ item.barcode if item.barcode else '' }}">
<input type="text" class="form-control" name="barcode" placeholder="-"
value="{{ item.barcode if item.barcode else '' }}">
</div>
</div>
<div class="row">
<div class="col-4">
<label for="brand" class="form-label">Brand</label>
<input list="brandList" id="brand" name="brand" class="form-control" placeholder="-" value="{{ item.brand.name }}">
<input list="brandList" id="brand" name="brand" class="form-control" placeholder="-"
value="{{ item.brand.name }}">
<input type="hidden" id="brandId">
<datalist id="brandList">
{% for brand in brands %}
<option data-id="{{ brand.id }}" value="{{ brand.name }}"></option>
<option data-id="{{ brand.id }}" value="{{ brand.name }}"></option>
{% endfor %}
</datalist>
</div>
@ -61,41 +68,46 @@
</div>
<div class="col-4">
<label for="category" class="form-label">Category</label>
<input type="text" class="form-control" name="category" placeholder="-" value="{{ item.item.description }}">
<input type="text" class="form-control" name="category" placeholder="-"
value="{{ item.item.description }}">
</div>
</div>
<div class="row">
<div class="col-4">
<label for="owner" class="form-label">Contact</label>
<input list="userList" id="owner" class="form-control" name="owner" placeholder="-" value="{{ item.owner.full_name }}">
<input list="userList" id="owner" class="form-control" name="owner" placeholder="-"
value="{{ item.owner.full_name }}" data-datalist-bind="#userList" data-hidden-target="#userId">
<input type="hidden" id="userId">
<datalist id="userList">
{% for user in users %}
<option data-id="{{ user.id }}" value="{{ user.full_name }}"></option>
<option data-id="{{ user.id }}" value="{{ user.full_name }}"></option>
{% endfor %}
</datalist>
</div>
<div class="col-4">
<label for="location" class="form-label">Location</label>
<input list="roomList" id="location" class="form-control" name="location" placeholder="-" value="{{ item.location.full_name }}">
<input list="roomList" id="location" class="form-control" name="location" placeholder="-"
value="{{ item.location.full_name }}" data-datalist-bind="#roomList" data-hidden-target="#roomId">
<input type="hidden" id="roomId">
<datalist id="roomList">
{% for room in rooms %}
<option data-id="{{ room.id }}" value="{{ room.full_name }}"></option>
<option data-id="{{ room.id }}" value="{{ room.full_name }}"></option>
{% endfor %}
</datalist>
</div>
<div class="col-2">
<label for="condition" class="form-label">Condition</label>
<select name="condition" id="" class="form-select" value="{{ item.condition }}">
{% for condition in ["Working", "Deployed", "Partially Inoperable", "Inoperable", "Unverified", "Removed", "Disposed"] %}
<option value="{{ condition }}">{{ condition }}</option>
{% for condition in ["Working", "Deployed", "Partially Inoperable", "Inoperable", "Unverified",
"Removed", "Disposed"] %}
<option value="{{ condition }}">{{ condition }}</option>
{% endfor %}
</select>
</div>
<div class="col-2 d-flex align-items-center justify-content-center" style="margin-top: 1.9rem;">
<div class="form-check mb-0">
<input type="checkbox" class="form-check-input" id="shared" name="shared" {% if item.shared %}checked{% endif %}>
<input type="checkbox" class="form-check-input" id="shared" name="shared" {% if item.shared
%}checked{% endif %}>
<label for="shared" class="form-check-label">Shared?</label>
</div>
</div>
@ -103,25 +115,26 @@
<div class="row">
<div class="col-{% if worklog %}6{% else %}12{% endif %}">
<label for="notes" class="form-label">Notes &amp; Comments</label>
<textarea name="notes" id="notes" class="form-control" rows="10">{{ item.notes if item.notes else '' }}</textarea>
<textarea name="notes" id="notes" class="form-control"
rows="10">{{ item.notes if item.notes else '' }}</textarea>
</div>
{% if worklog %}
<div class="col-6">
{{ tables.render_table(worklog_headers, worklog_rows, 'worklog_entry', 'Work Log') }}
{% if worklog_pagination['total_pages'] > 1 %}
{{ tables.render_pagination(
page=worklog_pagination['page'],
has_prev=worklog_pagination['has_prev'],
has_next=worklog_pagination['has_next'],
total_pages=worklog_pagination['total_pages'],
endpoint='main.inventory_item',
page_variable='worklog_page',
extra_args={'id': item.id, 'worklog_page': worklog_page}
) }}
{% endif %}
</div>
<div class="col-6">
{{ tables.render_table(worklog_headers, worklog_rows, 'worklog_entry', 'Work Log') }}
{% if worklog_pagination['total_pages'] > 1 %}
{{ tables.render_pagination(
page=worklog_pagination['page'],
has_prev=worklog_pagination['has_prev'],
has_next=worklog_pagination['has_next'],
total_pages=worklog_pagination['total_pages'],
endpoint='main.inventory_item',
page_variable='worklog_page',
extra_args={'id': item.id, 'worklog_page': worklog_page}
) }}
{% endif %}
</div>
{% endif %}
</div>
</form>
</div>
{% endblock %}
{% endblock %}