ProtoObjectObjectWAPresenterWAComponentWAAlphabeticBatchedList
| currentPage | items |
| instance | class |
|---|---|
| accessing accessing-calculated actions initialization rendering testing | no messages
|
| currentPage |
|---|
| items |
|---|
| accessing |
|---|
| currentPage |
^ currentPage ifNil: [currentPage _ self validPages first] |
| currentPage: aCharacter |
currentPage _ aCharacter |
| items |
^ items |
| items: aCollection |
items _ aCollection |
| accessing-calculated |
|---|
| allPages |
^ $A to: $Z |
| batch |
^ items select: [:ea | ea asString asUppercase first = self currentPage] |
| validPages |
^ (items collect: [:ea | ea asString asUppercase first]) asSet asSortedCollection |
| actions |
|---|
| nextPage |
self isOnLastPage ifFalse: [currentPage _ self validPages after: currentPage] |
| previousPage |
self isOnFirstPage ifFalse: [currentPage _ self validPages before: currentPage] |
| initialization |
|---|
| initialize |
self session registerObjectForBacktracking: self. |
| rendering |
|---|
| renderContentOn: html |
items isEmpty ifFalse: [ html divNamed: 'batch' with: [ self renderPreviousOn: html. self renderPagesOn: html. self renderNextOn: html ] ] |
| renderNextOn: html |
html space. self isOnLastPage ifFalse: [ html anchorWithAction: [ self nextPage ] text: '>>' ] ifTrue: [ html text: '>>' ] |
| renderPagesOn: html |
self allPages do: [ :char | currentPage = char ifFalse: [(self validPages includes: char) ifTrue: [html anchorWithAction: [self currentPage: char] text: char] ifFalse: [html text: char]] ifTrue: [html bold: char ] ] separatedBy: [ html space ] |
| renderPreviousOn: html |
self isOnFirstPage ifFalse: [ html anchorWithAction: [ self previousPage ] text: '<<' ] ifTrue: [ html text: '<<' ]. html space. |
| testing |
|---|
| isOnFirstPage |
^ self validPages first = self currentPage |
| isOnLastPage |
^ self validPages last = self currentPage |