Skip to content

Fix default sort option on inital load & slice changing #32

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
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions PowerSlice/Scripts/Components/ContentSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ define([
this._set("hideSortOptions", hide);
},


_reloadQuery: function (delay) {
var supermethod = this.getInherited(arguments);
if(this.reloadInterval) {
Expand All @@ -175,9 +176,20 @@ define([
newQuery = this._getQuery(newQueryName),
selectionChanged = newQueryName !== this.contentQuery.get("queryName");

if (selectionChanged) {
// Set the sort and order based on the defaults
if (newQuery.defaultSortOption) {
this.sortKey = newQuery.defaultSortOption.key;
this.orderDescending = newQuery.defaultSortOption.orderDescending;
} else {
this.sortKey = null;
this.orderDescending = false;
}
}

// Set parameters for contentQuery
this.contentQuery.set("sortKey", this.sortKey || null);
this.contentQuery.set("descending", this.sortKey ? this.orderDescending : false);
this.contentQuery.set("sortKey", this.sortKey);
this.contentQuery.set("descending", this.orderDescending);
this.contentQuery.set("queryParameters", { q: this.queryText ? this.queryText.get("value") : "" });

if(selectionChanged && this.sortButton) {
Expand All @@ -187,7 +199,6 @@ define([
this.set("sortOptions", newQuery.sortOptions);
this.set("hideSortOptions", newQuery.hideSortOptions);


// Set default sort options as active
if (newQuery.defaultSortOption) {
this.sortButton.set("attribute", newQuery.defaultSortOption.key);
Expand Down