Class { #name : 'MFTSetGroupLogEditorComponent', #superclass : 'WAComponent', #instVars : [ 'setGroupLog' ], #category : 'MyFitnessTracker-Web-Components', #package : 'MyFitnessTracker-Web', #tag : 'Components' } { #category : 'as yet unclassified' } MFTSetGroupLogEditorComponent class >> forSetGroupLog: aMFTSetGroupLog [ ^ self new setGroupLog: aMFTSetGroupLog; yourself ] { #category : 'rendering' } MFTSetGroupLogEditorComponent >> renderContentOn: html [ html heading level: 3; with: setGroupLog prescription canonicalName capitalized. html form: [ setGroupLog setsGroupedByExercise keysAndValuesDo: [ :exercise :sets | self renderOn: html exercise: exercise sets: sets ]. self renderFormActionsOn: html ] ] { #category : 'rendering' } MFTSetGroupLogEditorComponent >> renderFormActionsOn: html [ html fieldSet class: 'grid'; with: [ html button callback: [ self answer: setGroupLog ]; with: 'Save'. html button class: 'secondary'; callback: [ setGroupLog := MFTSetGroupLog forPrescription: setGroupLog prescription ]; with: 'Reset' ] ] { #category : 'rendering' } MFTSetGroupLogEditorComponent >> renderOn: html exercise: exercise sets: sets [ html div: [ html heading level: 4; with: exercise canonicalName capitalized. html div class: 'grid'; with: [ html button class: 'outline'; callback: [ setGroupLog addSet: (MFTSetLog forPrescription: sets last prescription) before: sets first ]; with: 'Add set'. html button class: 'outline secondary'; callback: [ | alternativeExercises selectedExercise | alternativeExercises := setGroupLog prescription alternativeExercisesFor: exercise. selectedExercise := self call: ((MFTExerciseSelectorComponent forExercises: alternativeExercises) selectedExercise: exercise). selectedExercise ifNotNil: [ "TODO" setGroupLog ] ]; with: 'Substitute exercise' ]. self renderTableOn: html forSets: sets ] ] { #category : 'rendering' } MFTSetGroupLogEditorComponent >> renderTableOn: html forSets: sets [ html table: [ html tableHead: [ html tableRow: [ html tableHeading; tableHeading: 'Reps'; tableHeading: 'Load'; tableHeading: 'Failure' ] ]; tableBody: [ sets doWithIndex: [ :setLog :setLogIdx | html tableRow: [ html tableData: setLogIdx; tableData: [ html numberInput placeholder: setLog prescription repScheme; callback: [ :value | value ifNotEmpty: [ setLog reps: value asNumber ] ]; value: setLog reps ]; tableData: [ html numberInput callback: [ :value | value ifNotEmpty: [ setLog load: value asNumber ] ]; value: setLog load ]; tableData: [ html button class: 'outline'; callback: [ ]; value: setLog failureAchieved ] ] ] ] ] ] { #category : 'accessing' } MFTSetGroupLogEditorComponent >> setGroupLog: aMFTSetGroupLog [ setGroupLog := aMFTSetGroupLog ]