Update to bootstrap 4
This commit is contained in:
@@ -3,16 +3,17 @@ I represent a person with a name and an email address. I'm usually
|
||||
part of a contact book.
|
||||
"
|
||||
Class {
|
||||
#name : #Contact,
|
||||
#superclass : #Object,
|
||||
#name : 'Contact',
|
||||
#superclass : 'Object',
|
||||
#instVars : [
|
||||
'fullname',
|
||||
'email'
|
||||
],
|
||||
#category : #ContactBook
|
||||
#category : 'ContactBook',
|
||||
#package : 'ContactBook'
|
||||
}
|
||||
|
||||
{ #category : #'instance creation' }
|
||||
{ #category : 'instance creation' }
|
||||
Contact class >> newNamed: aNameString email: anEmailString [
|
||||
^ self new
|
||||
fullname: aNameString;
|
||||
@@ -20,38 +21,38 @@ Contact class >> newNamed: aNameString email: anEmailString [
|
||||
yourself
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
{ #category : 'accessing' }
|
||||
Contact >> email [
|
||||
|
||||
^ email
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
{ #category : 'accessing' }
|
||||
Contact >> email: anObject [
|
||||
|
||||
email := anObject
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
{ #category : 'accessing' }
|
||||
Contact >> fullname [
|
||||
|
||||
^ fullname
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
{ #category : 'accessing' }
|
||||
Contact >> fullname: aString [
|
||||
|
||||
fullname := aString
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
{ #category : 'as yet unclassified' }
|
||||
Contact >> gravatarUrl [
|
||||
^ 'http://www.gravatar.com/avatar/',
|
||||
(MD5 hashMessage: email asString trimBoth asLowercase) hex,
|
||||
'.jpg'
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
{ #category : 'accessing' }
|
||||
Contact >> printOn: aStream [
|
||||
aStream
|
||||
nextPutAll: self fullname;
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
Class {
|
||||
#name : #ContactBook,
|
||||
#superclass : #Object,
|
||||
#name : 'ContactBook',
|
||||
#superclass : 'Object',
|
||||
#instVars : [
|
||||
'contacts'
|
||||
],
|
||||
#category : #ContactBook
|
||||
#category : 'ContactBook',
|
||||
#package : 'ContactBook'
|
||||
}
|
||||
|
||||
{ #category : #demos }
|
||||
{ #category : 'demos' }
|
||||
ContactBook class >> createDefault [
|
||||
^ self new
|
||||
addContact: (Contact newNamed: 'Damien Cassou' email: 'damien@cassou.me');
|
||||
@@ -17,28 +18,28 @@ ContactBook class >> createDefault [
|
||||
yourself
|
||||
]
|
||||
|
||||
{ #category : #writing }
|
||||
{ #category : 'writing' }
|
||||
ContactBook >> addContact: aContact [
|
||||
self contacts add: aContact
|
||||
]
|
||||
|
||||
{ #category : #reading }
|
||||
{ #category : 'reading' }
|
||||
ContactBook >> contacts [
|
||||
^ contacts
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
{ #category : 'initialization' }
|
||||
ContactBook >> initialize [
|
||||
super initialize.
|
||||
contacts := OrderedCollection new
|
||||
]
|
||||
|
||||
{ #category : #deleting }
|
||||
{ #category : 'deleting' }
|
||||
ContactBook >> removeContact: aContact [
|
||||
self contacts remove: aContact
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
{ #category : 'initialization' }
|
||||
ContactBook >> size [
|
||||
^ contacts size
|
||||
]
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
Class {
|
||||
#name : #ContactBookTest,
|
||||
#superclass : #TestCase,
|
||||
#name : 'ContactBookTest',
|
||||
#superclass : 'TestCase',
|
||||
#instVars : [
|
||||
'blog',
|
||||
'post'
|
||||
],
|
||||
#category : #ContactBook
|
||||
#category : 'ContactBook',
|
||||
#package : 'ContactBook'
|
||||
}
|
||||
|
||||
{ #category : #running }
|
||||
{ #category : 'running' }
|
||||
ContactBookTest >> setUp [
|
||||
blog := ContactBook new.
|
||||
blog addContact: (Contact newNamed: 'Tudor Girba' email: 'tudor@tudorgirba.com').
|
||||
@@ -16,25 +17,25 @@ ContactBookTest >> setUp [
|
||||
post := Contact newNamed: 'Clara Allende' email: 'clari.allende@gmail.com'
|
||||
]
|
||||
|
||||
{ #category : #tests }
|
||||
{ #category : 'tests' }
|
||||
ContactBookTest >> testAddContact [
|
||||
blog addContact: post.
|
||||
self assert: blog size equals: 2
|
||||
]
|
||||
|
||||
{ #category : #tests }
|
||||
{ #category : 'tests' }
|
||||
ContactBookTest >> testContacts [
|
||||
blog addContact: post.
|
||||
self assert: blog contacts size equals: 2
|
||||
]
|
||||
|
||||
{ #category : #tests }
|
||||
{ #category : 'tests' }
|
||||
ContactBookTest >> testRemoveContact [
|
||||
blog removeContact: blog contacts first.
|
||||
self assert: blog size equals: 0
|
||||
]
|
||||
|
||||
{ #category : #tests }
|
||||
{ #category : 'tests' }
|
||||
ContactBookTest >> testSize [
|
||||
self assert: blog size equals: 1
|
||||
]
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
Class {
|
||||
#name : #ContactTest,
|
||||
#superclass : #TestCase,
|
||||
#category : #ContactBook
|
||||
#name : 'ContactTest',
|
||||
#superclass : 'TestCase',
|
||||
#category : 'ContactBook',
|
||||
#package : 'ContactBook'
|
||||
}
|
||||
|
||||
{ #category : #tests }
|
||||
{ #category : 'tests' }
|
||||
ContactTest >> testCreation [
|
||||
|
||||
| contact |
|
||||
@@ -15,7 +16,7 @@ ContactTest >> testCreation [
|
||||
self assert: contact email equals: 'marcus.denker@inria.fr'
|
||||
]
|
||||
|
||||
{ #category : #tests }
|
||||
{ #category : 'tests' }
|
||||
ContactTest >> testPrinting [
|
||||
|
||||
| contact |
|
||||
|
||||
@@ -1,94 +1,95 @@
|
||||
Class {
|
||||
#name : #WAContact,
|
||||
#superclass : #WAComponent,
|
||||
#name : 'WAContact',
|
||||
#superclass : 'WAComponent',
|
||||
#instVars : [
|
||||
'contact'
|
||||
],
|
||||
#category : #ContactBook
|
||||
#category : 'ContactBook',
|
||||
#package : 'ContactBook'
|
||||
}
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
{ #category : 'as yet unclassified' }
|
||||
WAContact class >> editContact: aContact [
|
||||
^ self new
|
||||
setContact: aContact;
|
||||
yourself
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
{ #category : 'initialization' }
|
||||
WAContact >> contact [
|
||||
^ contact
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
{ #category : 'initialization' }
|
||||
WAContact >> initialize [
|
||||
super initialize.
|
||||
contact := Contact new
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
{ #category : 'as yet unclassified' }
|
||||
WAContact >> renderButtonsOn: html [
|
||||
html tbsFormGroup: [
|
||||
html tbsButtonGroup: [
|
||||
html formGroup: [
|
||||
html buttonGroup: [
|
||||
self
|
||||
renderSubmitButtonOn: html;
|
||||
renderCancelButtonOn: html ] ]
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
{ #category : 'as yet unclassified' }
|
||||
WAContact >> renderCancelButtonOn: html [
|
||||
html tbsButton
|
||||
html outlineButton
|
||||
beDanger;
|
||||
cancelCallback: [ self answer: nil ];
|
||||
with: 'Cancel'
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
{ #category : 'as yet unclassified' }
|
||||
WAContact >> renderContentOn: html [
|
||||
html tbsContainer: [
|
||||
html container: [
|
||||
html heading with: 'Contact Editing'.
|
||||
html tbsForm with: [
|
||||
html form with: [
|
||||
self renderFieldsOn: html.
|
||||
self renderButtonsOn: html ] ]
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
{ #category : 'as yet unclassified' }
|
||||
WAContact >> renderEmailFieldOn: html [
|
||||
html tbsFormGroup: [
|
||||
html formGroup: [
|
||||
html label: 'Email'.
|
||||
html emailInput
|
||||
tbsFormControl;
|
||||
formControl;
|
||||
placeholder: 'your@email.eu';
|
||||
callback: [ :value | self contact email: value ];
|
||||
value: (self contact email ifNil: '') ]
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
{ #category : 'as yet unclassified' }
|
||||
WAContact >> renderFieldsOn: html [
|
||||
self renderFullnameFieldOn: html.
|
||||
self renderEmailFieldOn: html
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
{ #category : 'as yet unclassified' }
|
||||
WAContact >> renderFullnameFieldOn: html [
|
||||
html tbsFormGroup: [
|
||||
html formGroup: [
|
||||
html label: 'Fullname'.
|
||||
html textInput
|
||||
tbsFormControl;
|
||||
formControl;
|
||||
placeholder: 'fullname';
|
||||
callback: [ :value | self contact fullname: value ];
|
||||
value: (self contact fullname ifNil: '') ]
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
{ #category : 'as yet unclassified' }
|
||||
WAContact >> renderSubmitButtonOn: html [
|
||||
html tbsSubmitButton
|
||||
html submitButton
|
||||
beSuccess;
|
||||
bePrimary;
|
||||
callback: [ self answer: self contact ];
|
||||
with: 'Save'
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
{ #category : 'initialization' }
|
||||
WAContact >> setContact: aContact [
|
||||
contact := aContact
|
||||
]
|
||||
|
||||
@@ -1,49 +1,50 @@
|
||||
Class {
|
||||
#name : #WAContactBook,
|
||||
#superclass : #WAComponent,
|
||||
#name : 'WAContactBook',
|
||||
#superclass : 'WAComponent',
|
||||
#instVars : [
|
||||
'contactBook'
|
||||
],
|
||||
#category : #ContactBook
|
||||
#category : 'ContactBook',
|
||||
#package : 'ContactBook'
|
||||
}
|
||||
|
||||
{ #category : #initialization }
|
||||
{ #category : 'initialization' }
|
||||
WAContactBook class >> initialize [
|
||||
(WAAdmin register: self asApplicationAt: 'contacts')
|
||||
addLibrary: JQDeploymentLibrary;
|
||||
addLibrary: TBSDeploymentLibrary
|
||||
addLibrary: SBSDevelopmentLibrary
|
||||
]
|
||||
|
||||
{ #category : #rendering }
|
||||
{ #category : 'rendering' }
|
||||
WAContactBook >> addContact [
|
||||
(self call: WAContact new)
|
||||
ifNotNil: [ :contact | contactBook addContact: contact ]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
{ #category : 'accessing' }
|
||||
WAContactBook >> contactBook [
|
||||
^ contactBook ifNil: [ contactBook := ContactBook createDefault ]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
{ #category : 'accessing' }
|
||||
WAContactBook >> contacts [
|
||||
^ self contactBook contacts
|
||||
]
|
||||
|
||||
{ #category : #iterating }
|
||||
{ #category : 'iterating' }
|
||||
WAContactBook >> contactsDo: aBlock [
|
||||
self contacts do: aBlock
|
||||
]
|
||||
|
||||
{ #category : #rendering }
|
||||
{ #category : 'rendering' }
|
||||
WAContactBook >> renderButtonsForContact: aContact on: html [
|
||||
html tbsButtonGroup: [
|
||||
html buttonGroup: [
|
||||
self
|
||||
renderEditButtonForContact: aContact on: html;
|
||||
renderRemoveButtonForContact: aContact on: html ]
|
||||
]
|
||||
|
||||
{ #category : #rendering }
|
||||
{ #category : 'rendering' }
|
||||
WAContactBook >> renderContact: aContact on: html [
|
||||
html tableRow: [
|
||||
html
|
||||
@@ -53,9 +54,9 @@ WAContactBook >> renderContact: aContact on: html [
|
||||
tableData: [ self renderButtonsForContact: aContact on: html ] ]
|
||||
]
|
||||
|
||||
{ #category : #rendering }
|
||||
{ #category : 'rendering' }
|
||||
WAContactBook >> renderContactsOn: html [
|
||||
html tbsTable: [
|
||||
html table: [
|
||||
html tableHead: [
|
||||
html
|
||||
tableHeading: 'Name';
|
||||
@@ -64,51 +65,51 @@ WAContactBook >> renderContactsOn: html [
|
||||
self contactsDo: [ :contact | self renderContact: contact on: html ] ]
|
||||
]
|
||||
|
||||
{ #category : #rendering }
|
||||
{ #category : 'rendering' }
|
||||
WAContactBook >> renderContentOn: html [
|
||||
"Main entry point of the view. Render both a title and the list of contacts."
|
||||
|
||||
html
|
||||
tbsContainer: [
|
||||
container: [
|
||||
html heading
|
||||
level: 1;
|
||||
with: 'My Contact Book'.
|
||||
html tbsForm: [
|
||||
html form: [
|
||||
self renderContactsOn: html.
|
||||
self renderGlobalButtonsOn: html ] ]
|
||||
]
|
||||
|
||||
{ #category : #rendering }
|
||||
{ #category : 'rendering' }
|
||||
WAContactBook >> renderEditButtonForContact: aContact on: html [
|
||||
html tbsButton
|
||||
html outlineButton
|
||||
beSuccess;
|
||||
callback: [ self call: (WAContact editContact: aContact) ];
|
||||
with: 'Edit'
|
||||
]
|
||||
|
||||
{ #category : #rendering }
|
||||
{ #category : 'rendering' }
|
||||
WAContactBook >> renderGlobalButtonsOn: html [
|
||||
html tbsButtonGroup: [
|
||||
html tbsButton
|
||||
html buttonGroup: [
|
||||
html outlineButton
|
||||
beSuccess;
|
||||
callback: [ self addContact ];
|
||||
with: 'New contact' ]
|
||||
]
|
||||
|
||||
{ #category : #rendering }
|
||||
{ #category : 'rendering' }
|
||||
WAContactBook >> renderPhotoOf: aContact on: html [
|
||||
html image url: aContact gravatarUrl
|
||||
]
|
||||
|
||||
{ #category : #rendering }
|
||||
{ #category : 'rendering' }
|
||||
WAContactBook >> renderRemoveButtonForContact: aContact on: html [
|
||||
html tbsButton
|
||||
html outlineButton
|
||||
beDanger;
|
||||
callback: [ self contactBook removeContact: aContact ];
|
||||
with: 'Remove'
|
||||
]
|
||||
|
||||
{ #category : #updating }
|
||||
{ #category : 'updating' }
|
||||
WAContactBook >> updateRoot: anHtmlRoot [
|
||||
super updateRoot: anHtmlRoot.
|
||||
anHtmlRoot title: 'Contact Book'
|
||||
|
||||
@@ -1 +1 @@
|
||||
Package { #name : #ContactBook }
|
||||
Package { #name : 'ContactBook' }
|
||||
|
||||
Reference in New Issue
Block a user