summaryrefslogtreecommitdiff
path: root/pharo-mooc/contact-book/src/ContactBook/WAContact.class.st
blob: 21eb575fa8f72f042b2dbe66b253b08ec7925243 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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
]