Skip to content

Commit

Permalink
fix(data-table): do not include page query param when searching (proj…
Browse files Browse the repository at this point in the history
…ectcaluma#302)

The search should take place over all entries and not only for the
ones on the current page.

Co-authored-by: Akanksh Saxena <[email protected]>
  • Loading branch information
aziiee and Akanksh Saxena authored Nov 18, 2021
1 parent 7b5e36d commit 07b027d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
6 changes: 4 additions & 2 deletions addon/components/data-table.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@
{{t "emeis.pagination.previous"}}
</button>
</li>
<li class="uk-active">
{{#if this.numPages}}
<li class="uk-active">
<span data-test-page>
{{this.page}} / {{this.numPages}}
</span>
</li>
</li>
{{/if}}
<li
class={{unless this.nextPage "uk-disabled"}}
data-test-next-page
Expand Down
18 changes: 12 additions & 6 deletions addon/components/data-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,25 @@ export default class DataTableComponent extends Component {
typeof this.args.modelName === "string"
);

const options = {
page: {
number: this.page,
size: this.emeisOptions.pageSize,
},
let options = {
filter: { search: this.search, ...(this.args.filter || {}) },
sort: this.args.sort,
include: this.args.include || "",
};

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.numPages = data.meta.pagination?.pages;

return data;
}
Expand Down

0 comments on commit 07b027d

Please sign in to comment.