Nice work on the user entry.

This commit is contained in:
Yaro Kasear 2025-11-05 11:36:05 -06:00
parent 4ef4d5e23f
commit d0551d52a1
4 changed files with 84 additions and 45 deletions

View file

@ -85,7 +85,12 @@ def _fields_for_model(model: str):
"inventory.label", "inventory.label",
"inventory.brand.name", "inventory.brand.name",
"inventory.model", "inventory.model",
"inventory.device_type.description" "inventory.device_type.description",
"inventory.condition.category",
"work_logs.work_item",
"work_logs.start_time",
"work_logs.end_time",
"work_logs.complete",
] ]
fields_spec = [ fields_spec = [
{"name": "label", "row": "label", "label": "", "type": "display", {"name": "label", "row": "label", "label": "", "type": "display",
@ -93,24 +98,27 @@ def _fields_for_model(model: str):
{"name": "buttons", "label": "", "row": "label", "type": "template", "template": "entry_buttons.html", {"name": "buttons", "label": "", "row": "label", "type": "template", "template": "entry_buttons.html",
"wrap": {"class": "col-auto text-end me-2"}, "attrs": {"data-model": model}}, "wrap": {"class": "col-auto text-end me-2"}, "attrs": {"data-model": model}},
{"name": "last_name", "label": "Last Name", "label_attrs": {"class": "form-label"}, {"name": "last_name", "label": "Last Name", "label_attrs": {"class": "form-label"},
"attrs": {"placeholder": "Doe", "class": "form-control"}, "row": "name", "wrap": {"class": "col-3"}}, "attrs": {"placeholder": "Doe", "class": "form-control"}, "row": "name", "wrap": {"class": "col"}},
{"name": "first_name", "label": "First Name", "label_attrs": {"class": "form-label"}, {"name": "first_name", "label": "First Name", "label_attrs": {"class": "form-label"},
"attrs": {"placeholder": "John", "class": "form-control"}, "row": "name", "wrap": {"class": "col-3"}}, "attrs": {"placeholder": "John", "class": "form-control"}, "row": "name", "wrap": {"class": "col"}},
{"name": "title", "label": "Title", "label_attrs": {"class": "form-label"}, {"name": "title", "label": "Title", "label_attrs": {"class": "form-label"},
"attrs": {"placeholder": "President of the Universe", "class": "form-control"}, "attrs": {"placeholder": "President of the Universe", "class": "form-control"},
"row": "name", "wrap": {"class": "col-3"}}, "row": "name", "wrap": {"class": "col"}},
{"name": "supervisor", "label": "Supervisor", "label_attrs": {"class": "form-label"}, {"name": "supervisor", "label": "Supervisor", "label_attrs": {"class": "form-label"},
"label_spec": "{label}", "row": "details", "wrap": {"class": "col-3"}, "label_spec": "{label}", "row": "details", "wrap": {"class": "col"},
"attrs": {"class": "form-control"}, "link": {"endpoint": "entry.entry", "params": {"id": "{supervisor.id}", "model": "user"}}, "attrs": {"class": "form-control"}, "link": {"endpoint": "entry.entry", "params": {"id": "{supervisor.id}", "model": "user"}},
"options_params": {"active__eq": True, "staff__eq": True}}, "options_params": {"active__eq": True, "staff__eq": True}},
{"name": "location", "label": "Room", "label_attrs": {"class": "form-label"}, {"name": "location", "label": "Room", "label_attrs": {"class": "form-label"},
"label_spec": "{name} - {room_function.description}", "label_spec": "{name} - {room_function.description}",
"row": "details", "wrap": {"class": "col-3"}, "attrs": {"class": "form-control"}}, "row": "details", "wrap": {"class": "col"}, "attrs": {"class": "form-control"}},
{"name": "active", "label": "Active", "label_attrs": {"class": "form-check-label"}, {"name": "active", "label": "Active", "label_attrs": {"class": "form-check-label"},
"row": "checkboxes", "attrs": {"class": "form-check-input"}, "wrap": {"class": "form-check"}}, "row": "checkboxes", "attrs": {"class": "form-check-input"}, "wrap": {"class": "form-check"}},
{"name": "staff", "label": "Staff Member", "label_attrs": {"class": "form-check-label"}, {"name": "staff", "label": "Staff Member", "label_attrs": {"class": "form-check-label"},
"row": "checkboxes", "attrs": {"class": "form-check-input"}, "wrap": {"class": "form-check"}}, "row": "checkboxes", "attrs": {"class": "form-check-input"}, "wrap": {"class": "form-check"}},
{"name": "inventory", "label": "Inventory", "type": "template", "row": "inventory", "template": "user_inventory.html"}, {"name": "inventory", "label": "Inventory", "type": "template", "row": "inventory",
"template": "user_inventory.html", "wrap": {"class": "col"}},
{"name": "work_logs", "label": "Work Logs", "row": "inventory", "type": "template",
"template": "user_worklogs.html", "wrap": {"class": "col"}},
] ]
layout = [ layout = [
{"name": "label", "order": 0, "attrs": {"class": "row align-items-center"}}, {"name": "label", "order": 0, "attrs": {"class": "row align-items-center"}},
@ -118,7 +126,7 @@ def _fields_for_model(model: str):
{"name": "details", "order": 20, "attrs": {"class": "row mt-2"}}, {"name": "details", "order": 20, "attrs": {"class": "row mt-2"}},
{"name": "checkboxes", "order": 30, "parent": "details", {"name": "checkboxes", "order": 30, "parent": "details",
"attrs": {"class": "col d-flex flex-column justify-content-end"}}, "attrs": {"class": "col d-flex flex-column justify-content-end"}},
{"name": "inventory", "order": 40}, {"name": "inventory", "order": 40, "attrs": {"class": "row"}},
] ]
elif model == "worklog": elif model == "worklog":

View file

@ -1,17 +1,11 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block style %}
thead.sticky-top th {
z-index: 2;
}
{% endblock %}
{% block main %} {% block main %}
<h1 class="display-4 text-center mb-3">Inventory Summary</h1> <h1 class="display-4 text-center mb-3">Inventory Summary</h1>
<div class="table-responsive mx-5 overflow-y-auto border" style="max-height: 70vh;"> <div class="table-responsive mx-5 overflow-y-auto border" style="max-height: 70vh;">
<table class="table table-sm table-striped table-hover table-bordered align-middle mb-0"> <table class="table table-sm table-striped table-hover table-bordered align-middle mb-0">
<thead> <thead>
<tr class="position-sticky top-0 bg-body border"> <tr>
<th class="text-nowrap position-sticky top-0 bg-body border">Device Type</th> <th class="text-nowrap position-sticky top-0 bg-body border">Device Type</th>
{% for col in col_headers %} {% for col in col_headers %}
{% if col.href %} {% if col.href %}

View file

@ -1,33 +1,33 @@
<label class="form-label mt-2">Assigned Inventory</label> <label class="form-label mt-2">Assigned Inventory</label>
{% set inv = field['template_ctx']['values']['inventory'] %} {% set inv = field['template_ctx']['values']['inventory'] %}
<div class="table-responsive"> <div class="table-responsive border overflow-y-auto" style="max-height: 45vh;">
<table class="table table-sm table-bordered table-striped table-hover"> <table class="table table-sm table-bordered table-striped table-hover mb-0">
{% if inv %} {% if inv %}
<thead> <thead>
<tr> <tr>
<th>Device</th> <th class="position-sticky top-0 bg-body z-1 border">Device</th>
<th>Brand</th> <th class="position-sticky top-0 bg-body z-1 border">Brand</th>
<th>Model</th> <th class="position-sticky top-0 bg-body z-1 border">Model</th>
<th>Type</th> <th class="position-sticky top-0 bg-body z-1 border">Type</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for i in inv %} {% for i in inv if i['condition.category'] not in ['Disposed', 'Administrative'] %}
<tr style="cursor: pointer;" onclick="location.href='{{ url_for('entry.entry', model='inventory', id=i.id) }}'"> <tr style="cursor: pointer;" onclick="location.href='{{ url_for('entry.entry', model='inventory', id=i.id) }}'">
<td>{{ i.label }}</td> <td>{{ i.label }}</td>
<td>{{ i['brand.name'] }}</td> <td>{{ i['brand.name'] }}</td>
<td>{{ i.model }}</td> <td>{{ i.model }}</td>
<td>{{ i['device_type.description'] }}</td> <td>{{ i['device_type.description'] }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
{% else %} {% else %}
<thead> <thead>
<tr> <tr>
<th colspan="4" class="text-center">No data.</th> <th colspan="4" class="text-center">No data.</th>
</tr> </tr>
</thead> </thead>
{% endif %} {% endif %}
</table> </table>
</div> </div>

View file

@ -0,0 +1,37 @@
<!-- WORK LOGS -->
<label class="form-label mt-2">Work Logs</label>
{% set wl = field['template_ctx']['values']['work_logs'] %}
{% set check %}
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-check text-success" viewBox="0 0 16 16">
<path d="M10.97 4.97a.75.75 0 0 1 1.07 1.05l-3.99 4.99a.75.75 0 0 1-1.08.02L4.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093 3.473-4.425z"/>
</svg>
{% endset %}
{% set x %}
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x text-danger" viewBox="0 0 16 16">
<path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708"/>
</svg>
{% endset %}
<div class="table-responsive border overflow-y-auto" style="max-height: 45vh;">
<table class="table table-sm table-striped table-bordered table-hover mb-0">
<thead>
<tr>
<th class="position-sticky top-0 bg-body z-1 border">Device</th>
<th class="position-sticky top-0 bg-body z-1 border">Start</th>
<th class="position-sticky top-0 bg-body z-1 border">End</th>
<th class="position-sticky top-0 bg-body z-1 border"></th>
</tr>
</thead>
<tbody>
{% for l in wl %}
<tr onclick="location.href='{{ url_for('entry.entry', model='worklog', id=l.id) }}'" style="cursor: pointer;">
<td>{{ l['work_item']['label'] if l['work_item'] else '-' }}</td>
<td>{{ l.start_time if l.start_time else '-' }}</td>
<td>{{ l.end_time if l.end_time else '-' }}</td>
<td class="text-center">{{ check if l.complete else x }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>