View raw

1 Class { 2 #name : 'MFTPlanPage', 3 #superclass : 'MFTPage', 4 #category : 'MyFitnessTracker-Web-Components', 5 #package : 'MyFitnessTracker-Web', 6 #tag : 'Components' 7 } 8 9 { #category : 'rendering' } 10 MFTPlanPage >> renderContentOn: html [ 11 12 self 13 renderCurrentRoutineInfoOn: html; 14 renderMyRoutinesOn: html; 15 renderMyWorkoutsOn: html 16 ] 17 18 { #category : 'rendering' } 19 MFTPlanPage >> renderCurrentRoutineInfoOn: html [ 20 21 | routine | 22 routine := self session user trainee currentRoutine. 23 24 html heading: 'Current routine'. 25 html definitionList: [ 26 html 27 definitionTerm: 'Routine title'; 28 definitionData: [ 29 html anchor 30 callback: [ 31 self call: (MFTRoutineViewerPage forRoutine: routine) ]; 32 with: routine canonicalName ]. 33 html 34 definitionTerm: 'Workouts'; 35 definitionData: routine workouts size. 36 html 37 definitionTerm: 'Avg. sets per week'; 38 definitionData: (routine averageSetsDuring: 1 week). 39 html 40 definitionTerm: 'Rest between workouts'; 41 definitionData: '48 hours' ] 42 ] 43 44 { #category : 'rendering' } 45 MFTPlanPage >> renderMyRoutinesOn: html [ 46 47 html heading: 'My routines'. 48 html anchor 49 callback: [ 50 | routine | 51 routine := self call: MFTRoutineCreationTask new. 52 routine ifNotNil: [ 53 self session user trainee currentRoutine: routine ] ]; 54 with: 'Create new routine' 55 ] 56 57 { #category : 'rendering' } 58 MFTPlanPage >> renderMyWorkoutsOn: html [ 59 60 html heading: 'My workouts'. 61 html anchor 62 callback: [ 63 | workoutPrescription | 64 workoutPrescription := self call: MFTWorkoutPrescriptionTask new. 65 workoutPrescription ifNotNil: [ 66 self session user trainee currentRoutine addWorkout: 67 workoutPrescription ] ]; 68 with: 'Create new workout'. 69 self session user trainee workoutPrescriptions do: [ ] 70 ] 71 72 { #category : 'accessing' } 73 MFTPlanPage >> title [ 74 75 ^ 'Plan for ' , self session user trainee canonicalName 76 ] 77