-
Notifications
You must be signed in to change notification settings - Fork 21
300-Allow-the-MDLTableWidget-to-be-paginated #304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
juliendelplanque
wants to merge
15
commits into
DuneSt:development
Choose a base branch
from
juliendelplanque:300-Allow-the-MDLTableWidget-to-be-paginated
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
be9692d
Merge pull request #247 from DuneSt/development
jecisc 7769357
Merge branch 'development'
jecisc bb5f102
Merge pull request #253 from DuneSt/development
jecisc be363f3
Merge branch 'development'
jecisc 5818e71
Merge branch 'development'
jecisc 46748fa
Merge pull request #262 from DuneSt/development
jecisc d465d7c
Merge branch 'development'
jecisc 1680d54
Merge pull request #295 from DuneSt/development
jecisc 5dcebd4
Implemented pagination for MDLTableWidget.
juliendelplanque d6cafc2
Added example of paginated table widget.
juliendelplanque e7aa8e0
Update src/Material-Design-Lite-Demo/MDLTableWidgetScreen.class.st
juliendelplanque efaa013
Update src/Material-Design-Lite-Widgets/MDLDisplayPaginatedTableConte…
juliendelplanque 56c5b92
Update src/Material-Design-Lite-Widgets/MDLDisplayPaginatedTableConte…
juliendelplanque d3dd713
Renamed pagination syntax sugar message to be shorter and added #bePa…
juliendelplanque 0679141
Raise correct error when #rowsPerPage message is sent but #rowsPerPag…
juliendelplanque File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
235 changes: 235 additions & 0 deletions
235
src/Material-Design-Lite-Widgets-Tests/MDLDisplayPaginatedTableContentTest.class.st
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,235 @@ | ||
| " | ||
| A MDLDisplayPaginatedTableContentTest is a test class for testing the behavior of MDLDisplayPaginatedTableContent | ||
| " | ||
| Class { | ||
| #name : #MDLDisplayPaginatedTableContentTest, | ||
| #superclass : #SGTAbstractSeasideTestCase, | ||
| #category : #'Material-Design-Lite-Widgets-Tests-Table' | ||
| } | ||
|
|
||
| { #category : #test } | ||
| MDLDisplayPaginatedTableContentTest >> testIndexOfLastRowToShow [ | ||
| | contentDisplayStrategy table | | ||
| contentDisplayStrategy := MDLDisplayPaginatedTableContent new. | ||
| table := MDLTableWidget new | ||
| contentDisplayStrategy: contentDisplayStrategy; | ||
| collection: (1 to: 100) asArray; | ||
| yourself. | ||
|
|
||
| self assert: contentDisplayStrategy rowsPerPage equals: 5. | ||
| self assert: contentDisplayStrategy indexOfLastRowToShow equals: 5. | ||
|
|
||
| contentDisplayStrategy rowsPerPage: 10. | ||
|
|
||
| self assert: contentDisplayStrategy rowsPerPage equals: 10. | ||
| self assert: contentDisplayStrategy indexOfLastRowToShow equals: 10. | ||
|
|
||
| ] | ||
|
|
||
| { #category : #test } | ||
| MDLDisplayPaginatedTableContentTest >> testInitialize [ | ||
| | contentDisplayStrategy | | ||
| contentDisplayStrategy := MDLDisplayPaginatedTableContent new. | ||
|
|
||
| self assert: contentDisplayStrategy position equals: contentDisplayStrategy initialPosition. | ||
| self assert: contentDisplayStrategy rowsPerPagePossibilities equals: contentDisplayStrategy defaultRowsPerPagePossibilities | ||
| ] | ||
|
|
||
| { #category : #test } | ||
| MDLDisplayPaginatedTableContentTest >> testIsAtEnd [ | ||
| | contentDisplayStrategy table | | ||
| contentDisplayStrategy := MDLDisplayPaginatedTableContent new. | ||
| table := MDLTableWidget new | ||
| contentDisplayStrategy: contentDisplayStrategy; | ||
| collection: (1 to: 100) asArray; | ||
| yourself. | ||
|
|
||
| self assert: contentDisplayStrategy position equals: contentDisplayStrategy initialPosition. | ||
| contentDisplayStrategy rowsPerPage: 50. | ||
|
|
||
| self deny: contentDisplayStrategy isAtEnd. | ||
| self assert: contentDisplayStrategy position equals: contentDisplayStrategy initialPosition. | ||
|
|
||
| contentDisplayStrategy nextPosition. | ||
|
|
||
| self assert: contentDisplayStrategy isAtEnd. | ||
| self assert: contentDisplayStrategy position equals: 51. | ||
|
|
||
| "Do not move if we call #nextPosition again." | ||
| contentDisplayStrategy nextPosition. | ||
|
|
||
| self assert: contentDisplayStrategy isAtEnd. | ||
| self assert: contentDisplayStrategy position equals: 51. | ||
| ] | ||
|
|
||
| { #category : #test } | ||
| MDLDisplayPaginatedTableContentTest >> testNextPosition [ | ||
| | contentDisplayStrategy table | | ||
| contentDisplayStrategy := MDLDisplayPaginatedTableContent new. | ||
| table := MDLTableWidget new | ||
| contentDisplayStrategy: contentDisplayStrategy; | ||
| collection: (1 to: 100) asArray; | ||
| yourself. | ||
|
|
||
| self assert: contentDisplayStrategy position equals: contentDisplayStrategy initialPosition. | ||
| self assert: contentDisplayStrategy rowsPerPage equals: 5. | ||
|
|
||
| contentDisplayStrategy nextPosition. | ||
|
|
||
| self assert: contentDisplayStrategy position equals: 6. | ||
|
|
||
| contentDisplayStrategy nextPosition. | ||
|
|
||
| self assert: contentDisplayStrategy position equals: 11. | ||
| ] | ||
|
|
||
| { #category : #test } | ||
| MDLDisplayPaginatedTableContentTest >> testNextPosition2 [ | ||
| | contentDisplayStrategy table | | ||
| contentDisplayStrategy := MDLDisplayPaginatedTableContent new. | ||
| table := MDLTableWidget new | ||
| contentDisplayStrategy: contentDisplayStrategy; | ||
| collection: (1 to: 100) asArray; | ||
| yourself. | ||
|
|
||
| self assert: contentDisplayStrategy position equals: contentDisplayStrategy initialPosition. | ||
| contentDisplayStrategy rowsPerPage: 10. | ||
|
|
||
| contentDisplayStrategy nextPosition. | ||
|
|
||
| self assert: contentDisplayStrategy position equals: 11. | ||
|
|
||
| contentDisplayStrategy nextPosition. | ||
|
|
||
| self assert: contentDisplayStrategy position equals: 21. | ||
| ] | ||
|
|
||
| { #category : #test } | ||
| MDLDisplayPaginatedTableContentTest >> testPreviousPosition [ | ||
| | contentDisplayStrategy table | | ||
| contentDisplayStrategy := MDLDisplayPaginatedTableContent new. | ||
| table := MDLTableWidget new | ||
| contentDisplayStrategy: contentDisplayStrategy; | ||
| collection: (1 to: 100) asArray; | ||
| yourself. | ||
| contentDisplayStrategy rowsPerPage: 10. | ||
| contentDisplayStrategy position: 91. | ||
|
|
||
| contentDisplayStrategy previousPosition. | ||
| self assert: contentDisplayStrategy position equals: 81. | ||
|
|
||
| contentDisplayStrategy previousPosition. | ||
| self assert: contentDisplayStrategy position equals: 71. | ||
|
|
||
| contentDisplayStrategy previousPosition. | ||
| self assert: contentDisplayStrategy position equals: 61. | ||
|
|
||
| contentDisplayStrategy previousPosition. | ||
| self assert: contentDisplayStrategy position equals: 51. | ||
|
|
||
| contentDisplayStrategy previousPosition. | ||
| self assert: contentDisplayStrategy position equals: 41. | ||
|
|
||
| contentDisplayStrategy previousPosition. | ||
| self assert: contentDisplayStrategy position equals: 31. | ||
|
|
||
| contentDisplayStrategy previousPosition. | ||
| self assert: contentDisplayStrategy position equals: 21. | ||
|
|
||
| contentDisplayStrategy previousPosition. | ||
| self assert: contentDisplayStrategy position equals: 11. | ||
|
|
||
| contentDisplayStrategy previousPosition. | ||
| self assert: contentDisplayStrategy position equals: 1. | ||
|
|
||
| "Check it does nothing once we reached beginning of collection." | ||
| contentDisplayStrategy previousPosition. | ||
| self assert: contentDisplayStrategy position equals: 1. | ||
| ] | ||
|
|
||
| { #category : #test } | ||
| MDLDisplayPaginatedTableContentTest >> testRenderPagesInfoOn [ | ||
| | contentDisplayStrategy table | | ||
| contentDisplayStrategy := MDLDisplayPaginatedTableContent new. | ||
| table := MDLTableWidget new | ||
| contentDisplayStrategy: contentDisplayStrategy; | ||
| collection: (1 to: 100) asArray; | ||
| yourself. | ||
| self | ||
| assert: [ :html | contentDisplayStrategy renderPagesInfoOn: html ] | ||
| generates: '1 - 5 of 100'. | ||
|
|
||
| contentDisplayStrategy nextPosition. | ||
|
|
||
| self | ||
| assert: [ :html | contentDisplayStrategy renderPagesInfoOn: html ] | ||
| generates: '6 - 10 of 100'. | ||
| ] | ||
|
|
||
| { #category : #test } | ||
| MDLDisplayPaginatedTableContentTest >> testRenderPagesInfoOn2 [ | ||
| | contentDisplayStrategy table | | ||
| contentDisplayStrategy := MDLDisplayPaginatedTableContent new. | ||
| table := MDLTableWidget new | ||
| contentDisplayStrategy: contentDisplayStrategy; | ||
| collection: (1 to: 100) asArray; | ||
| yourself. | ||
|
|
||
| contentDisplayStrategy rowsPerPage: 10. | ||
|
|
||
| self | ||
| assert: [ :html | contentDisplayStrategy renderPagesInfoOn: html ] | ||
| generates: '1 - 10 of 100'. | ||
|
|
||
| contentDisplayStrategy nextPosition. | ||
|
|
||
| self | ||
| assert: [ :html | contentDisplayStrategy renderPagesInfoOn: html ] | ||
| generates: '11 - 20 of 100'. | ||
| ] | ||
|
|
||
| { #category : #test } | ||
| MDLDisplayPaginatedTableContentTest >> testRowsToDisplayDo [ | ||
| | contentDisplayStrategy table | | ||
| contentDisplayStrategy := MDLDisplayPaginatedTableContent new. | ||
| table := MDLTableWidget new | ||
| contentDisplayStrategy: contentDisplayStrategy; | ||
| collection: (1 to: 100) asArray; | ||
| yourself. | ||
|
|
||
| self assertCollection: (Array streamContents: [ :stream | contentDisplayStrategy rowsToDisplayDo: [ :i | stream nextPut: i ] ]) equals: #(1 2 3 4 5). | ||
|
|
||
| contentDisplayStrategy nextPosition. | ||
|
|
||
| self assertCollection: (Array streamContents: [ :stream | contentDisplayStrategy rowsToDisplayDo: [ :i | stream nextPut: i ] ]) equals: #(6 7 8 9 10). | ||
| ] | ||
|
|
||
| { #category : #test } | ||
| MDLDisplayPaginatedTableContentTest >> testRowsToDisplayDo2 [ | ||
| | contentDisplayStrategy table | | ||
| contentDisplayStrategy := MDLDisplayPaginatedTableContent new. | ||
| table := MDLTableWidget new | ||
| contentDisplayStrategy: contentDisplayStrategy; | ||
| collection: (1 to: 100) asArray; | ||
| yourself. | ||
|
|
||
| contentDisplayStrategy rowsPerPage: 10. | ||
|
|
||
| self assertCollection: (Array streamContents: [ :stream | contentDisplayStrategy rowsToDisplayDo: [ :i | stream nextPut: i ] ]) equals: #(1 2 3 4 5 6 7 8 9 10). | ||
|
|
||
| contentDisplayStrategy nextPosition. | ||
|
|
||
| self assertCollection: (Array streamContents: [ :stream | contentDisplayStrategy rowsToDisplayDo: [ :i | stream nextPut: i ] ]) equals: #(11 12 13 14 15 16 17 18 19 20). | ||
| ] | ||
|
|
||
| { #category : #test } | ||
| MDLDisplayPaginatedTableContentTest >> testTotalNumberOfRows [ | ||
| | contentDisplayStrategy table | | ||
| contentDisplayStrategy := MDLDisplayPaginatedTableContent new. | ||
| table := MDLTableWidget new | ||
| contentDisplayStrategy: contentDisplayStrategy; | ||
| collection: (1 to: 100) asArray; | ||
| yourself. | ||
|
|
||
| self assert: contentDisplayStrategy totalNumberOfRows equals: table collection size. | ||
| ] |
26 changes: 26 additions & 0 deletions
26
src/Material-Design-Lite-Widgets/MDLDisplayFullTableContent.class.st
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| " | ||
| I am a simple strategy displaying the full content of the table. | ||
|
|
||
| I have not footer to display. | ||
| " | ||
| Class { | ||
| #name : #MDLDisplayFullTableContent, | ||
| #superclass : #MDLTableContentDisplayStrategy, | ||
| #category : #'Material-Design-Lite-Widgets-Table' | ||
| } | ||
|
|
||
| { #category : #rendering } | ||
| MDLDisplayFullTableContent >> renderContentOn: html [ | ||
| html tableBody | ||
| class: 'mdl-table-widget__body'; | ||
| with: [ | ||
| self tableWidget collection do: [ :row | | ||
| html tableRow: [ | ||
| self tableWidget columnDescriptions do: [ :columnDescription | | ||
| columnDescription render: row on: html ] ] ] ] | ||
| ] | ||
|
|
||
| { #category : #rendering } | ||
| MDLDisplayFullTableContent >> renderFooterOn: html [ | ||
| "Nothing to render here." | ||
| ] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.