mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 13:54:35 +03:00
Fixed sending of empty search param in members browse requests
no issue - when the search param was empty we were still adding a `?search=` query param to the API request
This commit is contained in:
parent
514034d329
commit
bdd874c01b
@ -25,7 +25,9 @@ export default class MembersRoute extends AuthenticatedRoute {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model(params) {
|
model(params) {
|
||||||
if (!params.searchParam) {
|
const {label, searchParam} = params;
|
||||||
|
|
||||||
|
if (!searchParam) {
|
||||||
this.controllerFor('members').resetSearch();
|
this.controllerFor('members').resetSearch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,9 +35,9 @@ export default class MembersRoute extends AuthenticatedRoute {
|
|||||||
let startDate = new Date();
|
let startDate = new Date();
|
||||||
|
|
||||||
// bypass the stale data shortcut if params change
|
// bypass the stale data shortcut if params change
|
||||||
let forceReload = params.label !== this._lastLabel || params.searchParam !== this._lastSearchParam;
|
let forceReload = label !== this._lastLabel || searchParam !== this._lastSearchParam;
|
||||||
this._lastLabel = params.label;
|
this._lastLabel = label;
|
||||||
this._lastSearchParam = params.searchParam;
|
this._lastSearchParam = searchParam;
|
||||||
|
|
||||||
// unless we have a forced reload, do not re-fetch the members list unless it's more than a minute old
|
// unless we have a forced reload, do not re-fetch the members list unless it's more than a minute old
|
||||||
// keeps navigation between list->details->list snappy
|
// keeps navigation between list->details->list snappy
|
||||||
@ -46,15 +48,15 @@ export default class MembersRoute extends AuthenticatedRoute {
|
|||||||
this._startDate = startDate;
|
this._startDate = startDate;
|
||||||
|
|
||||||
return this.ellaSparse.array((range = {}, query = {}) => {
|
return this.ellaSparse.array((range = {}, query = {}) => {
|
||||||
const labelFilter = params.label ? `label:'${params.label}'+` : '';
|
const labelFilter = label ? `label:'${label}'+` : '';
|
||||||
|
const searchQuery = searchParam ? {search: searchParam} : {};
|
||||||
|
|
||||||
query = Object.assign({
|
query = Object.assign({
|
||||||
limit: range.length,
|
limit: range.length,
|
||||||
page: range.start / range.length,
|
page: range.start / range.length,
|
||||||
order: 'created_at desc',
|
order: 'created_at desc',
|
||||||
filter: `${labelFilter}created_at:<='${moment.utc(this._startDate).format('YYYY-MM-DD HH:mm:ss')}'`,
|
filter: `${labelFilter}created_at:<='${moment.utc(this._startDate).format('YYYY-MM-DD HH:mm:ss')}'`
|
||||||
search: params.searchParam
|
}, searchQuery, query);
|
||||||
}, query);
|
|
||||||
|
|
||||||
return this.store.query('member', query).then((result) => {
|
return this.store.query('member', query).then((result) => {
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user