weightinput is now being displayed and the state is safed. TODO safe state for each exercise.
parent
39e7f9daa7
commit
f6f3ad8fa9
|
|
@ -8,27 +8,19 @@ export const useWeightInputStore = defineStore('weightInput', () => {
|
||||||
|
|
||||||
function addWorkingSet(selectedExercise) {
|
function addWorkingSet(selectedExercise) {
|
||||||
if (!exercises.value[selectedExercise]) {
|
if (!exercises.value[selectedExercise]) {
|
||||||
exercises.value[selectedExercise] = {
|
return;
|
||||||
workingSet: [],
|
|
||||||
};
|
|
||||||
exercises.value[selectedExercise].workingSet.push({
|
|
||||||
workingSetReps: [],
|
|
||||||
workingSetWeight: [],});
|
|
||||||
}
|
}
|
||||||
exercises.value[selectedExercise].workingSet.push({
|
exercises.value[selectedExercise].workingSet.push({
|
||||||
workingSetReps: [],
|
workingSetReps: [],
|
||||||
workingSetWeight: [],
|
workingSetWeight: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log('Added working set:', exercises.value[selectedExercise]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addWarmUpSet(selectedExercise) {
|
function addWarmUpSet(selectedExercise) {
|
||||||
if (!exercises.value[selectedExercise]) {
|
if (!exercises.value[selectedExercise]) {
|
||||||
exercises.value[selectedExercise] = {
|
return;
|
||||||
warmUpSet: [],
|
|
||||||
};
|
|
||||||
exercises.value[selectedExercise].warmUpSet.push({
|
|
||||||
warmSetReps: [],
|
|
||||||
warmSetWeight: [],});
|
|
||||||
}
|
}
|
||||||
exercises.value[selectedExercise].warmUpSet.push({
|
exercises.value[selectedExercise].warmUpSet.push({
|
||||||
warmSetReps: [],
|
warmSetReps: [],
|
||||||
|
|
@ -37,35 +29,37 @@ export const useWeightInputStore = defineStore('weightInput', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeWorkingSet(selectedExercise) {
|
function removeWorkingSet(selectedExercise) {
|
||||||
if(exercises.value[selectedExercise]) {
|
if(!exercises.value[selectedExercise]) {
|
||||||
exercises.workingSet.pop({
|
return
|
||||||
workingSetReps: [],
|
|
||||||
workingSetsWeight: [],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
exercises.value[selectedExercise].workingSet.pop({
|
||||||
|
workingSetReps: [],
|
||||||
|
workingSetsWeight: [],
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeWarmUpSet(selectedExercise) {
|
function removeWarmUpSet(selectedExercise) {
|
||||||
if(exercises.value[selectedExercise]) {
|
if(!exercises.value[selectedExercise]) {
|
||||||
exercises.warmUpSet.pop({
|
return;
|
||||||
warmUpSetReps: [],
|
|
||||||
warmUpSetsWeight: [],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
exercises.value[selectedExercise].workingSet.pop({
|
||||||
|
warmUpSetReps: [],
|
||||||
|
warmUpSetsWeight: [],
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWorkingSetCount(selectedExercise) {
|
function getWorkingSetCount(selectedExercise) {
|
||||||
if (exercises.value[selectedExercise]) {
|
if (exercises.value[selectedExercise]) {
|
||||||
return exercises.value[selectedExercise].workingSet.length;
|
return exercises.value[selectedExercise].workingSet.length;
|
||||||
}
|
}
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWarmUpSetCount(selectedExercise) {
|
function getWarmUpSetCount(selectedExercise) {
|
||||||
if (exercises.value[selectedExercise]) {
|
if (exercises.value[selectedExercise]) {
|
||||||
return exercises.value[selectedExercise].warmUpSet.length;
|
return exercises.value[selectedExercise].warmUpSet.length;
|
||||||
}
|
}
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function initSetsInputs(selectedExercise) {
|
function initSetsInputs(selectedExercise) {
|
||||||
|
|
@ -74,7 +68,6 @@ export const useWeightInputStore = defineStore('weightInput', () => {
|
||||||
workingSet: [],
|
workingSet: [],
|
||||||
warmUpSet: [],
|
warmUpSet: [],
|
||||||
};
|
};
|
||||||
};
|
|
||||||
exercises.value[selectedExercise].workingSet.push({
|
exercises.value[selectedExercise].workingSet.push({
|
||||||
workingSetReps: [],
|
workingSetReps: [],
|
||||||
workingSetWeight: [],
|
workingSetWeight: [],
|
||||||
|
|
@ -83,9 +76,18 @@ export const useWeightInputStore = defineStore('weightInput', () => {
|
||||||
warmSetReps: [],
|
warmSetReps: [],
|
||||||
warmSetWeight: [],
|
warmSetWeight: [],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return { exercises, addWorkingSet, removeWorkingSet, addWarmUpSet, removeWarmUpSet, getWorkingSetCount, getWarmUpSetCount, initSetsInputs }
|
return {
|
||||||
|
exercises,
|
||||||
|
addWorkingSet,
|
||||||
|
removeWorkingSet,
|
||||||
|
addWarmUpSet,
|
||||||
|
removeWarmUpSet,
|
||||||
|
getWorkingSetCount,
|
||||||
|
getWarmUpSetCount,
|
||||||
|
initSetsInputs }
|
||||||
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -7,26 +7,24 @@
|
||||||
Add
|
Add
|
||||||
</button>
|
</button>
|
||||||
<button :disabled="!warmUpSetSmallerOne"
|
<button :disabled="!warmUpSetSmallerOne"
|
||||||
@click="weightInpug.removeWarmUpSet()"
|
@click="weightInput.removeWarmUpSet()"
|
||||||
class="bg-accent hover:bg-primary-button text-white font-bold py-2 px-2 rounded ml-5 disabled:opacity-25">
|
class="bg-accent hover:bg-primary-button text-white font-bold py-2 px-2 rounded ml-5 disabled:opacity-25">
|
||||||
Remove
|
Remove
|
||||||
</button>
|
</button>
|
||||||
<div>
|
<div>
|
||||||
<div v-for="(warmUpSet, warmUpSetCount) in weightInput.exercises.warmUpSets" :key="warmUpSetCount" class="item flex justify-smart mt-1">
|
<div v-for="(warmUpSet, warmUpSetCount) in weightInput.exercises[selectedExercise].warmUpSet" :key="warmUpSetCount" class="item flex justify-smart mt-1">
|
||||||
{{ warmUpSet }}
|
<label class="break-normal"> {{ warmUpSetCount + 1 }}. Set</label>
|
||||||
<div class="ml-3">
|
<div class="ml-3">
|
||||||
<label class="ml-3 mt-2"> {{ warmUpSetCount }}. Set</label>
|
|
||||||
<input
|
<input
|
||||||
v-model="weightInput.exercises.warmUpSets.warmUpSetsWeight[warmUpSetCount]"
|
v-model="warmUpSet.warmUpWeight"
|
||||||
type="number"
|
type="number"
|
||||||
class="mt-1 px-3 py-2 bg-black border shadow-sm border-slate-300 placeholder-slate-400 focus:outline-none block rounded-md sm:text-sm "
|
class="mt-1 px-3 py-2 bg-black border shadow-sm border-slate-300 placeholder-slate-400 focus:outline-none block rounded-md sm:text-sm "
|
||||||
placeholder="Weight (kg)"
|
placeholder="Weight (kg)"
|
||||||
onkeypress='return event.charCode >= 48 && event.charCode <= 57'/>
|
onkeypress='return event.charCode >= 48 && event.charCode <= 57'/>
|
||||||
</div>
|
</div>
|
||||||
<label class="ml-3 mt-2">Reps</label>
|
|
||||||
<div class="ml-3">
|
<div class="ml-3">
|
||||||
<input
|
<input
|
||||||
v-model="weightInput.exercises.warmUpSets.warmUpSetReps[warmUpSetCount]"
|
v-model="warmUpSet.warmUpReps"
|
||||||
type="number"
|
type="number"
|
||||||
class="mt-1 px-3 py-2 bg-black border shadow-sm border-slate-300 placeholder-slate-400 focus:outline-none block rounded-md sm:text-sm "
|
class="mt-1 px-3 py-2 bg-black border shadow-sm border-slate-300 placeholder-slate-400 focus:outline-none block rounded-md sm:text-sm "
|
||||||
placeholder="Reps"
|
placeholder="Reps"
|
||||||
|
|
@ -48,20 +46,19 @@
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div v-for="(workingset, workingSetCount) in weightInput.exercises.workingSets" :key="workingSetCount" class="item flex justify-smart mt-1">
|
<div v-for="(workingset, workingSetCount) in weightInput.exercises[selectedExercise].workingSet" :key="workingSetCount" class="item flex justify-smart mt-1">
|
||||||
{{ workingset }}
|
<label class=""> {{ workingSetCount + 1 }}. Set</label>
|
||||||
<div class="ml-3">
|
<div class="ml-3">
|
||||||
<input
|
<input
|
||||||
v-model="weightInput.exercises.workingSets.workingSetsWeight[workingSetCount]"
|
v-model="workingset.workingSetWeight"
|
||||||
type="number"
|
type="number"
|
||||||
class="mt-1 px-3 py-2 bg-black border shadow-sm border-slate-300 placeholder-slate-400 focus:outline-none block rounded-md sm:text-sm "
|
class="mt-1 px-3 py-2 bg-black border shadow-sm border-slate-300 placeholder-slate-400 focus:outline-none block rounded-md sm:text-sm "
|
||||||
placeholder="Weight (Kg)"
|
placeholder="Weight (Kg)"
|
||||||
onkeypress='return event.charCode >= 48 && event.charCode <= 57'/>
|
onkeypress='return event.charCode >= 48 && event.charCode <= 57'/>
|
||||||
</div>
|
</div>
|
||||||
<label class="ml-3 mt-2">Reps</label>
|
|
||||||
<div class="ml-3">
|
<div class="ml-3">
|
||||||
<input
|
<input
|
||||||
v-model="weightInput.exercises.workingSets.workingSetReps[workingSetCount]"
|
v-model="workingset.workingSetReps"
|
||||||
type="number"
|
type="number"
|
||||||
class="mt-1 px-3 py-2 bg-black border shadow-sm border-slate-300 placeholder-slate-400 focus:outline-none block rounded-md sm:text-sm "
|
class="mt-1 px-3 py-2 bg-black border shadow-sm border-slate-300 placeholder-slate-400 focus:outline-none block rounded-md sm:text-sm "
|
||||||
placeholder="Reps"
|
placeholder="Reps"
|
||||||
|
|
@ -89,21 +86,11 @@ weightInput.selectedExercise = ref(selectedExercise.selectedExercise);
|
||||||
// weightInput.addWorkingSet(selectedExercise.selectedExercise);}
|
// weightInput.addWorkingSet(selectedExercise.selectedExercise);}
|
||||||
|
|
||||||
const warmUpSetSmallerOne = () => {
|
const warmUpSetSmallerOne = () => {
|
||||||
if (weightInput.getWarmUpSetCount < 1) {
|
weightInput.getWarmUpSetCount <= 1 ? false : true;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const workingSetSmallerOne = () => {
|
const workingSetSmallerOne = () => {
|
||||||
if (weightInput.getWorkingSetCount < 1) {
|
weightInput.getWorkingSetCount <= 1 ? false : true;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
Loading…
Reference in New Issue