Optional form components.

Commit
568d63e0aebc024e0941fd8f95a797c35779d5c0
Author
Marius Peter <marius.peter@tutanota.com>
Author date
Committer
Marius Peter <marius.peter@tutanota.com>
Committer date
src/MyFitnessTracker/MFTFormComponent.class.st
index 964168de..f1bb0771 100644..100644
@@ -1,9 +1,13 @@
1 Added: "
2 Added: When instantiated with the `MFTFormComponent class>>#set:` message, I return an instance of the appropriate subclass for setting the model object attribute.
3 Added: "
1 4 Class {
2 5 #name : 'MFTFormComponent',
3 6 #superclass : 'SBSComponent',
4 7 #instVars : [
5 8 'heading',
6 Removed: 'modelObject'
9 Added: 'modelObject',
10 Added: 'isOptional'
7 11 ],
8 12 #category : 'MyFitnessTracker-Forms',
9 13 #package : 'MyFitnessTracker',
@@ -36,7 +40,39 @@
36 40 thisContext sender receiver modelObject
37 41 ]
38 42
43 Added: { #category : 'initialization' }
44 Added: MFTFormComponent >> beMandatory [
45 Added:
46 Added: isOptional := false
47 Added: ]
48 Added:
49 Added: { #category : 'initialization' }
50 Added: MFTFormComponent >> beOptional [
51 Added:
52 Added: isOptional := true
53 Added:
54 Added: ]
55 Added:
39 56 { #category : 'accessing' }
57 Added: MFTFormComponent >> heading [
58 Added:
59 Added: ^ heading
60 Added: ]
61 Added:
62 Added: { #category : 'accessing' }
63 Added: MFTFormComponent >> heading: anObject [
64 Added:
65 Added: heading := anObject
66 Added: ]
67 Added:
68 Added: { #category : 'initialization' }
69 Added: MFTFormComponent >> initialize [
70 Added:
71 Added: super initialize.
72 Added: isOptional := false
73 Added: ]
74 Added:
75 Added: { #category : 'accessing' }
40 76 MFTFormComponent >> modelObject [
41 77
42 78 ^ modelObject
@@ -54,6 +90,10 @@
54 90 html formGroup
55 91 class: 'my-4';
56 92 with: [
57 Removed: html heading level3 with: heading.
93 Added: html paragraph
94 Added: heading: 3;
95 Added: with: [
96 Added: html text: heading.
97 Added: isOptional ifTrue: [ html small textMuted with: ' (optional)' ] ].
58 98 aBlock value ]
59 99 ]