Properly render optional form component affordances.

Commit
65ce44adc5c38fe15b2b4ffccbe1eb8b46044232
Author
Marius Peter <marius.peter@tutanota.com>
Author date
Committer
Marius Peter <marius.peter@tutanota.com>
Committer date
src/MyFitnessTracker/MFTFormComponent.class.st
index afc0479d..482eafe6 100644..100644
@@ -7,7 +7,8 @@
7 7 #instVars : [
8 8 'heading',
9 9 'modelObject',
10 Removed: 'isOptional'
10 Added: 'isOptional',
11 Added: 'displayOptional'
11 12 ],
12 13 #category : 'MyFitnessTracker-Forms',
13 14 #package : 'MyFitnessTracker',
@@ -73,7 +74,8 @@
73 74 MFTFormComponent >> initialize [
74 75
75 76 super initialize.
76 Removed: isOptional := false
77 Added: isOptional := false.
78 Added: displayOptional := false
77 79 ]
78 80
79 81 { #category : 'accessing' }
@@ -88,6 +90,12 @@
88 90 modelObject := anObject
89 91 ]
90 92
93 Added: { #category : 'rendering' }
94 Added: MFTFormComponent >> renderContentOn: html [
95 Added:
96 Added: self renderFormComponentOn: html with: [ html render: modelObject ]
97 Added: ]
98 Added:
91 99 { #category : 'as yet unclassified' }
92 100 MFTFormComponent >> renderFormComponentOn: html with: aBlock [
93 101
@@ -96,8 +104,21 @@
96 104 with: [
97 105 html paragraph
98 106 heading: 3;
99 Removed: with: [
100 Removed: html text: heading.
101 Removed: isOptional ifTrue: [ html small textMuted with: ' (optional)' ] ].
102 Removed: aBlock value ]
107 Added: with: [ html text: heading ].
108 Added: isOptional
109 Added: ifFalse: [ aBlock value ]
110 Added: ifTrue: [ self renderOptionalOn: html with: aBlock ] ]
111 Added: ]
112 Added:
113 Added: { #category : 'rendering' }
114 Added: MFTFormComponent >> renderOptionalOn: html with: aBlock [
115 Added:
116 Added: displayOptional
117 Added: ifFalse: [
118 Added: html outlineButton
119 Added: beSecondary;
120 Added: beSmall;
121 Added: callback: [ displayOptional := true ];
122 Added: with: 'Add' ]
123 Added: ifTrue: [ aBlock value ]
103 124 ]