From e31a78c3cc4b7691c67b8109d4984a3a857b9fda Mon Sep 17 00:00:00 2001 From: stilbruch Date: Mon, 9 May 2022 00:50:45 -0500 Subject: Fixed workout create bug --- BUGS | 2 -- app/static/js/create.js | 26 ++++++++++---------------- app/templates/workout/create.html | 10 +++++----- 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/BUGS b/BUGS index 0fe296a..e69de29 100644 --- a/BUGS +++ b/BUGS @@ -1,2 +0,0 @@ -/workout/edit: - Adding a workout to the edit page does not work diff --git a/app/static/js/create.js b/app/static/js/create.js index 0f63956..a9bf7ae 100644 --- a/app/static/js/create.js +++ b/app/static/js/create.js @@ -32,22 +32,16 @@ function handleDel(elem) { } } -document.getElementById("add").onclick = handleAdd; - function handleChange(elem) { - if (elem.target.value == 'time') { - elem.target.parentNode.parentNode.parentNode.children[1].placeholder = "Time (in seconds)"; - elem.target.parentNode.parentNode.parentNode.children[1].selected = true; - elem.target.parentNode.parentNode.children[1].children[0].classList.remove('fa-calculator'); - elem.target.parentNode.parentNode.children[1].children[0].classList.add('fa-clock-o'); - } else if (elem.target.value == 'reps') { - elem.target.parentNode.parentNode.children[1].children[0].classList.add('fa-calculator'); - elem.target.parentNode.parentNode.children[1].children[0].classList.remove('fa-clock-o'); - elem.target.parentNode.parentNode.parentNode.children[1].selected = true; - elem.target.parentNode.parentNode.parentNode.children[1].placeholder = "Reps"; + if (elem.value == 'time') { + elem.parentNode.parentNode.parentNode.children[1].placeholder = "Time (in seconds)"; + elem.parentNode.parentNode.parentNode.children[1].selected = true; + elem.parentNode.parentNode.children[1].children[0].classList.remove('fa-calculator'); + elem.parentNode.parentNode.children[1].children[0].classList.add('fa-clock-o'); + } else if (elem.value == 'reps') { + elem.parentNode.parentNode.children[1].children[0].classList.add('fa-calculator'); + elem.parentNode.parentNode.children[1].children[0].classList.remove('fa-clock-o'); + elem.parentNode.parentNode.parentNode.children[1].selected = true; + elem.parentNode.parentNode.parentNode.children[1].placeholder = "Reps"; } } - -for (row of rowsDiv.children) { - row.children[0].children[2].children[0].children[0].children[0].addEventListener('input', handleChange); -} diff --git a/app/templates/workout/create.html b/app/templates/workout/create.html index 628ef74..569717a 100644 --- a/app/templates/workout/create.html +++ b/app/templates/workout/create.html @@ -24,9 +24,6 @@
{% for entry in form.exercises.entries %} - {% if workout %} - {{ entry['id']() }} - {% endif %}
@@ -53,13 +50,13 @@
- {{ entry['type'] }} + {{ entry['type'](oninput='handleChange(this)') }}
- {{ entry['units'](class_='input', placeholder="Reps") }} + {{ entry['units'](class_='input', placeholder='Reps') }}

@@ -68,6 +65,9 @@

+ {% if workout %} + {{ entry['id']() }} + {% endif %} {% endfor %}
-- cgit v1.2.3