diff --git a/__pycache__/routes.cpython-313.pyc b/__pycache__/routes.cpython-313.pyc index 5802dc8..826fd92 100644 Binary files a/__pycache__/routes.cpython-313.pyc and b/__pycache__/routes.cpython-313.pyc differ diff --git a/routes.py b/routes.py index f181b50..905aac2 100644 --- a/routes.py +++ b/routes.py @@ -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) \ No newline at end of file + return render_template("worklog.html", title=f"Work Log #{id}", log=log, users=users, items=items, form_fields=worklog_form_fields) diff --git a/static/js/datalist.js b/static/js/datalist.js new file mode 100644 index 0000000..d17a9fc --- /dev/null +++ b/static/js/datalist.js @@ -0,0 +1,20 @@ +document.querySelectorAll('[data-datalist-bind]').forEach(input => { + const datalistSelector = input.dataset.datalistBind; + const hiddenSelector = input.dataset.hiddenTarget; + const datalist = document.querySelector(datalistSelector); + const hidden = document.querySelector(hiddenSelector); + + if (!datalist || !hidden) return; + + input.addEventListener('input', function () { + const value = this.value; + const options = datalist.querySelectorAll('option'); + let foundId = ''; + options.forEach(option => { + if (option.value === value) { + foundId = option.dataset.id || ''; + } + }); + hidden.value = foundId; + }); +}); diff --git a/templates/form.html b/templates/form.html new file mode 100644 index 0000000..74b7ba4 --- /dev/null +++ b/templates/form.html @@ -0,0 +1,10 @@ + +{% extends "layout.html" %} + +{% import "_table_fragment.html" as tables %} + +{% block title %}{{ title }}{% endblock %} + +{% block content %} + +{% endblock %} diff --git a/templates/inventory.html b/templates/inventory.html index ce13946..b488c22 100644 --- a/templates/inventory.html +++ b/templates/inventory.html @@ -9,10 +9,12 @@ -
-
-
-
- - -
- -
- - -
-
- -
-
- - - - - {% for supervisor in users %} - - {% endfor %} - -
- -
- - - - - {% for location in rooms %} - - {% endfor %} - -
-
-
-
- - -
-
- - -
-
-
-
- {% if inventory_rows %} -
-
- {{ tables.render_table(inventory_headers, inventory_rows, 'inventory_item', title='Assets') }} -
-
- {% endif %} - {% if worklog_rows %} -
-
- {{ tables.render_table(worklog_headers, worklog_rows, 'worklog_entry', title='Work Done') }} -
-
- {% endif %} -
+
+
- {% if inventory_pagination['total_pages'] > 1 %} -
- {{ tables.render_pagination( - page=inventory_pagination['page'], - has_prev=inventory_pagination['has_prev'], - has_next=inventory_pagination['has_next'], - total_pages=inventory_pagination['total_pages'], - endpoint='main.user', - page_variable='asset_page', - extra_args={'id': user.id, 'worklog_page': worklog_page} - ) }} -
- {% endif %} - {% 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.user', - page_variable='worklog_page', - extra_args={'id': user.id, 'worklog_page': worklog_page} - ) }} -
- {% endif %} -
-
-{% endblock %} +
+ + +
-{% block script %} -document.getElementById('supervisor').addEventListener('input', function() { - const input = this.value; - const options = document.querySelectorAll('#supervisorList option'); - let foundId = ''; - options.forEach(option => { - if (option.value === input) { - foundId = option.dataset.id; - } - }) - document.getElementById('supervisorId').value = foundId; -}); +
+ + +
+
+ +
+
+ + + + + {% for supervisor in users %} + + {% endfor %} + +
+ +
+ + + + + {% for location in rooms %} + + {% endfor %} + +
+
+
+
+ + +
+
+ + +
+
+ +
+ {% if inventory_rows %} +
+
+ {{ tables.render_table(inventory_headers, inventory_rows, 'inventory_item', title='Assets') }} +
+
+ {% endif %} + {% if worklog_rows %} +
+
+ {{ tables.render_table(worklog_headers, worklog_rows, 'worklog_entry', title='Work Done') }} +
+
+ {% endif %} +
+
+ {% if inventory_pagination['total_pages'] > 1 %} +
+ {{ tables.render_pagination( + page=inventory_pagination['page'], + has_prev=inventory_pagination['has_prev'], + has_next=inventory_pagination['has_next'], + total_pages=inventory_pagination['total_pages'], + endpoint='main.user', + page_variable='asset_page', + extra_args={'id': user.id, 'worklog_page': worklog_page} + ) }} +
+ {% endif %} + {% 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.user', + page_variable='worklog_page', + extra_args={'id': user.id, 'worklog_page': worklog_page} + ) }} +
+ {% endif %} +
+ {% endblock %} \ No newline at end of file diff --git a/templates/worklog.html b/templates/worklog.html index e8376f5..7ee507e 100644 --- a/templates/worklog.html +++ b/templates/worklog.html @@ -7,54 +7,102 @@ {% block content %} -{% endblock %} + +{% endblock %} \ No newline at end of file