2020-02-03 19:27:42 +03:00
|
|
|
import {helper} from '@ember/component/helper';
|
|
|
|
|
|
|
|
export const DEFAULT_QUERY_PARAMS = {
|
|
|
|
posts: {
|
|
|
|
type: null,
|
2020-06-09 14:19:25 +03:00
|
|
|
visibility: null,
|
2020-02-03 19:27:42 +03:00
|
|
|
author: null,
|
|
|
|
tag: null,
|
|
|
|
order: null
|
2020-02-14 12:34:01 +03:00
|
|
|
},
|
2020-05-22 14:47:03 +03:00
|
|
|
pages: {
|
|
|
|
type: null,
|
2020-06-09 14:19:25 +03:00
|
|
|
visibility: null,
|
2020-05-22 14:47:03 +03:00
|
|
|
author: null,
|
|
|
|
tag: null,
|
|
|
|
order: null
|
|
|
|
},
|
2020-02-14 12:34:01 +03:00
|
|
|
'members.index': {
|
2020-05-28 12:15:17 +03:00
|
|
|
label: null,
|
2020-06-12 14:12:27 +03:00
|
|
|
paid: null,
|
2020-06-09 10:48:45 +03:00
|
|
|
search: ''
|
2020-02-03 19:27:42 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// in order to reset query params to their defaults when using <LinkTo> or
|
|
|
|
// `transitionTo` it's necessary to explicitly set each param. This helper makes
|
|
|
|
// it easier to provide a "resetting" link, especially when used with custom views
|
|
|
|
|
|
|
|
export function resetQueryParams(routeName, newParams) {
|
|
|
|
return Object.assign({}, DEFAULT_QUERY_PARAMS[routeName], newParams);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default helper(function (params/*, hash*/) {
|
|
|
|
return resetQueryParams(...params);
|
|
|
|
});
|