From 8568518b57dba05500b63a4e471f8fa65883d10a Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Fri, 21 Nov 2025 22:26:28 +0100 Subject: Add pharo contact book --- .../src/ContactBook/WAContact.class.st | 96 ++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 pharo-mooc/contact-book/src/ContactBook/WAContact.class.st (limited to 'pharo-mooc/contact-book/src/ContactBook/WAContact.class.st') 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 +] -- cgit v1.2.3