adb-shared 5.0.36 → 5.0.38
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.
- package/esm2020/lib/components/pagers/pager-base.directive.mjs +36 -21
- package/fesm2015/adb-shared.mjs +35 -20
- package/fesm2015/adb-shared.mjs.map +1 -1
- package/fesm2020/adb-shared.mjs +35 -20
- package/fesm2020/adb-shared.mjs.map +1 -1
- package/lib/components/pagers/pager-base.directive.d.ts +4 -2
- package/package.json +1 -1
package/fesm2020/adb-shared.mjs
CHANGED
|
@@ -429,27 +429,40 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
|
|
|
429
429
|
|
|
430
430
|
class PagerBaseDirective {
|
|
431
431
|
constructor() {
|
|
432
|
-
this.limit = PagerBaseDirective.DEFAULT_LIMIT;
|
|
432
|
+
this.limit = PagerBaseDirective.DEFAULT_LIMIT;
|
|
433
433
|
this.currentPage = 1;
|
|
434
434
|
}
|
|
435
|
+
set setTotalCount(value) {
|
|
436
|
+
this.totalCount = value;
|
|
437
|
+
this.calculatePages();
|
|
438
|
+
}
|
|
439
|
+
set setLimit(value) {
|
|
440
|
+
this.limit = value ?? PagerBaseDirective.DEFAULT_LIMIT;
|
|
441
|
+
this.calculatePages();
|
|
442
|
+
}
|
|
435
443
|
calculatePages() {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
this.
|
|
439
|
-
this.
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
444
|
+
if (this.totalCount >= 0 && this.limit > 0) {
|
|
445
|
+
this.amountOfPages = Math.ceil(this.totalCount / this.limit);
|
|
446
|
+
if ((this.currentPage + 1) > PagerBaseDirective.VISIBLE_PAGES) {
|
|
447
|
+
this.pages = [
|
|
448
|
+
this.currentPage - 2,
|
|
449
|
+
this.currentPage - 1, this.currentPage
|
|
450
|
+
];
|
|
451
|
+
const above = this.amountOfPages - this.currentPage;
|
|
452
|
+
if (above >= 1) {
|
|
453
|
+
this.pages.push(this.currentPage + 1);
|
|
454
|
+
}
|
|
455
|
+
if (above >= 2) {
|
|
456
|
+
this.pages.push(this.currentPage + 2);
|
|
457
|
+
}
|
|
445
458
|
}
|
|
446
|
-
if (
|
|
447
|
-
this.
|
|
459
|
+
else if (this.totalCount) {
|
|
460
|
+
const max = this.amountOfPages > PagerBaseDirective.VISIBLE_PAGES ? 5 : this.amountOfPages;
|
|
461
|
+
this.pages = Array(Math.ceil(max)).fill(1).map((x, i) => i + 1);
|
|
448
462
|
}
|
|
449
463
|
}
|
|
450
|
-
else
|
|
451
|
-
|
|
452
|
-
this.pages = Array(Math.ceil(max)).fill(1).map((x, i) => i + 1);
|
|
464
|
+
else {
|
|
465
|
+
this.amountOfPages = 0;
|
|
453
466
|
}
|
|
454
467
|
}
|
|
455
468
|
}
|
|
@@ -457,13 +470,15 @@ PagerBaseDirective.DEFAULT_LIMIT = 10;
|
|
|
457
470
|
PagerBaseDirective.VISIBLE_PAGES = 5;
|
|
458
471
|
PagerBaseDirective.SKIP_RESOURCE = 'offset';
|
|
459
472
|
/** @nocollapse */ PagerBaseDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: PagerBaseDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
460
|
-
/** @nocollapse */ PagerBaseDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.8", type: PagerBaseDirective, inputs: {
|
|
473
|
+
/** @nocollapse */ PagerBaseDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.8", type: PagerBaseDirective, inputs: { setTotalCount: ["totalCount", "setTotalCount"], setLimit: ["limit", "setLimit"] }, ngImport: i0 });
|
|
461
474
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: PagerBaseDirective, decorators: [{
|
|
462
475
|
type: Directive
|
|
463
|
-
}], propDecorators: {
|
|
464
|
-
type: Input
|
|
465
|
-
|
|
466
|
-
|
|
476
|
+
}], propDecorators: { setTotalCount: [{
|
|
477
|
+
type: Input,
|
|
478
|
+
args: ['totalCount']
|
|
479
|
+
}], setLimit: [{
|
|
480
|
+
type: Input,
|
|
481
|
+
args: ['limit']
|
|
467
482
|
}] } });
|
|
468
483
|
|
|
469
484
|
class PagerComponent extends PagerBaseDirective {
|