diff --git a/frontend/www/scripts/workout.js b/frontend/www/scripts/workout.js index b351b1879bbfb78ecbd5c7338bcb7a115f52ff2f..bc95851bb273e4b8332432a2c0fd701febe8c9b0 100644 --- a/frontend/www/scripts/workout.js +++ b/frontend/www/scripts/workout.js @@ -34,6 +34,7 @@ async function retrieveWorkout(id) { } let input = form.querySelector("select:disabled"); + document.getElementById("divAthlete").style.display = "none"; input.value = workoutData["visibility"]; // files let filesDiv = document.querySelector("#uploaded-files"); @@ -108,6 +109,7 @@ async function retrieveWorkout(id) { let exerciseNumberInput = divExerciseContainer.querySelector( "input[name='number']" ); + exerciseNumberInput.id = `inputNumber${i}`; exerciseNumberInput.value = workoutData.exercise_instances[i].number; exerciseNumberInput.readOnly = true; @@ -154,8 +156,8 @@ function handleEditWorkoutButtonClick() { let removeExerciseButton = document.querySelector("#btn-remove-exercise"); setReadOnly(false, "#form-workout"); + document.querySelector("#inputOwner").readOnly = true; // owner field should still be readonly - document.querySelector("#forAthlete").hidden = true editWorkoutButton.className += " hide"; okWorkoutButton.className = okWorkoutButton.className.replace(" hide", ""); @@ -220,7 +222,7 @@ function generateWorkoutForm() { submitForm.append("name", formData.get("name")); let date = new Date(formData.get("date")).toISOString(); submitForm.append("date", date); - submitForm.append("owner", formData.get("owner_username")) + submitForm.append("owner", formData.get("owner_username")); submitForm.append("notes", formData.get("notes")); submitForm.append("visibility", formData.get("visibility")); @@ -247,7 +249,7 @@ function generateWorkoutForm() { async function createWorkout() { let submitForm = generateWorkoutForm(); - console.log(submitForm) + console.log(submitForm); let response = await sendRequest( "POST", @@ -422,15 +424,12 @@ window.addEventListener("DOMContentLoaded", async () => { } else { await createBlankExercise(); - coach = false; //sjekke om den er huket av let query = "#inputOwner"; let ownerInput = document.querySelector(query); + let check = document.querySelector("#forAthlete"); + console.log(check); ownerInput.value = currentUser.username; - if (coach) { - query = "#athletes"; - ownerInput = document.querySelector(query); - ownerInput.value = "athlete1"; - } + console.log(ownerInput.value); setReadOnly(false, "#form-workout"); ownerInput.readOnly = !ownerInput.readOnly; diff --git a/frontend/www/workout.html b/frontend/www/workout.html index 9be50088c6c29fe878290be404eb368938529662..25af4423a4d864af19ba2aae179fab3af8a088fb 100644 --- a/frontend/www/workout.html +++ b/frontend/www/workout.html @@ -60,8 +60,10 @@ </div> <div class="col-lg-6"></div> <div class="col-lg-6"> - <label for="forAthlete">Create workout for athlete</label> - <input id="forAthlete" type="checkbox" onclick="athleteChecked()" /> + <div id="divAthlete"> + <label for="forAthlete">Create workout for athlete</label> + <input id="forAthlete" type="checkbox" onclick="athleteChecked()" /> + </div> <div class="col-lg-6"></div> <p>Owner</p>