From a4bfb9838cf859d921abfdcb8a1d788f776d578e Mon Sep 17 00:00:00 2001 From: Yaro Kasear Date: Mon, 21 Jul 2025 08:30:29 -0500 Subject: [PATCH] Enhance button functionality in inventory, user, and worklog templates to include dynamic 'new' buttons and improve save button styling for better UI consistency --- inventory/templates/inventory.html | 24 ++++++++++++++++-------- inventory/templates/user.html | 25 +++++++++++++++++++------ inventory/templates/worklog.html | 10 +++++++++- 3 files changed, 44 insertions(+), 15 deletions(-) diff --git a/inventory/templates/inventory.html b/inventory/templates/inventory.html index 73a8301..2011f8d 100644 --- a/inventory/templates/inventory.html +++ b/inventory/templates/inventory.html @@ -25,10 +25,10 @@ try { const id = document.querySelector("#inventoryId").value; const isEdit = id && id !== "None"; - + const endpoint = isEdit ? `/api/inventory/${id}` : "/api/inventory"; const method = isEdit ? "PUT" : "POST"; - + const response = await fetch(endpoint, { method, headers: { @@ -36,14 +36,14 @@ }, body: JSON.stringify(payload) }); - + const result = await response.json(); if (result.success) { localStorage.setItem("toastMessage", JSON.stringify({ message: isEdit ? "Inventory item updated!" : "Inventory item created!", type: "success" })); - + window.location.href = `/inventory_item/${result.id}`; } else { renderToast({ message: `Error: ${result.error}`, type: "danger" }); @@ -69,15 +69,15 @@ const response = await fetch(`/api/inventory/${id}`, { method: "DELETE" }); - + const result = await response.json(); - + if (result.success) { localStorage.setItem("toastMessage", JSON.stringify({ message: "Inventory item deleted.", type: "success" })); - + window.location.href = "/inventory"; } else { renderToast({ message: `Error: ${result.error}`, type: "danger" }); @@ -89,11 +89,19 @@ {% endset %} {% set buttonBar %}
+ {% if item.id != None %} + {{ buttons.render_button( + id='new', + icon='plus-lg', + style='outline-primary rounded-start', + logic="window.location.href = '" + url_for('main.new_inventory_item') + "';" + )}} + {% endif %} {{ buttons.render_button( id='save', icon='floppy', logic=saveLogic, - style="outline-primary rounded-start" + style="outline-primary" + (' rounded-end' if not item.id else '') ) }} {% if item.id != None %} {{ buttons.render_button( diff --git a/inventory/templates/user.html b/inventory/templates/user.html index 7a7cac5..ae93bd8 100644 --- a/inventory/templates/user.html +++ b/inventory/templates/user.html @@ -46,6 +46,24 @@ console.error(err); } {% endset %} + {% set iconBar %} +
+ {% if user.id != None %} + {{ buttons.render_button( + id = 'new', + icon = 'plus-lg', + style = 'outline-secondary rounded-start', + logic = "window.location.href = '" + url_for('main.new_user') + "';" + )}} + {% endif %} + {{ buttons.render_button( + id = 'save', + icon = 'floppy', + logic = saveLogic, + style = 'outline-primary rounded-end' + ) }} +
+ {% endset %} {{ toolbars.render_toolbar( id = 'newUser', left = breadcrumbs.breadcrumb_header( @@ -54,12 +72,7 @@ {'label': 'Users', 'url': url_for('main.list_users')} ] ), - right = buttons.render_button( - id = 'save', - icon = 'floppy', - logic = saveLogic, - style = 'outline-primary' - ) + right = iconBar ) }} {% if not user.active %}
This user is inactive. You will not be able to make any changes to this record.
diff --git a/inventory/templates/worklog.html b/inventory/templates/worklog.html index fa664c4..6eafdcb 100644 --- a/inventory/templates/worklog.html +++ b/inventory/templates/worklog.html @@ -95,11 +95,19 @@ {% endset %} {% set iconBar %}
+ {% if log.id != None %} + {{ buttons.render_button( + id='new', + icon='plus-lg', + style='outline-primary rounded-start', + logic="window.location.href = '" + url_for('main.new_worklog') + "';" + ) }} + {% endif %} {{ buttons.render_button( id='save', icon='floppy', logic=saveLogic, - style='outline-primary rounded-start' + style='outline-primary' ) }} {% if log.id != None %} {{ buttons.render_button(