#18944: Fixing paging in Content Picker

Work Item: 18944

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2012-09-20 18:11:46 -07:00
parent c374528774
commit cda84ffc46
3 changed files with 11 additions and 1 deletions
@@ -45,6 +45,7 @@ namespace Orchard.ContentPicker.Controllers {
? contentTypeDefinition.DisplayName ? contentTypeDefinition.DisplayName
: contentTypeDefinition.Name; : contentTypeDefinition.Name;
query = query.ForType(model.Options.SelectedFilter); query = query.ForType(model.Options.SelectedFilter);
} }
switch (model.Options.OrderBy) { switch (model.Options.OrderBy) {
@@ -79,6 +80,10 @@ namespace Orchard.ContentPicker.Controllers {
.Options(model.Options) .Options(model.Options)
.TypeDisplayName(model.TypeDisplayName ?? ""); .TypeDisplayName(model.TypeDisplayName ?? "");
// retain the parameter in the pager links
RouteData.Values["Options.SelectedFilter"] = model.Options.SelectedFilter;
RouteData.Values["Options.OrderBy"] = model.Options.OrderBy.ToString();
return new ShapeResult(this, Services.New.ContentPicker().Tab(tab)); return new ShapeResult(this, Services.New.ContentPicker().Tab(tab));
} }
@@ -64,9 +64,11 @@
$("ul a").each(function () { $("ul a").each(function () {
var self = $(this); var self = $(this);
var link = self.attr("href"); var link = self.attr("href");
var url = link.split("?");
// if the link doesn't define the "callback" query string, then append it // if the link doesn't define the "callback" query string, then append it
// n.b., pagers already append it // n.b., pagers already append it
if (query("callback", link).length == 0) { if (url.length == 1 || query("callback", "?" + url[1]).length == 0) {
link = link + "?callback=" + query("callback"); link = link + "?callback=" + query("callback");
self.attr("href", link); self.attr("href", link);
} }
@@ -75,6 +75,9 @@ namespace Orchard.Search.Controllers {
item.Metadata.Type = "ContentPicker"; item.Metadata.Type = "ContentPicker";
} }
// retain the parameter in the pager links
RouteData.Values["searchText"] = searchText;
dynamic tab = Services.New.SearchContentTab() dynamic tab = Services.New.SearchContentTab()
.ContentItems(list) .ContentItems(list)
.Pager(pagerShape) .Pager(pagerShape)