Class { #name : 'TBPostsListComponent', #superclass : 'TBScreenComponent', #instVars : [ 'postComponents', 'currentCategory', 'showLoginError' ], #category : 'TinyBlog-Components', #package : 'TinyBlog-Components' } { #category : 'rendering' } TBPostsListComponent >> basicRenderCategoriesOn: html [ html render: self categoriesComponent ] { #category : 'rendering' } TBPostsListComponent >> basicRenderPostsOn: html [ self readSelectedPosts do: [ :p | html render: (self postComponentFor: p) ] ] { #category : 'rendering' } TBPostsListComponent >> categoriesComponent [ ^ TBCategoriesComponent categories: self blog allCategories postsList: self ] { #category : 'initialization' } TBPostsListComponent >> children [ ^ self postComponents, super children ] { #category : 'accessing' } TBPostsListComponent >> currentCategory [ ^ currentCategory ] { #category : 'accessing' } TBPostsListComponent >> currentCategory: anObject [ currentCategory := anObject ] { #category : 'as yet unclassified' } TBPostsListComponent >> goToAdministrationView [ self call: TBAdminComponent new ] { #category : 'as yet unclassified' } TBPostsListComponent >> hasLoginError [ ^ showLoginError ifNil: [ false ] ] { #category : 'initialization' } TBPostsListComponent >> initialize [ super initialize. postComponents := OrderedCollection new ] { #category : 'as yet unclassified' } TBPostsListComponent >> loginErrorMessage [ ^ 'Incorrect login and/or password' ] { #category : 'as yet unclassified' } TBPostsListComponent >> loginErrorOccurred [ showLoginError := true ] { #category : 'rendering' } TBPostsListComponent >> postComponentFor: aPost [ ^ TBPostComponent new post: aPost ] { #category : 'initialization' } TBPostsListComponent >> postComponents [ postComponents := self readSelectedPosts collect: [ :each | TBPostComponent new post: each ]. ^ postComponents ] { #category : 'initialization' } TBPostsListComponent >> readSelectedPosts [ ^ self currentCategory ifNil: [ self blog allVisibleBlogPosts ] ifNotNil: [ self blog allVisibleBlogPostsFromCategory: self currentCategory ] ] { #category : 'rendering' } TBPostsListComponent >> renderCategoryColumnOn: html [ html column extraSmallSize: 12; smallSize: 2; mediumSize: 4; with: [ self basicRenderCategoriesOn: html ] ] { #category : 'rendering' } TBPostsListComponent >> renderContentOn: html [ super renderContentOn: html. html container: [ html row with: [ html column extraSmallSize: 12; smallSize: 2; mediumSize: 4; with: [ html render: self categoriesComponent ]. self renderPostColumnOn: html ] ] ] { #category : 'rendering' } TBPostsListComponent >> renderLoginErrorMessageIfAnyOn: html [ self hasLoginError ifTrue: [ showLoginError := false. html alert beDanger; with: self loginErrorMessage ] ] { #category : 'rendering' } TBPostsListComponent >> renderPostColumnOn: html [ html column extraSmallSize: 12; smallSize: 10; mediumSize: 8; with: [ self renderLoginErrorMessageIfAnyOn: html. self basicRenderPostsOn: html ] ] { #category : 'as yet unclassified' } TBPostsListComponent >> tryConnectionWithLogin: login andPassword: password [ (login = self blog administrator login and: [ (SHA256 hashMessage: password) = self blog administrator password ]) ifTrue: [ self session currentAdmin: self blog administrator. self goToAdministrationView ] ifFalse: [ self loginErrorOccurred ] ]