From 54954ce2037cbdc6754bfa5758117be40e9c3793 Mon Sep 17 00:00:00 2001 From: Chriztian Steinmeier Date: Sat, 30 Mar 2013 00:21:01 +0100 Subject: [PATCH 01/19] Add fixture with nickname attributes (for sorting) --- .../test/fixtures/people-with-nicks.xml | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 paginationhelper/test/fixtures/people-with-nicks.xml diff --git a/paginationhelper/test/fixtures/people-with-nicks.xml b/paginationhelper/test/fixtures/people-with-nicks.xml new file mode 100644 index 0000000..b6e6c2a --- /dev/null +++ b/paginationhelper/test/fixtures/people-with-nicks.xml @@ -0,0 +1,23 @@ + + + + James Sawyer + james.sawyer@4815162342x.com + + + Kate Austen + kate.austen@4815162342x.com + + + Penelope Widmore + penelope.widmore@4815162342x.com + + + Hugo Reyes + hugo.reyes@4815162342x.com + + + Jack Shepard + jack.shepard@4815162342x.com + + \ No newline at end of file From a4e4d8a706f20958fe07a4858b514fd5d2e3ef6f Mon Sep 17 00:00:00 2001 From: Chriztian Steinmeier Date: Sat, 30 Mar 2013 00:21:40 +0100 Subject: [PATCH 02/19] Add Sample file for testing sorting --- .../test/PaginationHelperSortedSample.xslt | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 paginationhelper/test/PaginationHelperSortedSample.xslt diff --git a/paginationhelper/test/PaginationHelperSortedSample.xslt b/paginationhelper/test/PaginationHelperSortedSample.xslt new file mode 100644 index 0000000..68c7567 --- /dev/null +++ b/paginationhelper/test/PaginationHelperSortedSample.xslt @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + +

+ +

+
+ + + +
\ No newline at end of file From 638ea36be41820504e7dde3e04e6a438244ee9c7 Mon Sep 17 00:00:00 2001 From: Chriztian Steinmeier Date: Sat, 30 Mar 2013 00:21:59 +0100 Subject: [PATCH 03/19] Add specs for testing sorting --- .../test/PaginationHelperSortedTest.xspec | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 paginationhelper/test/PaginationHelperSortedTest.xspec diff --git a/paginationhelper/test/PaginationHelperSortedTest.xspec b/paginationhelper/test/PaginationHelperSortedTest.xspec new file mode 100644 index 0000000..050659f --- /dev/null +++ b/paginationhelper/test/PaginationHelperSortedTest.xspec @@ -0,0 +1,42 @@ + + + + + + + + + + + + +

James Sawyer

+

Kate Austen

+

Penelope Widmore

+

Hugo Reyes

+

Jack Shepard

+
+
+ + + + + + +

Hugo Reyes

+

Jack Shepard

+

James Sawyer

+

Kate Austen

+

Penelope Widmore

+
+
+ +
+ + + +
\ No newline at end of file From e39b0dc311bad33a0cce9a82efd81de829cc5c17 Mon Sep 17 00:00:00 2001 From: Chriztian Steinmeier Date: Sat, 30 Mar 2013 00:36:19 +0100 Subject: [PATCH 04/19] Support sorting by a child element --- paginationhelper/_PaginationHelper.xslt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/paginationhelper/_PaginationHelper.xslt b/paginationhelper/_PaginationHelper.xslt index ea60d71..e833cfb 100644 --- a/paginationhelper/_PaginationHelper.xslt +++ b/paginationhelper/_PaginationHelper.xslt @@ -72,7 +72,10 @@ - + + + + @@ -85,8 +88,17 @@ - - + + + + + + + + + + + From 07f3c7f9ec8ccc1bf818dbf59dcadb6576fbf2cd Mon Sep 17 00:00:00 2001 From: Chriztian Steinmeier Date: Sat, 30 Mar 2013 01:07:29 +0100 Subject: [PATCH 05/19] Add scenarios for specifically selectiong ASC or DESC sorting --- .../test/PaginationHelperSortedTest.xspec | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/paginationhelper/test/PaginationHelperSortedTest.xspec b/paginationhelper/test/PaginationHelperSortedTest.xspec index 050659f..4d119af 100644 --- a/paginationhelper/test/PaginationHelperSortedTest.xspec +++ b/paginationhelper/test/PaginationHelperSortedTest.xspec @@ -33,6 +33,33 @@

Kate Austen

Penelope Widmore

+ + + + + + +

Hugo Reyes

+

Jack Shepard

+

James Sawyer

+

Kate Austen

+

Penelope Widmore

+
+
+ + + + + + +

Penelope Widmore

+

Kate Austen

+

James Sawyer

+

Jack Shepard

+

Hugo Reyes

+
+
+ From d09b07a952b932b7594598d218c7789b16b0d3c9 Mon Sep 17 00:00:00 2001 From: Chriztian Steinmeier Date: Sat, 30 Mar 2013 01:07:47 +0100 Subject: [PATCH 06/19] Implement ASC + DESC sorting --- paginationhelper/_PaginationHelper.xslt | 32 +++++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/paginationhelper/_PaginationHelper.xslt b/paginationhelper/_PaginationHelper.xslt index e833cfb..d24f8b3 100644 --- a/paginationhelper/_PaginationHelper.xslt +++ b/paginationhelper/_PaginationHelper.xslt @@ -73,7 +73,7 @@ - + @@ -89,10 +89,32 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + From f6d5bec412616ede1981a40b28fa9b7ead8f77c6 Mon Sep 17 00:00:00 2001 From: Chriztian Steinmeier Date: Sat, 30 Mar 2013 01:17:40 +0100 Subject: [PATCH 07/19] Add tests for sorting by an attribute --- .../test/PaginationHelperSortedTest.xspec | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/paginationhelper/test/PaginationHelperSortedTest.xspec b/paginationhelper/test/PaginationHelperSortedTest.xspec index 4d119af..19b76ce 100644 --- a/paginationhelper/test/PaginationHelperSortedTest.xspec +++ b/paginationhelper/test/PaginationHelperSortedTest.xspec @@ -59,6 +59,46 @@

Hugo Reyes

+ + + + + + + + +

Jack Shepard

+

Kate Austen

+

Hugo Reyes

+

Penelope Widmore

+

James Sawyer

+
+ + + + + + +

Jack Shepard

+

Kate Austen

+

Hugo Reyes

+

Penelope Widmore

+

James Sawyer

+
+
+ + + + + + +

James Sawyer

+

Penelope Widmore

+

Hugo Reyes

+

Kate Austen

+

Jack Shepard

+
+
From 678234d9580b8068472b6ed7a06f8c4a05047d27 Mon Sep 17 00:00:00 2001 From: Chriztian Steinmeier Date: Wed, 3 Apr 2013 00:36:55 +0200 Subject: [PATCH 08/19] Remove redundant attribute --- paginationhelper/test/PaginationHelperSortedTest.xspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paginationhelper/test/PaginationHelperSortedTest.xspec b/paginationhelper/test/PaginationHelperSortedTest.xspec index 19b76ce..a2335b9 100644 --- a/paginationhelper/test/PaginationHelperSortedTest.xspec +++ b/paginationhelper/test/PaginationHelperSortedTest.xspec @@ -5,7 +5,7 @@ xmlns:x="http://www.jenitennison.com/xslt/xspec" > - + From 6a3c0fe4f34eeac95d7a6d5ba9c53c829d6db977 Mon Sep 17 00:00:00 2001 From: Chriztian Steinmeier Date: Wed, 17 Apr 2013 02:15:08 +0200 Subject: [PATCH 09/19] Add ids to people-with-nicks --- paginationhelper/test/fixtures/people-with-nicks.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/paginationhelper/test/fixtures/people-with-nicks.xml b/paginationhelper/test/fixtures/people-with-nicks.xml index b6e6c2a..b9bd7fb 100644 --- a/paginationhelper/test/fixtures/people-with-nicks.xml +++ b/paginationhelper/test/fixtures/people-with-nicks.xml @@ -1,22 +1,22 @@ - + James Sawyer james.sawyer@4815162342x.com - + Kate Austen kate.austen@4815162342x.com - + Penelope Widmore penelope.widmore@4815162342x.com - + Hugo Reyes hugo.reyes@4815162342x.com - + Jack Shepard jack.shepard@4815162342x.com From eb84bf577be63c38c0ea4d9ea32d159b84e4394a Mon Sep 17 00:00:00 2001 From: Chriztian Steinmeier Date: Wed, 17 Apr 2013 02:15:21 +0200 Subject: [PATCH 10/19] Add test for presorting --- paginationhelper/test/PreSortingTest.xspec | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 paginationhelper/test/PreSortingTest.xspec diff --git a/paginationhelper/test/PreSortingTest.xspec b/paginationhelper/test/PreSortingTest.xspec new file mode 100644 index 0000000..55742b1 --- /dev/null +++ b/paginationhelper/test/PreSortingTest.xspec @@ -0,0 +1,23 @@ + + + + + + + + + + 4 + 5 + 1 + 2 + 3 + + + + + \ No newline at end of file From c4f5e100e525b429e1282ca470bd9a522a9a26ce Mon Sep 17 00:00:00 2001 From: Chriztian Steinmeier Date: Wed, 17 Apr 2013 02:15:42 +0200 Subject: [PATCH 11/19] Further tests --- .../test/PaginationHelperSortedTest.xspec | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/paginationhelper/test/PaginationHelperSortedTest.xspec b/paginationhelper/test/PaginationHelperSortedTest.xspec index a2335b9..766fca7 100644 --- a/paginationhelper/test/PaginationHelperSortedTest.xspec +++ b/paginationhelper/test/PaginationHelperSortedTest.xspec @@ -47,6 +47,19 @@ + + + + + +

Hugo Reyes

+

Jack Shepard

+

James Sawyer

+

Kate Austen

+

Penelope Widmore

+
+
+ @@ -59,6 +72,19 @@

Hugo Reyes

+ + + + + + +

Penelope Widmore

+

Kate Austen

+

James Sawyer

+

Jack Shepard

+

Hugo Reyes

+
+
@@ -100,10 +126,20 @@ + + + + + + +

...

+

...

+

...

+
+
+ - - \ No newline at end of file From a9ecd2d9203ead2bbceb75de50152e2157663785 Mon Sep 17 00:00:00 2001 From: Chriztian Steinmeier Date: Wed, 17 Apr 2013 02:15:56 +0200 Subject: [PATCH 12/19] Add preSort template --- paginationhelper/_PaginationHelper.xslt | 42 +++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/paginationhelper/_PaginationHelper.xslt b/paginationhelper/_PaginationHelper.xslt index d24f8b3..941e893 100644 --- a/paginationhelper/_PaginationHelper.xslt +++ b/paginationhelper/_PaginationHelper.xslt @@ -296,5 +296,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 9642897861630d2a976b71424a9b4fbf03821b69 Mon Sep 17 00:00:00 2001 From: Chriztian Steinmeier Date: Wed, 17 Apr 2013 02:41:06 +0200 Subject: [PATCH 13/19] Refactor sorting --- paginationhelper/_PaginationHelper.xslt | 35 +++++++------------------ 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/paginationhelper/_PaginationHelper.xslt b/paginationhelper/_PaginationHelper.xslt index 941e893..782caeb 100644 --- a/paginationhelper/_PaginationHelper.xslt +++ b/paginationhelper/_PaginationHelper.xslt @@ -90,31 +90,16 @@ - - - - - - - - - - - + + + + + - - - - - - - - - - - - - + + + + @@ -301,8 +286,6 @@ - - From 8d2fa7183101e8e7405d803457df38047b252d55 Mon Sep 17 00:00:00 2001 From: Chriztian Steinmeier Date: Wed, 17 Apr 2013 23:13:41 +0200 Subject: [PATCH 14/19] Tests for paginating the sorted data --- .../test/PaginationHelperSortedTest.xspec | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/paginationhelper/test/PaginationHelperSortedTest.xspec b/paginationhelper/test/PaginationHelperSortedTest.xspec index 766fca7..ece04c3 100644 --- a/paginationhelper/test/PaginationHelperSortedTest.xspec +++ b/paginationhelper/test/PaginationHelperSortedTest.xspec @@ -85,6 +85,29 @@

Hugo Reyes

+ + + + + + + +

Hugo Reyes

+

Jack Shepard

+

James Sawyer

+
+ + + + + + +

Kate Austen

+

Penelope Widmore

+
+
+
+ From af11207f41a0329e06874129e32c420e2e888c22 Mon Sep 17 00:00:00 2001 From: Chriztian Steinmeier Date: Wed, 17 Apr 2013 23:13:47 +0200 Subject: [PATCH 15/19] Add comment --- paginationhelper/_PaginationHelper.xslt | 1 + 1 file changed, 1 insertion(+) diff --git a/paginationhelper/_PaginationHelper.xslt b/paginationhelper/_PaginationHelper.xslt index 782caeb..66f850b 100644 --- a/paginationhelper/_PaginationHelper.xslt +++ b/paginationhelper/_PaginationHelper.xslt @@ -89,6 +89,7 @@ + From 0aa1c8f159fe61544a52f270b40f875044da67f4 Mon Sep 17 00:00:00 2001 From: Chriztian Steinmeier Date: Thu, 18 Apr 2013 00:00:47 +0200 Subject: [PATCH 16/19] Explain sortBy parameter (README) --- paginationhelper/README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/paginationhelper/README.md b/paginationhelper/README.md index 77da22a..8b11682 100644 --- a/paginationhelper/README.md +++ b/paginationhelper/README.md @@ -55,6 +55,29 @@ output, you can turn them off with the `showPager` parameter by supplying `false can manually output the controls by calling `RenderPager`, using the same `selection` parameter as you called the `PaginateSelection` template with, to get the paging controls where you want them. +## Sorting the output + +Sometimes, the data you want to paginate is actually also being sorted when rendered, e.g. like this common scenario: + +```xslt + + + +``` + +The problem with introducing pagination here, is that most often you get the pagination happening *before* sorting, but you really want to *sort* the results first and then perform the pagination. For that you use the `sortBy` parameter: + +```xslt + + + + +``` + +*Note that it's a string combining the name of the element or attribute to sort by and the direction (`ASC` or `DESC`), separated by a space. `ASC` is the default so you don't even need to specify the direction, unless it's `DESC`.* + +It won't cover every scenario, e.g. it doesn't do numerical sorting yet, and you can only sort by a single element/attribute, where the element has to be a direct child of the node being sorted. Still, this should cover **a lot** of use cases. + ## QueryString options The pager links rendered will include all existing querystring options on the original page (i.e., "page 1"), so if From 70ce8bcae1a4c8fa96657e8de6b570a2162904ba Mon Sep 17 00:00:00 2001 From: Chriztian Steinmeier Date: Thu, 18 Apr 2013 00:10:15 +0200 Subject: [PATCH 17/19] Bump versions and Release Notes --- Release Notes.md | 2 ++ version.ent | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Release Notes.md b/Release Notes.md index 901182b..1d3e3fb 100644 --- a/Release Notes.md +++ b/Release Notes.md @@ -1,5 +1,6 @@ # Release Notes +* v0.8.5: Pagination Helper updated to 1.3 * v0.8.4: Pagination Helper updated to 1.2 * v0.8.3: Calendar Helper updated to 1.1, Media Helpers updated to 1.3 * v0.8.2: Media Helpers updated to 1.2 @@ -21,6 +22,7 @@ ## Pagination Helper +* v1.3: Support sorting with pagination by way of the `sortBy` parameter * v1.2: Use `pageLinksBeside` to specify number of links to show before & after current in the Pager * v1.1: `perPage` parameter can now be overridden diff --git a/version.ent b/version.ent index 7f12095..44c2c4b 100644 --- a/version.ent +++ b/version.ent @@ -1,8 +1,8 @@ - + - + From 3af14c065c2995382ce07d284fe8fc549b51cfbd Mon Sep 17 00:00:00 2001 From: Chriztian Steinmeier Date: Thu, 18 Apr 2013 01:40:40 +0200 Subject: [PATCH 18/19] Switch to use generate-id() instead of @id (@id was implementation-specific) --- paginationhelper/_PaginationHelper.xslt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/paginationhelper/_PaginationHelper.xslt b/paginationhelper/_PaginationHelper.xslt index 66f850b..f5b9cb1 100644 --- a/paginationhelper/_PaginationHelper.xslt +++ b/paginationhelper/_PaginationHelper.xslt @@ -98,8 +98,8 @@ - - + + @@ -320,7 +320,7 @@
- + \ No newline at end of file From 302da851b0f4b10ef50290f14621ec13694d3e76 Mon Sep 17 00:00:00 2001 From: Chriztian Steinmeier Date: Thu, 18 Apr 2013 01:41:44 +0200 Subject: [PATCH 19/19] Update dist/ --- dist/xslt/_CalendarHelper.xslt | 2 +- dist/xslt/_GroupingHelper.xslt | 2 +- dist/xslt/_MediaHelper.xslt | 2 +- dist/xslt/_NavigationHelper.xslt | 2 +- dist/xslt/_PaginationHelper.xslt | 68 +++++++++++++++++-- .../test/PaginationHelperSortedTest.xspec | 4 +- 6 files changed, 70 insertions(+), 10 deletions(-) diff --git a/dist/xslt/_CalendarHelper.xslt b/dist/xslt/_CalendarHelper.xslt index de15591..00010a2 100644 --- a/dist/xslt/_CalendarHelper.xslt +++ b/dist/xslt/_CalendarHelper.xslt @@ -3,7 +3,7 @@ ]> - + diff --git a/dist/xslt/_GroupingHelper.xslt b/dist/xslt/_GroupingHelper.xslt index 253ee84..f81b79f 100644 --- a/dist/xslt/_GroupingHelper.xslt +++ b/dist/xslt/_GroupingHelper.xslt @@ -1,5 +1,5 @@ - + diff --git a/dist/xslt/_MediaHelper.xslt b/dist/xslt/_MediaHelper.xslt index b09c394..00cf395 100644 --- a/dist/xslt/_MediaHelper.xslt +++ b/dist/xslt/_MediaHelper.xslt @@ -8,7 +8,7 @@ Enables simple retrieval of media by handling the GetMedia() call and error-checking --> - + diff --git a/dist/xslt/_NavigationHelper.xslt b/dist/xslt/_NavigationHelper.xslt index 82b6799..bf88227 100644 --- a/dist/xslt/_NavigationHelper.xslt +++ b/dist/xslt/_NavigationHelper.xslt @@ -3,7 +3,7 @@ ]> - + diff --git a/dist/xslt/_PaginationHelper.xslt b/dist/xslt/_PaginationHelper.xslt index 2cbdfd7..52d1617 100644 --- a/dist/xslt/_PaginationHelper.xslt +++ b/dist/xslt/_PaginationHelper.xslt @@ -1,5 +1,5 @@ - + @@ -52,7 +52,10 @@ - + + + + @@ -65,8 +68,25 @@ - - + + + + + + + + + + + + + + + + + + + @@ -242,5 +262,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/paginationhelper/test/PaginationHelperSortedTest.xspec b/paginationhelper/test/PaginationHelperSortedTest.xspec index ece04c3..df35d2e 100644 --- a/paginationhelper/test/PaginationHelperSortedTest.xspec +++ b/paginationhelper/test/PaginationHelperSortedTest.xspec @@ -149,11 +149,11 @@ - + - +

...

...