I try to make a workout page where I can add multiple exercises to a workout. For now I can log a workout with multiple exercises. But how do i add sets (objects) to an idividual exercise?
So this is my pageVars structure:
editWorkouts
- editing
- id
- name
- power
- settings
- weight
I can add a exercise with:
INSERT_ITEM_AT(pageVars.editWorkouts, 1,{name: repeated.current.name, weight: repeated.current.weight, settings: repeated.current.settings, power: repeated.current.power})
After editing an excercise I store the objects with: SET_ITEM_AT(pageVars.editWorkouts, INDEX_OF(pageVars.editWorkouts, repeated.current), {name: repeated.current.name, weight: repeated.current.weight, settings: repeated.current.settings, id: repeated.current.id , power: repeated.current.power, editing: false})
After that I can store the pageVars to my local database. So far it works.
Now I want to add the following to the exercises:
- sets (list of objects)
- id
- reps
- setnumber
- weight
So it becomes:
editWorkouts
- editing
- id
- name
- power
- settings
- weight
- sets (list of objects)
- id
- reps
- setnumber
- weight
I think it must be something like this but that messes up everything:
INSERT_ITEM_AT(pageVars.editWorkouts, INDEX_OF(sets, -1),INSERT_ITEM_AT(sets, 1,{reps: “1”, weight: “1”, setnumber: “1”}))