FIX: prevents false boolean param to be filtered as non existant (#9968)
* FIX: prevents false boolean param to be filtered as non existant This was preventing to filter top category route to be filtered by replies. * if order is different ascending should be true on first click * test * fix * just pass params * more fixxes
This commit is contained in:
parent
7fe414d35d
commit
d27b877a40
|
@ -61,12 +61,12 @@ export default (filterArg, params) => {
|
||||||
const record = this.store.createRecord("category", result.category);
|
const record = this.store.createRecord("category", result.category);
|
||||||
record.setupGroupsAndPermissions();
|
record.setupGroupsAndPermissions();
|
||||||
this.site.updateCategory(record);
|
this.site.updateCategory(record);
|
||||||
return { category: record };
|
return { category: record, modelParams };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (category) {
|
if (category) {
|
||||||
return { category };
|
return { category, modelParams };
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ export default (filterArg, params) => {
|
||||||
this._setupNavigation(model.category);
|
this._setupNavigation(model.category);
|
||||||
return all([
|
return all([
|
||||||
this._createSubcategoryList(model.category),
|
this._createSubcategoryList(model.category),
|
||||||
this._retrieveTopicList(model.category, transition)
|
this._retrieveTopicList(model.category, transition, model.modelParams)
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -113,11 +113,11 @@ export default (filterArg, params) => {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
},
|
},
|
||||||
|
|
||||||
_retrieveTopicList(category, transition) {
|
_retrieveTopicList(category, transition, modelParams) {
|
||||||
const listFilter = `c/${Category.slugFor(category)}/${
|
const listFilter = `c/${Category.slugFor(category)}/${
|
||||||
category.id
|
category.id
|
||||||
}/l/${this.filter(category)}`,
|
}/l/${this.filter(category)}`,
|
||||||
findOpts = filterQueryParams(transition.to.queryParams, params),
|
findOpts = filterQueryParams(modelParams),
|
||||||
extras = { cached: this.isPoppedState(transition) };
|
extras = { cached: this.isPoppedState(transition) };
|
||||||
|
|
||||||
return findTopicList(
|
return findTopicList(
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { isEmpty } from "@ember/utils";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import DiscourseRoute from "discourse/routes/discourse";
|
import DiscourseRoute from "discourse/routes/discourse";
|
||||||
import { queryParams } from "discourse/controllers/discovery-sortable";
|
import { queryParams } from "discourse/controllers/discovery-sortable";
|
||||||
|
@ -12,7 +13,7 @@ function filterQueryParams(params, defaultParams) {
|
||||||
|
|
||||||
if (params) {
|
if (params) {
|
||||||
Object.keys(queryParams).forEach(function(opt) {
|
Object.keys(queryParams).forEach(function(opt) {
|
||||||
if (params[opt]) {
|
if (!isEmpty(params[opt])) {
|
||||||
findOpts[opt] = params[opt];
|
findOpts[opt] = params[opt];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -50,10 +51,12 @@ function findTopicList(store, tracking, filter, filterParams, extras) {
|
||||||
|
|
||||||
// Clean up any string parameters that might slip through
|
// Clean up any string parameters that might slip through
|
||||||
filterParams = filterParams || {};
|
filterParams = filterParams || {};
|
||||||
Object.keys(filterParams).forEach(function(k) {
|
Object.keys(filterParams).forEach(k => {
|
||||||
const val = filterParams[k];
|
let val = filterParams[k];
|
||||||
if (val === "undefined" || val === "null" || val === "false") {
|
if (val === "false") val = false;
|
||||||
filterParams[k] = undefined;
|
if (val === "true") val = true;
|
||||||
|
if (val === "undefined" || val === "null") {
|
||||||
|
filterParams[k] = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue