diff --git a/inventory/templates/fragments/_editor_fragment.html b/inventory/templates/fragments/_editor_fragment.html index 4277bd7..77b0a7f 100644 --- a/inventory/templates/fragments/_editor_fragment.html +++ b/inventory/templates/fragments/_editor_fragment.html @@ -1,6 +1,6 @@ {% import "fragments/_icon_fragment.html" as icons %} -{% macro render_editor(id, title, mode='edit', content=None) %} +{% macro render_editor(id, title, mode='edit', content=None, enabled=True) %}
@@ -8,17 +8,19 @@ + {% if enabled %} + {% endif %}
- +
diff --git a/inventory/templates/worklog.html b/inventory/templates/worklog.html index 818a153..132d72d 100644 --- a/inventory/templates/worklog.html +++ b/inventory/templates/worklog.html @@ -4,115 +4,123 @@ {% block title %}{{ title }}{% endblock %} {% block content %} - +
+
+
+
+ +
+
+ +
+
+ {% for update in log.updates %} + {{ editor.render_editor( + id = update.id, + title = update.timestamp.strftime('%Y-%m-%d %H:%M:%S'), + mode = 'view', + content = update.content, + enabled = not log.complete + ) }} + {% endfor %} + +
+ {% endblock %} {% block script %} @@ -123,44 +131,11 @@ function formatDate(date) { const pad = (n) => String(n).padStart(2, '0'); return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ` - + `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`; + + `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`; } 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 = formatDate(new Date()); - 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"; - - // Hook in auto-resize - updateContent.addEventListener("input", () => autoResizeTextarea(updateContent)); - autoResizeTextarea(updateContent); - - // Stitch it all together - igroup.appendChild(ts); - igroup.appendChild(updateContent); - col.appendChild(igroup); - row.appendChild(col); - #} const template = document.getElementById("editor-template"); const newEditor = EditorWidget.createEditorWidget(template, EditorWidget.createTempId("new"), formatDate(new Date()));