Add a resetPagination method to the searchable mixin

Searchable can be used without pagination, but reseting pagination
is more a function of search than pagination insofar as if you
add search to a page, you are also going to want automatic pagination
resetting.
This commit is contained in:
Michael Lange
2018-10-30 10:50:50 -07:00
parent badb6c42d0
commit f7ad2ce8bb

View File

@@ -36,6 +36,16 @@ export default Mixin.create({
fuzzySearchEnabled: false,
regexEnabled: true,
// Search should reset pagination. Not every instance of
// search will be paired with pagination, but it's still
// preferable to generalize this rather than risking it being
// forgotten on a single page.
resetPagination() {
if (this.get('currentPage') != null) {
this.set('currentPage', 1);
}
},
fuse: computed('listToSearch.[]', 'fuzzySearchProps.[]', function() {
return new Fuse(this.get('listToSearch'), {
shouldSort: true,