summaryrefslogtreecommitdiff
path: root/pharo-mooc/tiny-blog/src/TinyBlog-Components/TBAuthenticationComponent.class.st
blob: b76cb6b7c80b0d62e969ccf1eea8909f19701431 (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
117
118
119
120
121
122
123
124
125
Class {
	#name : 'TBAuthenticationComponent',
	#superclass : 'SBSComponent',
	#instVars : [
		'password',
		'account',
		'component'
	],
	#category : 'TinyBlog-Components',
	#package : 'TinyBlog-Components'
}

{ #category : 'instance creation' }
TBAuthenticationComponent class >> from: aComponent [
	^ self new
		component: aComponent;
		yourself
]

{ #category : 'accessing' }
TBAuthenticationComponent >> account [

	^ account
]

{ #category : 'accessing' }
TBAuthenticationComponent >> account: anObject [

	account := anObject
]

{ #category : 'accessing' }
TBAuthenticationComponent >> component [

	^ component
]

{ #category : 'accessing' }
TBAuthenticationComponent >> component: anObject [

	component := anObject
]

{ #category : 'accessing' }
TBAuthenticationComponent >> password [

	^ password
]

{ #category : 'accessing' }
TBAuthenticationComponent >> password: anObject [

	password := anObject
]

{ #category : 'rendering' }
TBAuthenticationComponent >> renderAccountFieldOn: html [
	html 
		formGroup: [ html label with: 'Account'.
			html textInput
				formControl;
				attributeAt: 'autofocus' put: 'true';
				callback: [ :value | account := value ];
				value: account ]
]

{ #category : 'rendering' }
TBAuthenticationComponent >> renderBodyOn: html [
	html 
		modalBody: [ 
			html form: [ 
				self renderAccountFieldOn: html.
				self renderPasswordFieldOn: html.
				html modalFooter: [ self renderButtonsOn: html ] ] ]
]

{ #category : 'rendering' }
TBAuthenticationComponent >> renderButtonsOn: html [
	html formButton
		beSecondary;
		dataDismiss: 'modal';
		value: 'Cancel'.
	html formButton
		"beSubmit;"
		bePrimary;
		callback: [ self validate ];
		value: 'SignIn'
]

{ #category : 'rendering' }
TBAuthenticationComponent >> renderContentOn: html [
	html modal 
		id: 'myAuthDialog';
		fade;
		with: [ 
			html modalDialog: [ 
				html modalContent: [ 
					self renderHeaderOn: html.
					self renderBodyOn: html ] ] ]
]

{ #category : 'rendering' }
TBAuthenticationComponent >> renderHeaderOn: html [
	html 
		modalHeader: [ 
			html modalCloseButton.
			html modalTitle
				level: 4;
				with: 'Authentication' ]
]

{ #category : 'rendering' }
TBAuthenticationComponent >> renderPasswordFieldOn: html [
	html 
		formGroup: [ html label with: 'Password'.
			html passwordInput
				formControl;
				callback: [ :value | password := value ];
				value: password ]
]

{ #category : 'rendering' }
TBAuthenticationComponent >> validate [
	^ component tryConnectionWithLogin: self account andPassword: self password
]