View raw

1 Class { 2 #name : 'MFTPlanEditorPage', 3 #superclass : 'MFTPage', 4 #instVars : [ 5 'routine', 6 'tmp' 7 ], 8 #category : 'MyFitnessTracker-Web-Components', 9 #package : 'MyFitnessTracker-Web', 10 #tag : 'Components' 11 } 12 13 { #category : 'as yet unclassified' } 14 MFTPlanEditorPage class >> forRoutine: aMFTRoutine [ 15 16 ^ self new 17 routine: aMFTRoutine; 18 yourself 19 ] 20 21 { #category : 'rendering' } 22 MFTPlanEditorPage >> renderContentOn: html [ 23 24 html heading 25 level: 1; 26 with: 'Edit routine'. 27 html form: [ 28 html heading: tmp. 29 html button 30 callback: [ tmp := self request: 'Change the title' ]; 31 with: 'foo'. 32 html textInput 33 value: routine title; 34 placeholder: 'Routine title'; 35 callback: [ :value | routine title: value ]. 36 html horizontalRule. 37 routine workouts do: [ :workoutPrescription | 38 self renderWorkoutPrescription: workoutPrescription on: html. 39 html horizontalRule ]. 40 html button 41 class: 'outline'; 42 callback: [ routine addWorkout: MFTWorkoutPrescription new ]; 43 with: 'Add workout'. 44 html div 45 class: 'grid'; 46 with: [ 47 html submitButton 48 callback: [ self answer: routine ]; 49 with: 'Save plan'. 50 html submitButton 51 class: 'secondary'; 52 callback: [ self answer ]; 53 with: 'Cancel' ] ] 54 ] 55 56 { #category : 'rendering' } 57 MFTPlanEditorPage >> renderWorkoutPrescription: aMFTWorkoutPrescription on: html [ 58 59 html div: [ 60 html fieldSet 61 attributeAt: 'role' put: 'group'; 62 with: [ 63 html textInput 64 value: aMFTWorkoutPrescription title; 65 placeholder: 'New workout title'; 66 callback: [ :value | 67 aMFTWorkoutPrescription title: value asString ]; 68 with: aMFTWorkoutPrescription canonicalName. 69 html button 70 class: 'outline'; 71 callback: [ routine removeWorkout: aMFTWorkoutPrescription ]; 72 with: 'Delete' ]. 73 aMFTWorkoutPrescription setGroups do: [ :setGroupPrescription | 74 html div 75 class: 'grid'; 76 with: [ 77 html heading 78 level: 3; 79 with: setGroupPrescription canonicalName. 80 html button 81 class: 'outline'; 82 callback: [ 83 aMFTWorkoutPrescription removeSetGroup: setGroupPrescription ]; 84 with: 'Delete' ] ]. 85 html div 86 class: 'grid'; 87 with: [ 88 html button 89 class: 'outline'; 90 callback: [ 91 aMFTWorkoutPrescription addSetGroup: 92 MFTStraightSetGroupPrescription new ]; 93 with: 'Add straight set'. 94 html button 95 class: 'outline'; 96 callback: [ 97 aMFTWorkoutPrescription addSetGroup: 98 MFTSupersetGroupPrescription new ]; 99 with: 'Add superset' ] ] 100 ] 101 102 { #category : 'accessing' } 103 MFTPlanEditorPage >> routine: aMFTRoutine [ 104 105 routine := aMFTRoutine 106 ] 107 108 { #category : 'accessing' } 109 MFTPlanEditorPage >> title [ 110 111 ^ 'Edit plan' 112 ] 113