diff --git a/inventory/templates/worklog.html b/inventory/templates/worklog.html
index 5bd2209..4b43f27 100644
--- a/inventory/templates/worklog.html
+++ b/inventory/templates/worklog.html
@@ -97,17 +97,28 @@
#}
-
- {% for update in log.updates %}
+
+
+
+
-
- {{ update.timestamp.strftime('%Y-%m-%d %H:%M:%S') }}
-
-
+
- {% endfor %}
+ {% for update in log.updates %}
+
+
+
+ {{ update.timestamp.strftime('%Y-%m-%d %H:%M:%S') }}
+
+
+
+
+ {% endfor %}
+
{% endblock %}
@@ -115,20 +126,56 @@
{% block script %}
const saveButton = document.getElementById("saveButton");
const deleteButton = document.getElementById("deleteButton");
+ const addUpdateButton = document.getElementById("addUpdateButton");
- const updateTextareas = Array.from(document.querySelectorAll("textarea[name^='update']"));
- const updates = updateTextareas.map(el => {
- const id = el.dataset.noteId;
- const content = el.value;
- return id ? { id, content } : { content };
- });
+ if (addUpdateButton) {
+ addUpdateButton.addEventListener("click", (e) => {
+ const row = document.createElement("div");
+ row.classList.add("row");
+
+ const col = document.createElement("div");
+ col.classList.add("col");
+
+ const igroup = document.createElement("div");
+ igroup.classList.add("input-group", "mb-3");
+
+ // Timestamp span (just display the current time)
+ const ts = document.createElement("span");
+ ts.classList.add("input-group-text");
+ const now = new Date().toLocaleString(); // you could go full ISO if you're feeling spicy
+ ts.textContent = now;
+
+ // Textarea for update content
+ const updateContent = document.createElement("textarea");
+ updateContent.classList.add("form-control");
+ updateContent.placeholder = "Enter update...";
+ updateContent.dataset.noteId = "";
+ updateContent.name = "updateNew";
+
+ // Stitch it all together
+ igroup.appendChild(ts);
+ igroup.appendChild(updateContent);
+ col.appendChild(igroup);
+ row.appendChild(col);
+
+ const updatesContainer = document.getElementById("updates-container");
+ updatesContainer.appendChild(row);
+ });
+ }
if (saveButton) {
saveButton.addEventListener("click", async (e) => {
e.preventDefault();
const updateTextareas = Array.from(document.querySelectorAll("textarea[name^='update']"));
- const updates = updateTextareas.map(el => el.value).filter(val => val.trim() !== '');
+ const updates = updateTextareas
+ .map(el => {
+ const content = el.value.trim();
+ if (!content) return null;
+ const id = el.dataset.noteId;
+ return id ? { id, content } : { content };
+ })
+ .filter(u => u !== null);
const payload = {
start_time: document.querySelector("input[name='start']").value,