diff options
| author | Eugen Wissner <belka@caraus.de> | 2025-11-21 22:20:10 +0100 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2025-11-21 22:20:10 +0100 |
| commit | c03c9f8b886c0e8eca5a701c0ca941e05e0b6285 (patch) | |
| tree | 5f27293563caa042b182de97fe59b22e2cbd533a /pharo-mooc/tiny-blog/src/TinyBlog-Components/TBAuthenticationComponent.class.st | |
| parent | c0336dac8effb57c04221f23b72bff70170933c5 (diff) | |
| download | book-exercises-c03c9f8b886c0e8eca5a701c0ca941e05e0b6285.tar.gz | |
Add pharo tiny blog
Diffstat (limited to 'pharo-mooc/tiny-blog/src/TinyBlog-Components/TBAuthenticationComponent.class.st')
| -rw-r--r-- | pharo-mooc/tiny-blog/src/TinyBlog-Components/TBAuthenticationComponent.class.st | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/pharo-mooc/tiny-blog/src/TinyBlog-Components/TBAuthenticationComponent.class.st b/pharo-mooc/tiny-blog/src/TinyBlog-Components/TBAuthenticationComponent.class.st new file mode 100644 index 0000000..b76cb6b --- /dev/null +++ b/pharo-mooc/tiny-blog/src/TinyBlog-Components/TBAuthenticationComponent.class.st @@ -0,0 +1,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 +] |
