diff options
Diffstat (limited to 'pharo-mooc/contact-book/src/ContactBook/WAContact.class.st')
| -rw-r--r-- | pharo-mooc/contact-book/src/ContactBook/WAContact.class.st | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/pharo-mooc/contact-book/src/ContactBook/WAContact.class.st b/pharo-mooc/contact-book/src/ContactBook/WAContact.class.st new file mode 100644 index 0000000..21eb575 --- /dev/null +++ b/pharo-mooc/contact-book/src/ContactBook/WAContact.class.st @@ -0,0 +1,96 @@ +Class { + #name : 'WAContact', + #superclass : 'SBSRootComponent', + #instVars : [ + 'contact' + ], + #category : 'ContactBook', + #package : 'ContactBook' +} + +{ #category : 'as yet unclassified' } +WAContact class >> editContact: aContact [ + ^ self new + setContact: aContact; + yourself +] + +{ #category : 'initialization' } +WAContact >> contact [ + ^ contact +] + +{ #category : 'initialization' } +WAContact >> initialize [ + super initialize. + contact := Contact new +] + +{ #category : 'as yet unclassified' } +WAContact >> renderButtonsOn: html [ + html formGroup: [ + html buttonGroup: [ + self + renderSubmitButtonOn: html; + renderCancelButtonOn: html ] ] +] + +{ #category : 'as yet unclassified' } +WAContact >> renderCancelButtonOn: html [ + html outlineButton + beDanger; + cancelCallback: [ self answer: nil ]; + with: 'Cancel' +] + +{ #category : 'as yet unclassified' } +WAContact >> renderContentOn: html [ + html container: [ + html heading with: 'Contact Editing'. + html form with: [ + self renderFieldsOn: html. + self renderButtonsOn: html ] ] +] + +{ #category : 'as yet unclassified' } +WAContact >> renderEmailFieldOn: html [ + html formGroup: [ + html label: 'Email'. + html emailInput + formControl; + placeholder: 'your@email.eu'; + callback: [ :value | self contact email: value address ]; + value: (self contact email ifNil: '') ] +] + +{ #category : 'as yet unclassified' } +WAContact >> renderFieldsOn: html [ + self renderFullnameFieldOn: html. + self renderEmailFieldOn: html +] + +{ #category : 'as yet unclassified' } +WAContact >> renderFullnameFieldOn: html [ + html formGroup: [ + html label: 'Fullname'. + html textInput + formControl; + placeholder: 'fullname'; + callback: [ :value | self contact fullname: value ]; + value: (self contact fullname ifNil: '') ] +] + +{ #category : 'as yet unclassified' } +WAContact >> renderSubmitButtonOn: html [ + html formButton + beSubmit; + beSuccess; + bePrimary; + callback: [ self answer: self contact ]; + with: 'Save' +] + +{ #category : 'initialization' } +WAContact >> setContact: aContact [ + contact := aContact +] |
