@onehat/data 1.4.7 → 1.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -372,6 +372,19 @@ describe('Repository Base', function() {
|
|
|
372
372
|
expect(didFireChangeFilters).to.be.true;
|
|
373
373
|
});
|
|
374
374
|
|
|
375
|
+
it('changing filters resets pagination', function() {
|
|
376
|
+
this.repository.isPaginated = true;
|
|
377
|
+
this.repository.setPageSize(1);
|
|
378
|
+
this.repository.setPage(3);
|
|
379
|
+
|
|
380
|
+
this.repository.setFilters({
|
|
381
|
+
b: '1',
|
|
382
|
+
c: '2',
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
expect(this.repository.page).to.be.eq(1);
|
|
386
|
+
});
|
|
387
|
+
|
|
375
388
|
});
|
|
376
389
|
|
|
377
390
|
describe('pagination', function() {
|
|
@@ -471,6 +484,18 @@ describe('Repository Base', function() {
|
|
|
471
484
|
expect(results.pageTotal).to.be.eq(1);
|
|
472
485
|
});
|
|
473
486
|
|
|
487
|
+
it('reset pagination', function() {
|
|
488
|
+
expect(this.repository.page).to.be.eq(1);
|
|
489
|
+
|
|
490
|
+
this.repository.isPaginated = true;
|
|
491
|
+
this.repository.setPageSize(1);
|
|
492
|
+
this.repository.setPage(3);
|
|
493
|
+
expect(this.repository.page).to.be.eq(3);
|
|
494
|
+
|
|
495
|
+
this.repository.resetPagination();
|
|
496
|
+
expect(this.repository.page).to.be.eq(1);
|
|
497
|
+
});
|
|
498
|
+
|
|
474
499
|
});
|
|
475
500
|
|
|
476
501
|
describe('creating', function() {
|
package/package.json
CHANGED
|
@@ -648,6 +648,7 @@ export default class Repository extends EventEmitter {
|
|
|
648
648
|
if (!_.isEqual(this.filters, filters)) {
|
|
649
649
|
isChanged = true;
|
|
650
650
|
this.filters = filters;
|
|
651
|
+
this.resetPagination();
|
|
651
652
|
this.emit('changeFilters');
|
|
652
653
|
if (this._onChangeFilters) {
|
|
653
654
|
return this._onChangeFilters();
|
|
@@ -666,6 +667,17 @@ export default class Repository extends EventEmitter {
|
|
|
666
667
|
// /_/ \__,_/\__, /_/_/ /_/\__,_/\__/\___/
|
|
667
668
|
// /____/
|
|
668
669
|
|
|
670
|
+
/**
|
|
671
|
+
* Resets the pagination to page one
|
|
672
|
+
* @fires changePageSize
|
|
673
|
+
*/
|
|
674
|
+
resetPagination = (pageSize) => {
|
|
675
|
+
if (this.isDestroyed) {
|
|
676
|
+
throw Error('this.resetPagination is no longer valid. Repository has been destroyed.');
|
|
677
|
+
}
|
|
678
|
+
this.setPage(1);
|
|
679
|
+
}
|
|
680
|
+
|
|
669
681
|
/**
|
|
670
682
|
* Sets the pageSize
|
|
671
683
|
* @fires changePageSize
|