[Pharo] Personal fitness tracker web app.
Update many web components.
Changed files
- src/MyFitnessTracker-Web/MFTHomePage.class.st
- src/MyFitnessTracker-Web/MFTLogBookViewerComponent.class.st
- src/MyFitnessTracker-Web/MFTPage.class.st
- src/MyFitnessTracker-Web/MFTPlanEditorPage.class.st
- src/MyFitnessTracker-Web/MFTPlanPage.class.st
- src/MyFitnessTracker-Web/MFTProfilePage.class.st
- src/MyFitnessTracker-Web/MFTRoutineCreationTask.class.st
- src/MyFitnessTracker-Web/MFTRoutineViewerPage.class.st
- src/MyFitnessTracker-Web/MFTScreenComponent.class.st
- src/MyFitnessTracker-Web/MFTWorkoutLogEditorPage.class.st
- src/MyFitnessTracker-Web/MFTWorkoutPrescriptionTask.class.st
src/MyFitnessTracker-Web/MFTHomePage.class.st
@@ -9,16 +9,15 @@
9
9
{ #category : 'rendering' }
10
10
MFTHomePage >> renderContentOn: html [
11
11
12
Removed:
self renderPageOn: html with: [
13
Removed:
html heading
14
Removed:
level: 1;
15
Removed:
with: self session user trainee routine canonicalName capitalized.
16
Removed:
self
17
Removed:
renderStatusOn: html;
18
Removed:
renderNextWorkoutPrescriptionOn: html;
19
Removed:
renderMainActionsOn: html.
20
Removed:
self session user trainee logBook workoutLogs ifNotEmpty: [
21
Removed:
self renderWorkoutLogBookOn: html ] ]
12
Added:
html heading
13
Added:
level: 1;
14
Added:
with: self session user trainee currentRoutine canonicalName capitalized.
15
Added:
self
16
Added:
renderStatusOn: html;
17
Added:
renderNextWorkoutPrescriptionOn: html;
18
Added:
renderMainActionsOn: html.
19
Added:
self session user trainee logBook workoutLogs ifNotEmpty: [
20
Added:
self renderWorkoutLogBookOn: html ]
22
21
]
23
22
24
23
{ #category : 'rendering' }
src/MyFitnessTracker-Web/MFTLogBookViewerComponent.class.st
@@ -1,57 +0,0 @@
1
Removed:
Class {
2
Removed:
#name : 'MFTLogBookViewerComponent',
3
Removed:
#superclass : 'WAComponent',
4
Removed:
#instVars : [
5
Removed:
'logBook',
6
Removed:
'logBookItemComponents',
7
Removed:
'heading'
8
Removed:
],
9
Removed:
#category : 'MyFitnessTracker-Web-Components',
10
Removed:
#package : 'MyFitnessTracker-Web',
11
Removed:
#tag : 'Components'
12
Removed:
}
13
Removed:
14
Removed:
{ #category : 'accessing' }
15
Removed:
MFTLogBookViewerComponent class >> forLogBook: aMFTWorkoutLogBook [
16
Removed:
17
Removed:
^ self new logBook: aMFTWorkoutLogBook
18
Removed:
]
19
Removed:
20
Removed:
{ #category : 'rendering' }
21
Removed:
MFTLogBookViewerComponent >> children [
22
Removed:
23
Removed:
^ logBookItemComponents
24
Removed:
]
25
Removed:
26
Removed:
{ #category : 'rendering' }
27
Removed:
MFTLogBookViewerComponent >> heading: aString [
28
Removed:
29
Removed:
heading := aString
30
Removed:
]
31
Removed:
32
Removed:
{ #category : 'rendering' }
33
Removed:
MFTLogBookViewerComponent >> initialize [
34
Removed:
35
Removed:
super initialize.
36
Removed:
logBookItemComponents := OrderedCollection new
37
Removed:
]
38
Removed:
39
Removed:
{ #category : 'accessing' }
40
Removed:
MFTLogBookViewerComponent >> logBook: aMFTWorkoutLogBook [
41
Removed:
42
Removed:
logBook := aMFTWorkoutLogBook.
43
Removed:
]
44
Removed:
45
Removed:
{ #category : 'rendering' }
46
Removed:
MFTLogBookViewerComponent >> renderContentOn: html [
47
Removed:
48
Removed:
logBookItemComponents := logBook workoutLogs collect: [ :each |
49
Removed:
MFTWorkoutLogViewerComponent
50
Removed:
forWorkoutLog: each ].
51
Removed:
52
Removed:
logBook workoutLogs ifNotEmpty: [
53
Removed:
html heading
54
Removed:
level: 2;
55
Removed:
with: heading.
56
Removed:
logBookItemComponents reverseDo: [ :each | html render: each ] ]
57
Removed:
]
src/MyFitnessTracker-Web/MFTPage.class.st
@@ -9,14 +9,6 @@
9
9
#tag : 'Components'
10
10
}
11
11
12
Removed:
{ #category : 'rendering' }
13
Removed:
MFTPage >> renderPageOn: html with: aBlock [
14
Removed:
15
Removed:
html div
16
Removed:
id: 'content';
17
Removed:
with: aBlock
18
Removed:
]
19
Removed:
20
12
{ #category : 'accessing' }
21
13
MFTPage >> title [
22
14
src/MyFitnessTracker-Web/MFTPlanEditorPage.class.st
@@ -2,7 +2,8 @@
2
2
#name : 'MFTPlanEditorPage',
3
3
#superclass : 'MFTPage',
4
4
#instVars : [
5
Removed:
'routine'
5
Added:
'routine',
6
Added:
'tmp'
6
7
],
7
8
#category : 'MyFitnessTracker-Web-Components',
8
9
#package : 'MyFitnessTracker-Web',
@@ -20,24 +21,82 @@
20
21
{ #category : 'rendering' }
21
22
MFTPlanEditorPage >> renderContentOn: html [
22
23
23
Removed:
self renderPageOn: html with: [
24
Removed:
html heading
25
Removed:
level: 1;
26
Removed:
with: 'Edit plan'.
27
Removed:
html heading
28
Removed:
level: 2;
29
Removed:
with: routine canonicalName.
30
Removed:
html form: [
24
Added:
html heading
25
Added:
level: 1;
26
Added:
with: 'Edit routine'.
27
Added:
html form: [
28
Added:
html heading: tmp.
29
Added:
html button
30
Added:
callback: [ tmp := self request: 'Change the title' ];
31
Added:
with: 'foo'.
32
Added:
html textInput
33
Added:
value: routine title;
34
Added:
placeholder: 'Routine title';
35
Added:
callback: [ :value | routine title: value ].
36
Added:
html horizontalRule.
37
Added:
routine workouts do: [ :workoutPrescription |
38
Added:
self renderWorkoutPrescription: workoutPrescription on: html.
39
Added:
html horizontalRule ].
40
Added:
html button
41
Added:
class: 'outline';
42
Added:
callback: [ routine addWorkout: MFTWorkoutPrescription new ];
43
Added:
with: 'Add workout'.
44
Added:
html div
45
Added:
class: 'grid';
46
Added:
with: [
47
Added:
html submitButton
48
Added:
callback: [ self answer: routine ];
49
Added:
with: 'Save plan'.
50
Added:
html submitButton
51
Added:
class: 'secondary';
52
Added:
callback: [ self answer ];
53
Added:
with: 'Cancel' ] ]
54
Added:
]
55
Added:
56
Added:
{ #category : 'rendering' }
57
Added:
MFTPlanEditorPage >> renderWorkoutPrescription: aMFTWorkoutPrescription on: html [
58
Added:
59
Added:
html div: [
60
Added:
html fieldSet
61
Added:
attributeAt: 'role' put: 'group';
62
Added:
with: [
63
Added:
html textInput
64
Added:
value: aMFTWorkoutPrescription title;
65
Added:
placeholder: 'New workout title';
66
Added:
callback: [ :value |
67
Added:
aMFTWorkoutPrescription title: value asString ];
68
Added:
with: aMFTWorkoutPrescription canonicalName.
69
Added:
html button
70
Added:
class: 'outline';
71
Added:
callback: [ routine removeWorkout: aMFTWorkoutPrescription ];
72
Added:
with: 'Delete' ].
73
Added:
aMFTWorkoutPrescription setGroups do: [ :setGroupPrescription |
31
74
html div
32
75
class: 'grid';
33
76
with: [
77
Added:
html heading
78
Added:
level: 3;
79
Added:
with: setGroupPrescription canonicalName.
34
80
html button
35
Removed:
callback: [ self answer: routine ];
36
Removed:
with: 'Save plan'.
37
Removed:
html button
38
Removed:
class: 'secondary';
39
Removed:
callback: [ self answer ];
40
Removed:
with: 'Cancel' ] ] ]
81
Added:
class: 'outline';
82
Added:
callback: [
83
Added:
aMFTWorkoutPrescription removeSetGroup: setGroupPrescription ];
84
Added:
with: 'Delete' ] ].
85
Added:
html div
86
Added:
class: 'grid';
87
Added:
with: [
88
Added:
html button
89
Added:
class: 'outline';
90
Added:
callback: [
91
Added:
aMFTWorkoutPrescription addSetGroup:
92
Added:
MFTStraightSetGroupPrescription new ];
93
Added:
with: 'Add straight set'.
94
Added:
html button
95
Added:
class: 'outline';
96
Added:
callback: [
97
Added:
aMFTWorkoutPrescription addSetGroup:
98
Added:
MFTSupersetGroupPrescription new ];
99
Added:
with: 'Add superset' ] ]
41
100
]
42
101
43
102
{ #category : 'accessing' }
src/MyFitnessTracker-Web/MFTPlanPage.class.st
@@ -9,62 +9,64 @@
9
9
{ #category : 'rendering' }
10
10
MFTPlanPage >> renderContentOn: html [
11
11
12
Removed:
self renderPageOn: html with: [
13
Removed:
html heading: 'Plan'.
14
Removed:
self renderPlanActionsOn: html.
15
Removed:
html heading
16
Removed:
level: 2;
17
Removed:
with: 'Current plan'.
18
Removed:
self
19
Removed:
renderCurrentPlanInfoOn: html;
20
Removed:
renderPlanWorkoutsOn: html ]
12
Added:
self
13
Added:
renderCurrentRoutineInfoOn: html;
14
Added:
renderMyRoutinesOn: html;
15
Added:
renderMyWorkoutsOn: html
21
16
]
22
17
23
18
{ #category : 'rendering' }
24
Removed:
MFTPlanPage >> renderCurrentPlanInfoOn: html [
19
Added:
MFTPlanPage >> renderCurrentRoutineInfoOn: html [
25
20
26
21
| routine |
27
Removed:
routine := self session user trainee routine.
22
Added:
routine := self session user trainee currentRoutine.
28
23
24
Added:
html heading: 'Current routine'.
29
25
html definitionList: [
30
26
html
31
Removed:
definitionTerm: 'Current routine';
32
Removed:
definitionData: routine canonicalName.
27
Added:
definitionTerm: 'Routine title';
28
Added:
definitionData: [
29
Added:
html anchor
30
Added:
callback: [
31
Added:
self call: (MFTRoutineViewerPage forRoutine: routine) ];
32
Added:
with: routine canonicalName ].
33
33
html
34
Added:
definitionTerm: 'Workouts';
35
Added:
definitionData: routine workouts size.
36
Added:
html
37
Added:
definitionTerm: 'Avg. sets per week';
38
Added:
definitionData: (routine averageSetsDuring: 1 week).
39
Added:
html
34
40
definitionTerm: 'Rest between workouts';
35
41
definitionData: '48 hours' ]
36
42
]
37
43
38
44
{ #category : 'rendering' }
39
Removed:
MFTPlanPage >> renderPlanActionsOn: html [
45
Added:
MFTPlanPage >> renderMyRoutinesOn: html [
40
46
41
Removed:
html unorderedList: [
42
Removed:
html
43
Removed:
listItem: [
44
Removed:
html anchor
45
Removed:
callback: [ self ];
46
Removed:
with: 'View current plan' ];
47
Removed:
listItem: [
48
Removed:
html anchor
49
Removed:
callback: [
50
Removed:
self call:
51
Removed:
(MFTPlanEditorPage forRoutine:
52
Removed:
self session user trainee routine) ];
53
Removed:
with: 'Edit plan' ] ]
47
Added:
html heading: 'My routines'.
48
Added:
html anchor
49
Added:
callback: [
50
Added:
| routine |
51
Added:
routine := self call: MFTRoutineCreationTask new.
52
Added:
routine ifNotNil: [
53
Added:
self session user trainee currentRoutine: routine ] ];
54
Added:
with: 'Create new routine'
54
55
]
55
56
56
57
{ #category : 'rendering' }
57
Removed:
MFTPlanPage >> renderPlanWorkoutsOn: html [
58
Added:
MFTPlanPage >> renderMyWorkoutsOn: html [
58
59
59
Removed:
| routine |
60
Removed:
routine := self session user trainee routine.
61
Removed:
62
Removed:
routine workouts do: [ :workoutPrescription |
63
Removed:
html heading
64
Removed:
level: 2;
65
Removed:
with: workoutPrescription canonicalName capitalized.
66
Removed:
html render:
67
Removed:
(MFTWorkoutPrescriptionTable forPrescription: workoutPrescription) ]
60
Added:
html heading: 'My workouts'.
61
Added:
html anchor
62
Added:
callback: [
63
Added:
| workoutPrescription |
64
Added:
workoutPrescription := self call: MFTWorkoutPrescriptionTask new.
65
Added:
workoutPrescription ifNotNil: [
66
Added:
self session user trainee currentRoutine addWorkout:
67
Added:
workoutPrescription ] ];
68
Added:
with: 'Create new workout'.
69
Added:
self session user trainee workoutPrescriptions do: [ ]
68
70
]
69
71
70
72
{ #category : 'accessing' }
src/MyFitnessTracker-Web/MFTProfilePage.class.st
@@ -9,10 +9,9 @@
9
9
{ #category : 'rendering' }
10
10
MFTProfilePage >> renderContentOn: html [
11
11
12
Removed:
self renderPageOn: html with: [
13
Removed:
html heading
14
Removed:
level: 1;
15
Removed:
with: self title ]
12
Added:
html heading
13
Added:
level: 1;
14
Added:
with: self title
16
15
]
17
16
18
17
{ #category : 'accessing' }
src/MyFitnessTracker-Web/MFTRoutineCreationTask.class.st
@@ -0,0 +1,32 @@
1
Added:
Class {
2
Added:
#name : 'MFTRoutineCreationTask',
3
Added:
#superclass : 'WATask',
4
Added:
#instVars : [
5
Added:
'routine'
6
Added:
],
7
Added:
#category : 'MyFitnessTracker-Web',
8
Added:
#package : 'MyFitnessTracker-Web'
9
Added:
}
10
Added:
11
Added:
{ #category : 'as yet unclassified' }
12
Added:
MFTRoutineCreationTask class >> forRoutine: aMFTRoutine [
13
Added:
14
Added:
^ self new
15
Added:
routine: aMFTRoutine;
16
Added:
yourself
17
Added:
]
18
Added:
19
Added:
{ #category : 'running' }
20
Added:
MFTRoutineCreationTask >> go [
21
Added:
22
Added:
routine := MFTRoutine new.
23
Added:
routine title: (self request: 'Routine title' default: routine title).
24
Added:
self confirm: 'Add workout?'.
25
Added:
self answer: routine
26
Added:
]
27
Added:
28
Added:
{ #category : 'accessing' }
29
Added:
MFTRoutineCreationTask >> routine: aMFTRoutine [
30
Added:
31
Added:
routine := aMFTRoutine
32
Added:
]
src/MyFitnessTracker-Web/MFTRoutineViewerPage.class.st
@@ -0,0 +1,72 @@
1
Added:
Class {
2
Added:
#name : 'MFTRoutineViewerPage',
3
Added:
#superclass : 'MFTPage',
4
Added:
#instVars : [
5
Added:
'routine'
6
Added:
],
7
Added:
#category : 'MyFitnessTracker-Web-Components',
8
Added:
#package : 'MyFitnessTracker-Web',
9
Added:
#tag : 'Components'
10
Added:
}
11
Added:
12
Added:
{ #category : 'as yet unclassified' }
13
Added:
MFTRoutineViewerPage class >> forRoutine: aMFTRoutine [
14
Added:
15
Added:
^ self new
16
Added:
routine: aMFTRoutine;
17
Added:
yourself
18
Added:
]
19
Added:
20
Added:
{ #category : 'rendering' }
21
Added:
MFTRoutineViewerPage >> renderActionButtonsOn: html [
22
Added:
23
Added:
html div
24
Added:
class: 'grid';
25
Added:
style: 'margin-bottom: 2rem';
26
Added:
with: [
27
Added:
html anchor
28
Added:
class: 'outline';
29
Added:
attributeAt: 'role' put: 'button';
30
Added:
callback: [ self answer ];
31
Added:
with: 'Return'.
32
Added:
33
Added:
html anchor
34
Added:
class: 'secondary outline';
35
Added:
attributeAt: 'role' put: 'button';
36
Added:
callback: [
37
Added:
routine := (self call:
38
Added:
(MFTRoutineCreationTask forRoutine: routine))
39
Added:
ifNil: [ routine ] ];
40
Added:
with: 'Edit' ]
41
Added:
]
42
Added:
43
Added:
{ #category : 'rendering' }
44
Added:
MFTRoutineViewerPage >> renderContentOn: html [
45
Added:
46
Added:
self renderActionButtonsOn: html.
47
Added:
48
Added:
html heading
49
Added:
level: 1;
50
Added:
with: routine title.
51
Added:
routine workouts do: [ :workoutPrescription |
52
Added:
html details
53
Added:
attributeAt: 'name' put: 'workoutPrescriptions';
54
Added:
with: [
55
Added:
html summary: workoutPrescription title.
56
Added:
html render:
57
Added:
(MFTWorkoutPrescriptionTable forPrescription:
58
Added:
workoutPrescription) ].
59
Added:
html horizontalRule ]
60
Added:
]
61
Added:
62
Added:
{ #category : 'accessing' }
63
Added:
MFTRoutineViewerPage >> routine: aMFTRoutine [
64
Added:
65
Added:
routine := aMFTRoutine
66
Added:
]
67
Added:
68
Added:
{ #category : 'accessing' }
69
Added:
MFTRoutineViewerPage >> title [
70
Added:
71
Added:
^ routine canonicalName
72
Added:
]
src/MyFitnessTracker-Web/MFTScreenComponent.class.st
@@ -56,9 +56,6 @@
56
56
{ #category : 'initialization' }
57
57
MFTScreenComponent >> initializeMainPages [
58
58
59
Removed:
| trainee |
60
Removed:
trainee := self session user trainee.
61
Removed:
62
59
mainPages := OrderedDictionary newFrom: {
63
60
(#home -> MFTHomePage new).
64
61
(#plan -> MFTPlanPage new).
@@ -75,4 +72,15 @@
75
72
MFTScreenComponent >> navbar: aNavbar [
76
73
77
74
navbar := aNavbar
75
Added:
]
76
Added:
77
Added:
{ #category : 'accessing' }
78
Added:
MFTScreenComponent >> renderContentOn: html [
79
Added:
80
Added:
html render: navbar.
81
Added:
html main
82
Added:
class: 'content-fluid';
83
Added:
id: 'content';
84
Added:
with: activePage.
85
Added:
html render: footer
78
86
]
src/MyFitnessTracker-Web/MFTWorkoutLogEditorPage.class.st
@@ -40,15 +40,14 @@
40
40
{ #category : 'rendering' }
41
41
MFTWorkoutLogEditorPage >> renderContentOn: html [
42
42
43
Removed:
self renderPageOn: html with: [
44
Removed:
html heading
45
Removed:
level: 1;
46
Removed:
with: 'Log Workout'.
47
Removed:
html heading
48
Removed:
level: 2;
49
Removed:
with: workoutLog prescription canonicalName.
50
Removed:
html horizontalRule.
51
Removed:
html render: workoutLogEditorComponent ]
43
Added:
html heading
44
Added:
level: 1;
45
Added:
with: 'Log Workout'.
46
Added:
html heading
47
Added:
level: 2;
48
Added:
with: workoutLog prescription canonicalName.
49
Added:
html horizontalRule.
50
Added:
html render: workoutLogEditorComponent
52
51
]
53
52
54
53
{ #category : 'accessing' }
src/MyFitnessTracker-Web/MFTWorkoutPrescriptionTask.class.st
@@ -0,0 +1,38 @@
1
Added:
Class {
2
Added:
#name : 'MFTWorkoutPrescriptionTask',
3
Added:
#superclass : 'WATask',
4
Added:
#instVars : [
5
Added:
'workoutPrescription'
6
Added:
],
7
Added:
#category : 'MyFitnessTracker-Web',
8
Added:
#package : 'MyFitnessTracker-Web'
9
Added:
}
10
Added:
11
Added:
{ #category : 'accessing' }
12
Added:
MFTWorkoutPrescriptionTask class >> forPrescription: aMFTWorkoutPrescription [
13
Added:
14
Added:
^ self new
15
Added:
workoutPrescription: aMFTWorkoutPrescription;
16
Added:
yourself
17
Added:
]
18
Added:
19
Added:
{ #category : 'running' }
20
Added:
MFTWorkoutPrescriptionTask >> go [
21
Added:
22
Added:
workoutPrescription title: (self request: 'Workout title').
23
Added:
" workoutPrescription setGroups: (self )."
24
Added:
self answer: workoutPrescription
25
Added:
]
26
Added:
27
Added:
{ #category : 'running' }
28
Added:
MFTWorkoutPrescriptionTask >> initialize [
29
Added:
30
Added:
super initialize.
31
Added:
workoutPrescription := MFTWorkoutPrescription new
32
Added:
]
33
Added:
34
Added:
{ #category : 'accessing' }
35
Added:
MFTWorkoutPrescriptionTask >> workoutPrescription: aMFTWorkoutPrescription [
36
Added:
37
Added:
workoutPrescription := aMFTWorkoutPrescription
38
Added:
]