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

@ -63,6 +63,17 @@ worklog_headers = {
"Quick Analysis?": lambda i: {"text": i.analysis, "type": "bool", "html": checked_box if i.analysis else unchecked_box},
}
worklog_form_fields = {
"start": lambda log: {"label": "Start Timestamp", "type": "date", "value": log.start_time.date().isoformat() if log.start_time else ""},
"end": lambda log: {"label": "End Timestamp", "type": "date", "value": log.end_time.date().isoformat() if log.end_time else ""},
"contact": lambda log: {"label": "Contact", "type": "datalist", "value": log.contact.full_name if log.contact else "", "list": "contactList"},
"item": lambda log: {"label": "Work Item", "type": "datalist", "value": log.work_item.identifier if log.work_item else "", "list": "itemList"},
"complete": lambda log: {"label": "Complete?", "type": "checkbox", "value": log.complete},
"followup": lambda log: {"label": "Follow Up?", "type": "checkbox", "value": log.followup},
"analysis": lambda log: {"label": "Quick Analysis?", "type": "checkbox", "value": log.analysis},
"notes": lambda log: {"label": "Notes", "type": "textarea", "value": log.notes or "", "rows": 15}
}
def make_paginated_data(
query,
page: int,
@ -233,4 +244,4 @@ def worklog_entry(id):
users = eager_load_user_relationships(user_query).all()
item_query = db.session.query(Inventory)
items = eager_load_inventory_relationships(item_query).all()
return render_template("worklog.html", title=f"Work Log #{id}", log=log, users=users, items=items)
return render_template("worklog.html", title=f"Work Log #{id}", log=log, users=users, items=items, form_fields=worklog_form_fields)