From 7ef15b3a32e9a804a8b4fc93798f6d6b133153bf Mon Sep 17 00:00:00 2001 From: jacobjones Date: Tue, 13 Aug 2019 14:34:53 -0400 Subject: [PATCH] Fix default sort option on inital load & slice changing --- PowerSlice/Scripts/Components/ContentSlice.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/PowerSlice/Scripts/Components/ContentSlice.js b/PowerSlice/Scripts/Components/ContentSlice.js index f54c89a..42f8409 100644 --- a/PowerSlice/Scripts/Components/ContentSlice.js +++ b/PowerSlice/Scripts/Components/ContentSlice.js @@ -165,6 +165,7 @@ define([ this._set("hideSortOptions", hide); }, + _reloadQuery: function (delay) { var supermethod = this.getInherited(arguments); if(this.reloadInterval) { @@ -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) { @@ -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);