aboutsummaryrefslogtreecommitdiff
path: root/pharo-mooc/contact-book/src/ContactBook/WAContact.class.st
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2025-11-21 22:26:28 +0100
committerEugen Wissner <belka@caraus.de>2025-11-21 22:26:28 +0100
commit8568518b57dba05500b63a4e471f8fa65883d10a (patch)
tree59681b400bccd6fd1299b3c22443c2ddf6f1b378 /pharo-mooc/contact-book/src/ContactBook/WAContact.class.st
parentc03c9f8b886c0e8eca5a701c0ca941e05e0b6285 (diff)
downloadbook-exercises-8568518b57dba05500b63a4e471f8fa65883d10a.tar.gz
Add pharo contact book
Diffstat (limited to 'pharo-mooc/contact-book/src/ContactBook/WAContact.class.st')
-rw-r--r--pharo-mooc/contact-book/src/ContactBook/WAContact.class.st96
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
+]