Workouts tab.

Commit
976ae940ef18244cbbc1dd81d67b2da9222826a2
Author
Marius Peter <marius.peter@tutanota.com>
Author date
Committer
Marius Peter <marius.peter@tutanota.com>
Committer date
Changed files
src/MyFitnessTracker/MFTWorkoutsListComponent.class.st
index 36546171..00000000 100644..000000
@@ -1,109 +0,0 @@
1 Removed: "
2 Removed: I represent the list of user workouts retrieved from the database.
3 Removed:
4 Removed: I am rendered by `MFTRootComponent` when the user views their workouts. I know about user workouts retrieved from the database.
5 Removed:
6 Removed: * Collaborators
7 Removed:
8 Removed: - I work with lists of `MFTWorkout`s.
9 Removed: - I might work with `MFTExercise class`canonical exercises once the variable is implemented.
10 Removed:
11 Removed: Public API and Key Messages
12 Removed:
13 Removed: - message one
14 Removed: - message two
15 Removed: - (for bonus points) how to create instances.
16 Removed:
17 Removed: One simple example is simply gorgeous.
18 Removed:
19 Removed: Internal Representation and Key Implementation Points.
20 Removed:
21 Removed:
22 Removed: Implementation Points
23 Removed: "
24 Removed: Class {
25 Removed: #name : #MFTWorkoutsListComponent,
26 Removed: #superclass : #MFTScreenComponent,
27 Removed: #instVars : [
28 Removed: 'workouts'
29 Removed: ],
30 Removed: #category : #'MyFitnessTracker-Components'
31 Removed: }
32 Removed:
33 Removed: { #category : #rendering }
34 Removed: MFTWorkoutsListComponent class >> placeholder [
35 Removed: "Return a placeholder list of three workouts."
36 Removed:
37 Removed: | placeholderWorkouts workout1 workout2 workout3 |
38 Removed: placeholderWorkouts := OrderedCollection new.
39 Removed: workout1 := MFTWorkout new
40 Removed: primaryMuscle: MFTMuscle chest;
41 Removed: exercises: {
42 Removed: (MFTExercise cableRow sets: {
43 Removed: (MFTSet reps: 8 rpe: 6).
44 Removed: (MFTSet reps: 6 rpe: 8).
45 Removed: (MFTSet reps: 6 rpe: 10).
46 Removed: (MFTSet reps: 15 rpe: 4) }).
47 Removed: (MFTExercise shoulderPressDumbell sets: {
48 Removed: (MFTSet reps: 10 rpe: 6).
49 Removed: (MFTSet reps: 6 rpe: 8).
50 Removed: (MFTSet reps: 6 rpe: 10) }).
51 Removed: (MFTExercise declineBenchPress sets: {
52 Removed: (MFTSet reps: 5 rpe: 6).
53 Removed: (MFTSet reps: 6 rpe: 8).
54 Removed: (MFTSet reps: 8 rpe: 10) }) }.
55 Removed: workout2 := MFTWorkout new
56 Removed: date: (Date fromString: '04/20/2023');
57 Removed: exercises: {
58 Removed: (MFTExercise cableRow sets: {
59 Removed: (MFTSet reps: 8 rpe: 6).
60 Removed: (MFTSet reps: 6 rpe: 8).
61 Removed: (MFTSet reps: 6 rpe: 10).
62 Removed: (MFTSet reps: 15 rpe: 4) }).
63 Removed: MFTExercise shoulderPressDumbell.
64 Removed: MFTExercise declineBenchPress }.
65 Removed: workout3 := MFTWorkout new
66 Removed: date: (Date fromString: '01/01/2023');
67 Removed: addExercise: MFTExercise cableRow;
68 Removed: addExercise: MFTExercise shoulderPressDumbell;
69 Removed: addExercise: MFTExercise declineBenchPress.
70 Removed: placeholderWorkouts
71 Removed: add: workout1;
72 Removed: add: workout2;
73 Removed: add: workout3.
74 Removed:
75 Removed: ^ self new
76 Removed: workouts: placeholderWorkouts;
77 Removed: yourself
78 Removed: ]
79 Removed:
80 Removed: { #category : #hooks }
81 Removed: MFTWorkoutsListComponent >> children [
82 Removed:
83 Removed: ^ workouts
84 Removed: ]
85 Removed:
86 Removed: { #category : #initialization }
87 Removed: MFTWorkoutsListComponent >> initialize [
88 Removed:
89 Removed: super initialize.
90 Removed: workouts := OrderedCollection new
91 Removed: ]
92 Removed:
93 Removed: { #category : #rendering }
94 Removed: MFTWorkoutsListComponent >> renderContentOn: html [
95 Removed:
96 Removed: html tbsContainer
97 Removed: class: 'workouts-list';
98 Removed: with: [
99 Removed: html heading
100 Removed: level: 2;
101 Removed: with: 'Workouts'.
102 Removed: workouts do: [ :each | html render: each ] ]
103 Removed: ]
104 Removed:
105 Removed: { #category : #accessing }
106 Removed: MFTWorkoutsListComponent >> workouts: aListOfWorkouts [
107 Removed:
108 Removed: workouts := aListOfWorkouts
109 Removed: ]
src/MyFitnessTracker/MFTWorkoutsListTab.class.st
index 00000000..99c209b2 000000..100644
@@ -0,0 +1,199 @@
1 Added: "
2 Added: I represent the list of user workouts retrieved from the database.
3 Added:
4 Added: I am rendered by `MFTRootComponent` when the user views their workouts. I know about user workouts retrieved from the database.
5 Added:
6 Added: * Collaborators
7 Added:
8 Added: - I work with lists of `MFTWorkout`s.
9 Added: - I might work with `MFTExercise class`canonical exercises once the variable is implemented.
10 Added:
11 Added: Public API and Key Messages
12 Added:
13 Added: - message one
14 Added: - message two
15 Added: - (for bonus points) how to create instances.
16 Added:
17 Added: One simple example is simply gorgeous.
18 Added:
19 Added: Internal Representation and Key Implementation Points.
20 Added:
21 Added:
22 Added: Implementation Points
23 Added: "
24 Added: Class {
25 Added: #name : #MFTWorkoutsListTab,
26 Added: #superclass : #MFTTab,
27 Added: #instVars : [
28 Added: 'workouts'
29 Added: ],
30 Added: #category : #'MyFitnessTracker-Components'
31 Added: }
32 Added:
33 Added: { #category : #rendering }
34 Added: MFTWorkoutsListTab class >> placeholder [
35 Added: "Return a placeholder list of three workouts."
36 Added:
37 Added: | placeholderWorkouts workout1 workout2 workout3 |
38 Added: placeholderWorkouts := OrderedCollection new.
39 Added: workout1 := MFTWorkout new
40 Added: primaryMuscle: MFTMuscleGroup chest;
41 Added: exercises: (OrderedCollection
42 Added: with: (MFTExercise cableRow sets: {
43 Added: (MFTSet reps: 8 rpe: 6).
44 Added: (MFTSet reps: 6 rpe: 8).
45 Added: (MFTSet reps: 6 rpe: 10).
46 Added: (MFTSet reps: 15 rpe: 4) })
47 Added: with: (MFTExercise shoulderPressDumbell sets: {
48 Added: (MFTSet reps: 10 rpe: 6).
49 Added: (MFTSet reps: 6 rpe: 8).
50 Added: (MFTSet reps: 6 rpe: 10) })
51 Added: with: (MFTExercise declineBenchPress sets: {
52 Added: (MFTSet reps: 5 rpe: 6).
53 Added: (MFTSet reps: 6 rpe: 8).
54 Added: (MFTSet reps: 8 rpe: 10) })).
55 Added: workout2 := MFTWorkout new
56 Added: date: (Date fromString: '04/20/2023');
57 Added: exercises: (OrderedCollection
58 Added: with: (MFTExercise cableRow sets: {
59 Added: (MFTSet reps: 8 rpe: 6).
60 Added: (MFTSet reps: 6 rpe: 8).
61 Added: (MFTSet reps: 6 rpe: 10).
62 Added: (MFTSet reps: 15 rpe: 4) })
63 Added: with: MFTExercise shoulderPressDumbell
64 Added: with: MFTExercise declineBenchPress).
65 Added: workout3 := MFTWorkout new
66 Added: date: (Date fromString: '01/01/2023');
67 Added: addExercise: MFTExercise cableRow;
68 Added: addExercise: MFTExercise shoulderPressDumbell;
69 Added: addExercise: MFTExercise declineBenchPress.
70 Added: placeholderWorkouts
71 Added: add: workout1;
72 Added: add: workout2;
73 Added: add: workout3.
74 Added:
75 Added: ^ self new
76 Added: workouts: placeholderWorkouts;
77 Added: yourself
78 Added: ]
79 Added:
80 Added: { #category : #adding }
81 Added: MFTWorkoutsListTab >> addWorkout [
82 Added:
83 Added: | newWorkout |
84 Added: newWorkout := self call: MFTWorkoutDialog new.
85 Added: newWorkout ifNotNil: [ workouts addFirst: newWorkout ]
86 Added: ]
87 Added:
88 Added: { #category : #hooks }
89 Added: MFTWorkoutsListTab >> children [
90 Added:
91 Added: ^ workouts
92 Added: ]
93 Added:
94 Added: { #category : #accessing }
95 Added: MFTWorkoutsListTab >> confirmDeleteAt: i [
96 Added:
97 Added: | workout confirmed |
98 Added: workout := workouts at: i.
99 Added: confirmed := self call: (MFTConfirmDialog delete: workout).
100 Added: confirmed ifTrue: [ workouts removeAt: i ]
101 Added: ]
102 Added:
103 Added: { #category : #'as yet unclassified' }
104 Added: MFTWorkoutsListTab >> editWorkoutAt: i [
105 Added:
106 Added: | oldWorkout newWorkout |
107 Added: oldWorkout := workouts at: i.
108 Added: newWorkout := self call: (MFTWorkoutDialog edit: oldWorkout).
109 Added: newWorkout ifNotNil: [ workouts at: i put: newWorkout ]
110 Added: ]
111 Added:
112 Added: { #category : #initialization }
113 Added: MFTWorkoutsListTab >> initialize [
114 Added:
115 Added: super initialize.
116 Added: title := 'Workouts'.
117 Added: workouts := OrderedCollection new
118 Added: ]
119 Added:
120 Added: { #category : #'as yet unclassified' }
121 Added: MFTWorkoutsListTab >> randomWittyCTA [
122 Added:
123 Added: | listOfStrings randomString |
124 Added: listOfStrings := #( 'First time?' 'Get your sweat on!'
125 Added: 'Go go go!' 'Go get ''em, Tiger!' ).
126 Added: randomString := listOfStrings atRandom.
127 Added: ^ randomString
128 Added: ]
129 Added:
130 Added: { #category : #rendering }
131 Added: MFTWorkoutsListTab >> renderActionsButtonGroup: html [
132 Added:
133 Added: html form: [
134 Added: html buttonGroup: [
135 Added: html formButton
136 Added: bePrimary;
137 Added: callback: [ self addWorkout ];
138 Added: with: 'Add workout' ] ]
139 Added: ]
140 Added:
141 Added: { #category : #rendering }
142 Added: MFTWorkoutsListTab >> renderContentOn: html [
143 Added:
144 Added: workouts sort: [ :a :b | a date > b date ].
145 Added: html container: [
146 Added: workouts ifEmpty: [
147 Added: html jumbotron: [ html heading: self randomWittyCTA ] ].
148 Added: self renderActionsButtonGroup: html.
149 Added: html break.
150 Added: self renderWorkoutsAsAccordionOn: html ]
151 Added: ]
152 Added:
153 Added: { #category : #rendering }
154 Added: MFTWorkoutsListTab >> renderWorkoutActionsButtonGroup: html at: i [
155 Added:
156 Added: html form: [
157 Added: html buttonGroup: [
158 Added: html formButton
159 Added: bePrimary;
160 Added: callback: [ self editWorkoutAt: i ];
161 Added: with: 'Edit'.
162 Added: html formButton
163 Added: beDanger;
164 Added: callback: [ self confirmDeleteAt: i ];
165 Added: with: 'Delete' ] ]
166 Added: ]
167 Added:
168 Added: { #category : #rendering }
169 Added: MFTWorkoutsListTab >> renderWorkoutsAsAccordionOn: html [
170 Added:
171 Added: html accordion
172 Added: id: 'accordion';
173 Added: with: [
174 Added: workouts doWithIndex: [ :workout :i |
175 Added: html accordionItem: [
176 Added: html accordionHeading: [
177 Added: html accordionButton
178 Added: dataToggle: 'collapse';
179 Added: dataTarget: '#collapse' , i asString;
180 Added: with:
181 Added: workout date yyyymmdd , (workout primaryMuscle nameEnglish
182 Added: ifNotEmpty: [
183 Added: ' | ' , workout primaryMuscle name asString ]
184 Added: ifEmpty: [ '' ]) ].
185 Added: html accordionCollapse
186 Added: id: 'collapse' , i asString;
187 Added: class: 'collapse';
188 Added: dataAttributeAt: 'bs-parent' put: '#accordion';
189 Added: with: [
190 Added: html accordionBody with: [
191 Added: html render: workout.
192 Added: self renderWorkoutActionsButtonGroup: html at: i ] ] ] ] ]
193 Added: ]
194 Added:
195 Added: { #category : #accessing }
196 Added: MFTWorkoutsListTab >> workouts: aListOfWorkouts [
197 Added:
198 Added: workouts := aListOfWorkouts
199 Added: ]