From 9fcf542b5c2beefec0ab142b117b18b947ca3089 Mon Sep 17 00:00:00 2001 From: Yoshihiro OKUMURA Date: Mon, 13 May 2019 23:54:12 +0900 Subject: [PATCH] move to page 1 if order by changed. --- src/components/database/DatabaseListItem.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/database/DatabaseListItem.tsx b/src/components/database/DatabaseListItem.tsx index d99b3fc..1720cbe 100644 --- a/src/components/database/DatabaseListItem.tsx +++ b/src/components/database/DatabaseListItem.tsx @@ -73,15 +73,15 @@ class DatabaseListItem extends Component { } 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));