From 31daee2dd8e178be552052b006df7bc06481caf3 Mon Sep 17 00:00:00 2001 From: Cutty Date: Thu, 19 Mar 2026 15:51:07 -0600 Subject: [PATCH] Added Single Exercise Input Block --- .../tracker/templates/tracker/index.html | 81 ++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/zed_workouts/tracker/templates/tracker/index.html b/zed_workouts/tracker/templates/tracker/index.html index a95daab..ccd7f22 100644 --- a/zed_workouts/tracker/templates/tracker/index.html +++ b/zed_workouts/tracker/templates/tracker/index.html @@ -63,6 +63,34 @@ +
+ + +

Add Extra Exercise (4 Sets)

+
+
+ + +
+
+ + + + + + + + + + + + +
ExerciseGroupSetRepsWeightNotes
+ +
+
{% csrf_token %} @@ -119,6 +147,19 @@ }); } + function populateAdhocDropdown() { + const select = document.getElementById('adhocSelect'); + const sorted = [...exercises].sort((a,b) => a.exercise.localeCompare(b.exercise)); + sorted.forEach(ex => { + const opt = document.createElement('option'); + opt.value = ex.exercise; + opt.text = ex.exercise; + opt.dataset.type = ex.type; + opt.dataset.group = ex.group; + select.appendChild(opt); + }); + } + function loadTemplateData(templateName) { const tbody = document.getElementById('activeTableBody'); tbody.innerHTML = ''; @@ -194,8 +235,44 @@ } } + function generateAdhocRows() { + const select = document.getElementById('adhocSelect'); + const tbody = document.getElementById('adhocTableBody'); + tbody.innerHTML = ''; + + if (!select.value) return; + + const opt = select.options[select.selectedIndex]; + const exName = select.value; + const gr = opt.dataset.group; + const ty = opt.dataset.type; + + for (let set = 1; set <= 4; set++) { + const row = ` + + ${exName} + ${gr} + + ${set} + + + + `; + tbody.insertAdjacentHTML('beforeend', row); + } + } + function saveBlock() { - const activeBody = document.getElementById('activeTableBody'); + processSaveBlock('activeTableBody'); + } + + function saveAdhocBlock() { + processSaveBlock('adhocTableBody'); + document.getElementById('adhocSelect').value = ''; + } + + function processSaveBlock(tableId) { + const activeBody = document.getElementById(tableId); const logBody = document.getElementById('logTableBody'); const hiddenDiv = document.getElementById('hiddenInputs'); @@ -229,6 +306,8 @@ // Clear Active Table activeBody.innerHTML = ''; } + + populateAdhocDropdown();