move to page 1 if order by changed.
This commit is contained in:
@@ -73,15 +73,15 @@ class DatabaseListItem extends Component<Props, State> {
|
||||
}
|
||||
|
||||
getListUrl(query: { orderby?: string, order_dir?: number, limit?: number, page?: number }) {
|
||||
const newOrderby: string = typeof query.orderby !== 'undefined' ? query.orderby : this.state.condition.orderBy;
|
||||
const newOrderBy: string = typeof query.orderby !== 'undefined' ? query.orderby : this.state.condition.orderBy;
|
||||
const newOrderDir: number = typeof query.order_dir !== 'undefined' ? query.order_dir : this.state.condition.orderDir;
|
||||
const newLimit: number = typeof query.limit !== 'undefined' ? query.limit : this.state.condition.limit;
|
||||
let newPage: number = typeof query.page !== 'undefined' ? query.page : this.state.condition.page;
|
||||
if (newLimit !== this.state.condition.limit) {
|
||||
if (newLimit !== this.state.condition.limit || newOrderBy !== this.state.condition.orderBy) {
|
||||
newPage = SORT_CONDITION_DEFAULT.page;
|
||||
}
|
||||
let params: string[] = [];
|
||||
params.push('orderby=' + newOrderby);
|
||||
params.push('orderby=' + newOrderBy);
|
||||
params.push('order_dir=' + String(newOrderDir));
|
||||
params.push('itemcount=' + String(newLimit));
|
||||
params.push('page=' + String(newPage));
|
||||
|
||||
Reference in New Issue
Block a user