@porscheinformatik/clr-addons 12.5.1 → 12.5.2

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.
@@ -5,7 +5,7 @@ import { CommonModule, DOCUMENT } from '@angular/common';
5
5
  import * as i3$1 from '@angular/forms';
6
6
  import { FormsModule, NG_VALIDATORS, NgControl, NG_VALUE_ACCESSOR } from '@angular/forms';
7
7
  import * as i1 from '@clr/angular';
8
- import { ClarityModule, ClrFormsModule, ClrDropdown, ClrForm, ClrAlert, ClrAxis, ClrSide, ClrAlignment, ClrPopoverToggleService, ClrPopoverEventsService, ClrPopoverPositionService, ClrIconModule, ClrDropdownModule } from '@clr/angular';
8
+ import { ClarityModule, ClrFormsModule, ClrDropdown, ClrForm, ClrAlert, ClrAxis, ClrSide, ClrAlignment, ClrPopoverToggleService, ClrPopoverEventsService, ClrPopoverPositionService, ClrIconModule, ClrDropdownModule, ClrDatagridPagination } from '@clr/angular';
9
9
  import { Subject, BehaviorSubject, timer, asyncScheduler, interval, of, ReplaySubject, takeUntil as takeUntil$1 } from 'rxjs';
10
10
  import { takeUntil, observeOn, take } from 'rxjs/operators';
11
11
  import * as i3 from '@angular/router';
@@ -4606,9 +4606,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
4606
4606
  }] } });
4607
4607
 
4608
4608
  class StatePersistenceKeyDirective {
4609
+ ngAfterContentInit() {
4610
+ if (this.pagination && this.pagination.page) {
4611
+ /* persist page size changes in local storage */
4612
+ this.pagination.page.sizeChange.subscribe(pageSize => {
4613
+ let state = JSON.parse(localStorage.getItem(this.clrStatePersistenceKey));
4614
+ if (!state) {
4615
+ state = {};
4616
+ }
4617
+ state.pageSize = pageSize;
4618
+ localStorage.setItem(this.clrStatePersistenceKey, JSON.stringify(state));
4619
+ });
4620
+ /* init page size of datagrid if already persisted in local storage */
4621
+ const state = JSON.parse(localStorage.getItem(this.clrStatePersistenceKey));
4622
+ if (state && state.pageSize) {
4623
+ /* postpone set size to other cycle as it is already set in this change detection cycle */
4624
+ setTimeout(() => (this.pagination.page.size = state.pageSize));
4625
+ }
4626
+ }
4627
+ }
4609
4628
  }
4610
4629
  StatePersistenceKeyDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: StatePersistenceKeyDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
4611
- StatePersistenceKeyDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.8", type: StatePersistenceKeyDirective, selector: "[clrStatePersistenceKey]", inputs: { clrStatePersistenceKey: "clrStatePersistenceKey" }, ngImport: i0 });
4630
+ StatePersistenceKeyDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.8", type: StatePersistenceKeyDirective, selector: "[clrStatePersistenceKey]", inputs: { clrStatePersistenceKey: "clrStatePersistenceKey" }, queries: [{ propertyName: "pagination", first: true, predicate: ClrDatagridPagination, descendants: true }], ngImport: i0 });
4612
4631
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: StatePersistenceKeyDirective, decorators: [{
4613
4632
  type: Directive,
4614
4633
  args: [{
@@ -4616,6 +4635,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
4616
4635
  }]
4617
4636
  }], propDecorators: { clrStatePersistenceKey: [{
4618
4637
  type: Input
4638
+ }], pagination: [{
4639
+ type: ContentChild,
4640
+ args: [ClrDatagridPagination]
4619
4641
  }] } });
4620
4642
 
4621
4643
  class ColumnHiddenStatePersistenceDirective {
@@ -4641,10 +4663,9 @@ class ColumnHiddenStatePersistenceDirective {
4641
4663
  if (persistedGridStateJson !== null) {
4642
4664
  const persistedGridState = JSON.parse(persistedGridStateJson);
4643
4665
  /* read column state if existing */
4644
- const persistedColumnState = persistedGridState[this.columnDirective.clrDgField];
4645
- if (persistedColumnState) {
4666
+ if (persistedGridState.columns && persistedGridState.columns[this.columnDirective.clrDgField]) {
4646
4667
  /* read column hidden state if existing */
4647
- const persistedColumnHiddenState = persistedColumnState.hidden;
4668
+ const persistedColumnHiddenState = persistedGridState.columns[this.columnDirective.clrDgField].hidden;
4648
4669
  if (persistedColumnHiddenState) {
4649
4670
  this.hideableColumnDirective.clrDgHidden = persistedColumnHiddenState === true;
4650
4671
  }
@@ -4660,10 +4681,13 @@ class ColumnHiddenStatePersistenceDirective {
4660
4681
  persistedGridState = JSON.parse(persistedGridStateJson);
4661
4682
  }
4662
4683
  /* read column state if existing */
4663
- let persistedColumnState = persistedGridState[this.columnDirective.clrDgField];
4684
+ if (!persistedGridState.columns) {
4685
+ persistedGridState.columns = {};
4686
+ }
4687
+ let persistedColumnState = persistedGridState.columns[this.columnDirective.clrDgField];
4664
4688
  if (!persistedColumnState) {
4665
4689
  persistedColumnState = {};
4666
- persistedGridState[this.columnDirective.clrDgField] = persistedColumnState;
4690
+ persistedGridState.columns[this.columnDirective.clrDgField] = persistedColumnState;
4667
4691
  }
4668
4692
  /* set column hidden state and persist in local storage */
4669
4693
  persistedColumnState.hidden = hidden;