From 43c6a28313c80b4df936ea88d33982731447cba0 Mon Sep 17 00:00:00 2001 From: Falk Neumann Date: Mon, 8 Aug 2022 11:44:25 +0200 Subject: [PATCH] fix(data-table): always include page meta info (#544) --- addon/components/data-table.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/addon/components/data-table.js b/addon/components/data-table.js index 63db49cc..be78af13 100644 --- a/addon/components/data-table.js +++ b/addon/components/data-table.js @@ -96,22 +96,16 @@ export default class DataTableComponent extends Component { includes = this.args.include.join(","); } - let options = { + const options = { + include: includes, filter: { search: this.search, ...(this.args.filter || {}) }, sort: this.sort, - include: includes, + page: { + number: this.page, + size: this.emeisOptions.pageSize, + }, }; - if (!this.search) { - options = { - ...options, - page: { - number: this.page, - size: this.emeisOptions.pageSize, - }, - }; - } - const data = yield this.store.query(this.args.modelName, options); this.numPages = data.meta.pagination?.pages; this.entryCount = data.meta.pagination?.count; @@ -152,6 +146,8 @@ export default class DataTableComponent extends Component { // Prevent reload because of form submit submitEvent.preventDefault(); this.search = submitEvent.target.elements.search.value; + // changing search may change the number of pages, therefore navigate to first page + this.page = 1; } @action