Added Single Exercise Input Block
This commit is contained in:
parent
209359043e
commit
31daee2dd8
1 changed files with 80 additions and 1 deletions
|
|
@ -63,6 +63,34 @@
|
||||||
|
|
||||||
<button class="btn btn-warning mb-4" onclick="saveBlock()">Save Block (Clear Table)</button>
|
<button class="btn btn-warning mb-4" onclick="saveBlock()">Save Block (Clear Table)</button>
|
||||||
|
|
||||||
|
<hr class="my-4">
|
||||||
|
|
||||||
|
<!-- SECTION 3.5: Ad-Hoc Input -->
|
||||||
|
<h4>Add Extra Exercise (4 Sets)</h4>
|
||||||
|
<div class="row mb-3">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label>Select Exercise</label>
|
||||||
|
<select id="adhocSelect" class="form-select" onchange="generateAdhocRows()">
|
||||||
|
<option value="">Select...</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<thead class="table-dark">
|
||||||
|
<tr>
|
||||||
|
<th>Exercise</th>
|
||||||
|
<th>Group</th>
|
||||||
|
<th>Set</th>
|
||||||
|
<th>Reps</th>
|
||||||
|
<th>Weight</th>
|
||||||
|
<th>Notes</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="adhocTableBody"></tbody>
|
||||||
|
</table>
|
||||||
|
<button class="btn btn-warning mb-4" onclick="saveAdhocBlock()">Save Extra Exercise</button>
|
||||||
|
<hr class="my-4">
|
||||||
|
|
||||||
<!-- SECTION 4: Final Submission -->
|
<!-- SECTION 4: Final Submission -->
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
{% csrf_token %}
|
{% 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) {
|
function loadTemplateData(templateName) {
|
||||||
const tbody = document.getElementById('activeTableBody');
|
const tbody = document.getElementById('activeTableBody');
|
||||||
tbody.innerHTML = '';
|
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 = `
|
||||||
|
<tr>
|
||||||
|
<td>${exName}<input type="hidden" class="d-ex" value="${exName}"></td>
|
||||||
|
<td>${gr}<input type="hidden" class="d-gr" value="${gr}">
|
||||||
|
<input type="hidden" class="d-ty" value="${ty}"></td>
|
||||||
|
<td>${set}<input type="hidden" class="d-st" value="${set}"></td>
|
||||||
|
<td><input type="number" class="table-input d-rp" value="0"></td>
|
||||||
|
<td><input type="number" class="table-input d-wt" step="0.5" value="0"></td>
|
||||||
|
<td><input type="text" class="table-input d-nt" value="" placeholder="Notes"></td>
|
||||||
|
</tr>`;
|
||||||
|
tbody.insertAdjacentHTML('beforeend', row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function saveBlock() {
|
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 logBody = document.getElementById('logTableBody');
|
||||||
const hiddenDiv = document.getElementById('hiddenInputs');
|
const hiddenDiv = document.getElementById('hiddenInputs');
|
||||||
|
|
||||||
|
|
@ -229,6 +306,8 @@
|
||||||
// Clear Active Table
|
// Clear Active Table
|
||||||
activeBody.innerHTML = '';
|
activeBody.innerHTML = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
populateAdhocDropdown();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue