blob: 209cbe09b164f92eeb81f83ebcc1cd67d904c150 (
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
Class {
#name : 'WAContactBook',
#superclass : 'SBSRootComponent',
#instVars : [
'contactBook'
],
#category : 'ContactBook',
#package : 'ContactBook'
}
{ #category : 'initialization' }
WAContactBook class >> initialize [
(WAAdmin register: self asApplicationAt: 'contacts')
addLibrary: JQDeploymentLibrary;
addLibrary: SBSDeploymentLibrary
]
{ #category : 'rendering' }
WAContactBook >> addContact [
(self call: WAContact new)
ifNotNil: [ :contact | contactBook addContact: contact ]
]
{ #category : 'accessing' }
WAContactBook >> contactBook [
^ contactBook ifNil: [ contactBook := ContactBook createDefault ]
]
{ #category : 'accessing' }
WAContactBook >> contacts [
^ self contactBook contacts
]
{ #category : 'iterating' }
WAContactBook >> contactsDo: aBlock [
self contacts do: aBlock
]
{ #category : 'rendering' }
WAContactBook >> renderButtonsForContact: aContact on: html [
html buttonGroup: [
self
renderEditButtonForContact: aContact on: html;
renderRemoveButtonForContact: aContact on: html ]
]
{ #category : 'rendering' }
WAContactBook >> renderContact: aContact on: html [
html tableRow: [
html
tableData: aContact fullname;
tableData: aContact email;
tableData: [ self renderPhotoOf: aContact on: html ];
tableData: [ self renderButtonsForContact: aContact on: html ] ]
]
{ #category : 'rendering' }
WAContactBook >> renderContactsOn: html [
html table: [
html tableHead: [
html
tableHeading: 'Name';
tableHeading: 'Email';
tableHeading: 'Photo' ].
self contactsDo: [ :contact | self renderContact: contact on: html ] ]
]
{ #category : 'rendering' }
WAContactBook >> renderContentOn: html [
"Main entry point of the view. Render both a title and the list of contacts."
html
container: [
html heading
level: 1;
with: 'My Contact Book'.
html form: [
self renderContactsOn: html.
self renderGlobalButtonsOn: html ] ]
]
{ #category : 'rendering' }
WAContactBook >> renderEditButtonForContact: aContact on: html [
html outlineButton
beSuccess;
callback: [ self call: (WAContact editContact: aContact) ];
with: 'Edit'
]
{ #category : 'rendering' }
WAContactBook >> renderGlobalButtonsOn: html [
html buttonGroup: [
html outlineButton
beSuccess;
callback: [ self addContact ];
with: 'New contact' ]
]
{ #category : 'rendering' }
WAContactBook >> renderPhotoOf: aContact on: html [
html image url: aContact gravatarUrl
]
{ #category : 'rendering' }
WAContactBook >> renderRemoveButtonForContact: aContact on: html [
html outlineButton
beDanger;
callback: [ self contactBook removeContact: aContact ];
with: 'Remove'
]
{ #category : 'updating' }
WAContactBook >> updateRoot: anHtmlRoot [
super updateRoot: anHtmlRoot.
anHtmlRoot title: 'Contact Book'
]
|