[Pharo] Personal fitness tracker web app.
Weights and Workouts List pages.
Changed files
src/MyFitnessTracker/MFTWeightsListPage.class.st
@@ -1,6 +1,9 @@
1
1
Class {
2
2
#name : #MFTWeightsListPage,
3
3
#superclass : #MFTPage,
4
Added:
#instVars : [
5
Added:
'weights'
6
Added:
],
4
7
#category : #'MyFitnessTracker-Components'
5
8
}
6
9
@@ -21,21 +24,25 @@
21
24
22
25
| newWeight |
23
26
newWeight := self call: MFTWeightDialog new.
24
Removed:
newWeight ifNotNil: [ self session user weights addLast: newWeight ]
27
Added:
(newWeight isNotNil and: [ (newWeight value = 0) not ]) ifTrue: [
28
Added:
self session user weights add: newWeight ]
25
29
]
26
30
27
31
{ #category : #accessing }
28
32
MFTWeightsListPage >> editWeightAt: i [
29
33
30
Removed:
self call: (MFTWeightDialog edit: (self session user weights at: i))
34
Added:
| oldWeight newWeight |
35
Added:
oldWeight := weights at: i.
36
Added:
newWeight := self call: (MFTWeightDialog edit: oldWeight).
37
Added:
(newWeight value isNotNil and: [ (newWeight value = 0) not ])
38
Added:
ifTrue: [ self session user workouts at: i put: newWeight ]
31
39
]
32
40
33
41
{ #category : #initialization }
34
42
MFTWeightsListPage >> initialize [
35
43
36
44
super initialize.
37
Removed:
title := 'weights'.
38
Removed:
45
Added:
title := 'weights'
39
46
]
40
47
41
48
{ #category : #'as yet unclassified' }
@@ -79,15 +86,12 @@
79
86
{ #category : #rendering }
80
87
MFTWeightsListPage >> renderContentOn: html [
81
88
82
Removed:
| weights |
83
Removed:
weights := self session user weights.
84
Removed:
weights sort: [ :a :b | a date > b date ].
85
Removed:
89
Added:
weights := self session user weights sort: [ :a :b | a date > b date ].
86
90
self renderPageOn: html with: [
87
91
weights ifEmpty: [
88
92
html jumbotron: [ html heading: self randomWittyCTA ] ].
89
93
self renderActionsButtonGroupOn: html.
90
Removed:
self renderWeightsAsTableOn: html ]
94
Added:
weights ifNotEmpty: [ self renderWeightsAsTableOn: html ] ]
91
95
]
92
96
93
97
{ #category : #rendering }
@@ -120,11 +124,11 @@
120
124
tableHeading;
121
125
tableHeading: 'Date';
122
126
tableHeading: 'Value' ].
123
Removed:
self session user weights doWithIndex: [ :weight :i |
127
Added:
weights doWithIndex: [ :weight :i |
124
128
html tableRow: [
125
129
html tableData: [
126
130
self renderWeightActionsButtonGroupOn: html at: i ].
127
Removed:
html tableData: weight date.
131
Added:
html tableData: weight date yyyymmdd.
128
132
html tableData: weight value ] ] ]
129
133
]
130
134
src/MyFitnessTracker/MFTWorkoutsListPage.class.st
@@ -24,6 +24,9 @@
24
24
Class {
25
25
#name : #MFTWorkoutsListPage,
26
26
#superclass : #MFTPage,
27
Added:
#instVars : [
28
Added:
'workouts'
29
Added:
],
27
30
#category : #'MyFitnessTracker-Components'
28
31
}
29
32
@@ -36,6 +39,7 @@
36
39
workout1 := MFTWorkout new
37
40
date: (Date fromString: '01/03/2023');
38
41
primaryMuscle: MFTMuscleGroup chest;
42
Added:
secondaryMuscles: { MFTMuscle tricepsBrachii };
39
43
exercises: (OrderedCollection
40
44
with: (MFTExercise cableRow sets: {
41
45
(MFTSet reps: 8 rpe: 6).
@@ -75,14 +79,6 @@
75
79
yourself
76
80
]
77
81
78
Removed:
{ #category : #adding }
79
Removed:
MFTWorkoutsListPage >> addWorkout [
80
Removed:
81
Removed:
| newWorkout |
82
Removed:
newWorkout := self call: MFTWorkoutDialog new.
83
Removed:
newWorkout ifNotNil: [ self session user workouts add: newWorkout ]
84
Removed:
]
85
Removed:
86
82
{ #category : #hooks }
87
83
MFTWorkoutsListPage >> children [
88
84
@@ -92,18 +88,18 @@
92
88
{ #category : #accessing }
93
89
MFTWorkoutsListPage >> confirmDeleteAt: i [
94
90
95
Removed:
| workout confirmed |
91
Added:
| workout |
96
92
workout := self session user workouts at: i.
97
Removed:
confirmed := self call: (MFTConfirmDialog delete: workout).
98
Removed:
confirmed ifTrue: [ self session user workouts removeAt: i ]
93
Added:
(self call: (MFTConfirmDialog delete: workout)) ifTrue: [
94
Added:
self session user workouts removeAt: i ]
99
95
]
100
96
101
97
{ #category : #'as yet unclassified' }
102
98
MFTWorkoutsListPage >> editWorkoutAt: i [
103
99
104
100
| oldWorkout newWorkout |
105
Removed:
oldWorkout := self session user workouts at: i.
106
Removed:
newWorkout := self call: (MFTWorkoutDialog edit: oldWorkout).
101
Added:
oldWorkout := workouts at: i.
102
Added:
newWorkout := self call: (MFTWorkoutTask edit: oldWorkout).
107
103
newWorkout ifNotNil: [
108
104
self session user workouts at: i put: newWorkout ]
109
105
]
@@ -113,7 +109,7 @@
113
109
114
110
super initialize.
115
111
title := 'workouts'.
116
Removed:
112
Added:
workouts := OrderedCollection new
117
113
]
118
114
119
115
{ #category : #'as yet unclassified' }
@@ -140,7 +136,7 @@
140
136
html buttonGroup: [
141
137
html formButton
142
138
bePrimary;
143
Removed:
callback: [ self addWorkout ];
139
Added:
callback: [ self call: MFTWorkoutTask new ];
144
140
with: 'Log workout'.
145
141
html formButton
146
142
beSecondary;
@@ -151,15 +147,13 @@
151
147
{ #category : #rendering }
152
148
MFTWorkoutsListPage >> renderContentOn: html [
153
149
154
Removed:
| workouts |
155
Removed:
workouts := self session user workouts.
156
Removed:
workouts sort: [ :a :b | a date > b date ].
157
Removed:
150
Added:
workouts := self session user workouts sort: [ :a :b |
151
Added:
a date > b date ].
158
152
self renderPageOn: html with: [
159
153
workouts ifEmpty: [
160
154
html jumbotron: [ html heading: self randomWittyCTA ] ].
161
155
self renderActionsButtonGroupOn: html.
162
Removed:
self renderWorkoutsAsAccordionOn: html ]
156
Added:
workouts ifNotEmpty: [ self renderWorkoutsAsAccordionOn: html ] ]
163
157
]
164
158
165
159
{ #category : #rendering }
@@ -182,22 +176,22 @@
182
176
183
177
html accordion
184
178
id: 'accordion';
185
Removed:
class: 'mt-3';
179
Added:
class: 'my-3';
186
180
with: [
187
Removed:
self session user workouts doWithIndex: [ :workout :i |
181
Added:
workouts doWithIndex: [ :workout :i |
188
182
html accordionItem: [
189
183
html accordionHeading: [
190
184
html accordionButton
191
185
dataToggle: 'collapse';
192
186
dataTarget: '#collapse' , i asString;
193
187
with: [
194
Removed:
html
195
Removed:
text:
196
Removed:
workout date yyyymmdd , ' ('
197
Removed:
, workout date dayOfWeekName asString , ')';
198
Removed:
space.
188
Added:
html text:
189
Added:
workout date yyyymmdd , ', ' , workout date dayOfWeekName.
199
190
workout primaryMuscle englishName ifNotEmpty: [
200
Removed:
html strong: workout primaryMuscle englishName ] ] ].
191
Added:
html
192
Added:
text: ':';
193
Added:
space;
194
Added:
emphasis: workout primaryMuscle englishName ] ] ].
201
195
html accordionCollapse
202
196
id: 'collapse' , i asString;
203
197
class: 'collapse';