Fix workout status badge.

Commit
60384604aab95c6607527faa93243b0c91807171
Author
Marius Peter <marius.peter@tutanota.com>
Author date
Committer
Marius Peter <marius.peter@tutanota.com>
Committer date
Changed files
src/MyFitnessTracker-Components/MFTWorkoutComponent.class.st
index 34f347e0..88f953b3 100644..100644
@@ -28,6 +28,9 @@
28 28 html
29 29 definitionTerm: 'Date Planned';
30 30 definitionData: workout datePlanned.
31 Added: html
32 Added: definitionTerm: 'Date Completed';
33 Added: definitionData: workout dateCompleted.
31 34 workout primaryMuscleGroup ifNotNil: [
32 35 html
33 36 definitionTerm: 'Primary Muscle Group';
src/MyFitnessTracker-Components/MFTWorkoutsLog.class.st
index 26006bce..d97c5b93 100644..100644
@@ -78,6 +78,42 @@
78 78 ]
79 79
80 80 { #category : 'rendering' }
81 Added: MFTWorkoutsLog >> renderAccordionItemOn: html for: workout index: i [
82 Added:
83 Added: html accordionItem: [
84 Added: html accordionHeading: [
85 Added: html accordionButton
86 Added: dataToggle: 'collapse';
87 Added: dataTarget: '#collapse' , i asString;
88 Added: with: [
89 Added: html space.
90 Added: workout isCompleted
91 Added: ifTrue: [
92 Added: html badge beSuccess with: 'done'.
93 Added: html space.
94 Added: html text: workout dateCompleted yyyymmdd , ', '
95 Added: , workout dateCompleted dayOfWeekName ]
96 Added: ifFalse: [
97 Added: html badge beWarning with: 'planned'.
98 Added: html space.
99 Added: html text: workout datePlanned yyyymmdd , ', '
100 Added: , workout datePlanned dayOfWeekName ].
101 Added: workout primaryMuscleGroup ifNotNil: [
102 Added: html
103 Added: text: ':';
104 Added: space;
105 Added: emphasis: workout primaryMuscleGroup englishName ] ] ].
106 Added: html accordionCollapse
107 Added: id: 'collapse' , i asString;
108 Added: class: 'collapse';
109 Added: dataAttributeAt: 'bs-parent' put: '#accordion';
110 Added: with: [
111 Added: html accordionBody with: [
112 Added: html render: (MFTWorkoutComponent with: workout).
113 Added: self renderWorkoutActionsButtonGroupOn: html for: workout ] ] ]
114 Added: ]
115 Added:
116 Added: { #category : 'rendering' }
81 117 MFTWorkoutsLog >> renderActionsButtonGroupOn: html [
82 118
83 119 html form: [
@@ -96,7 +132,7 @@
96 132 MFTWorkoutsLog >> renderContentOn: html [
97 133
98 134 workouts := self session user workouts sort: [ :a :b |
99 Removed: a date > b date ].
135 Added: a datePlanned > b datePlanned ].
100 136 self renderLogOn: html with: [
101 137 workouts ifEmpty: [
102 138 html jumbotron: [ html heading: self randomWittyCTA ] ].
@@ -105,7 +141,7 @@
105 141 ]
106 142
107 143 { #category : 'rendering' }
108 Removed: MFTWorkoutsLog >> renderWorkoutActionsButtonGroup: html for: workout [
144 Added: MFTWorkoutsLog >> renderWorkoutActionsButtonGroupOn: html for: workout [
109 145
110 146 html form: [
111 147 html buttonGroup: [
@@ -127,27 +163,7 @@
127 163 class: 'my-3';
128 164 with: [
129 165 workouts doWithIndex: [ :workout :i |
130 Removed: html accordionItem: [
131 Removed: html accordionHeading: [
132 Removed: html accordionButton
133 Removed: dataToggle: 'collapse';
134 Removed: dataTarget: '#collapse' , i asString;
135 Removed: with: [
136 Removed: html text:
137 Removed: workout date yyyymmdd , ', ' , workout date dayOfWeekName.
138 Removed: workout primaryMuscleGroup ifNotNil: [
139 Removed: html
140 Removed: text: ':';
141 Removed: space;
142 Removed: emphasis: workout primaryMuscleGroup englishName ] ] ].
143 Removed: html accordionCollapse
144 Removed: id: 'collapse' , i asString;
145 Removed: class: 'collapse';
146 Removed: dataAttributeAt: 'bs-parent' put: '#accordion';
147 Removed: with: [
148 Removed: html accordionBody with: [
149 Removed: html render: workout.
150 Removed: self renderWorkoutActionsButtonGroup: html for: workout ] ] ] ] ]
166 Added: self renderAccordionItemOn: html for: workout index: i ] ]
151 167 ]
152 168
153 169 { #category : 'adding' }
src/MyFitnessTracker-Core/MFTWorkout.class.st
index c148f871..4d458d37 100644..100644
@@ -11,7 +11,8 @@
11 11 'secondaryMuscleGroups',
12 12 'plan',
13 13 'datePlanned',
14 Removed: 'dateCompleted'
14 Added: 'dateCompleted',
15 Added: 'isCompleted'
15 16 ],
16 17 #category : 'MyFitnessTracker-Core',
17 18 #package : 'MyFitnessTracker-Core'
@@ -22,7 +23,9 @@
22 23
23 24 | workout1 workout2 workout3 |
24 25 workout1 := self new
26 Added: datePlanned: (Date year: 2024 month: 1 day: 1);
25 27 dateCompleted: (Date year: 2024 month: 1 day: 1);
28 Added: isCompleted: true;
26 29 primaryMuscleGroup: MFTMuscleGroup back;
27 30 setGroups: {
28 31 (MFTSetGroup withSet: (MFTSet new
@@ -39,7 +42,7 @@
39 42 exercise: MFTExercise latPulldown)) }.
40 43
41 44 workout2 := self new
42 Removed: dateCompleted: (Date year: 2024 month: 1 day: 2);
45 Added: datePlanned: (Date year: 2024 month: 1 day: 2);
43 46 primaryMuscleGroup: MFTMuscleGroup legs;
44 47 setGroups: {
45 48 (MFTSetGroup withSets: {
@@ -57,7 +60,7 @@
57 60 exercise: MFTExercise legCurl)) }.
58 61
59 62 workout3 := self new
60 Removed: dateCompleted: (Date year: 2024 month: 1 day: 3);
63 Added: datePlanned: (Date year: 2024 month: 1 day: 3);
61 64 primaryMuscleGroup: MFTMuscleGroup chest;
62 65 addSets: {
63 66 (MFTSet new
@@ -155,7 +158,20 @@
155 158 super initialize.
156 159 datePlanned := Date today.
157 160 setGroups := OrderedCollection new.
158 Removed: secondaryMuscleGroups := OrderedCollection new
161 Added: secondaryMuscleGroups := OrderedCollection new.
162 Added: isCompleted := false
163 Added: ]
164 Added:
165 Added: { #category : 'accessing' }
166 Added: MFTWorkout >> isCompleted [
167 Added:
168 Added: ^ isCompleted
169 Added: ]
170 Added:
171 Added: { #category : 'accessing' }
172 Added: MFTWorkout >> isCompleted: aBoolean [
173 Added:
174 Added: isCompleted := aBoolean
159 175 ]
160 176
161 177 { #category : 'accessing' }
src/MyFitnessTracker-Database/MFTDescriptorSystem.class.st
index a3956ca5..b736b4f2 100644..100644
@@ -99,7 +99,8 @@
99 99 newAttributeNamed: #secondaryMuscleGroups
100 100 collectionOf: MFTMuscleGroup;
101 101 newAttributeNamed: #setGroups collectionOf: MFTSetGroup;
102 Removed: newAttributeNamed: #restAfter type: Float
102 Added: newAttributeNamed: #restAfter type: Float;
103 Added: newAttributeNamed: #isCompleted type: Boolean
103 104 ]
104 105
105 106 { #category : 'class models' }
@@ -195,7 +196,8 @@
195 196 from: #primaryMuscleGroup
196 197 to: ((self tableNamed: 'MUSCLEGROUP') fieldNamed: 'id').
197 198 (aDescriptor newMapping: ManyToManyMapping) attributeName:
198 Removed: #secondaryMuscleGroups
199 Added: #secondaryMuscleGroups.
200 Added: aDescriptor directMappingFor: #isCompleted
199 201 ]
200 202
201 203 { #category : 'tables' }
@@ -281,6 +283,7 @@
281 283 aTable
282 284 createFieldNamed: 'primaryMuscleGroupId'
283 285 type: (platform varChar: 100).
286 Added: aTable createFieldNamed: 'isCompleted' type: platform boolean.
284 287
285 288 aTable
286 289 addForeignKeyFrom: userField