@porscheinformatik/clr-addons 19.11.0 → 19.11.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.
@@ -1,9 +1,10 @@
1
- import { ElementRef, EventEmitter } from '@angular/core';
1
+ import { ElementRef, EventEmitter, OnDestroy } from '@angular/core';
2
2
  import { ClrDatagrid } from '@clr/angular';
3
3
  import { ExportDatagridService } from './export-datagrid.service';
4
4
  import { ExportType, ExportTypeEnum } from './export-type.model';
5
+ import { Subject } from 'rxjs';
5
6
  import * as i0 from "@angular/core";
6
- export declare class ExportDatagridButtonComponent {
7
+ export declare class ExportDatagridButtonComponent implements OnDestroy {
7
8
  private readonly exportService;
8
9
  datagrid: import("@angular/core").InputSignal<ClrDatagrid<any>>;
9
10
  datagridRef: import("@angular/core").InputSignal<ElementRef<any>>;
@@ -13,6 +14,7 @@ export declare class ExportDatagridButtonComponent {
13
14
  exportButtonPosition: import("@angular/core").InputSignal<"right" | "left">;
14
15
  possibleExportTypes: import("@angular/core").WritableSignal<ExportTypeEnum[]>;
15
16
  exportButtonText: import("@angular/core").InputSignal<string>;
17
+ destroy$: Subject<void>;
16
18
  readonly backendExport: EventEmitter<ExportTypeEnum>;
17
19
  readonly exportTypes: ExportType[];
18
20
  readonly exportTypesFiltered: import("@angular/core").Signal<{
@@ -20,6 +22,7 @@ export declare class ExportDatagridButtonComponent {
20
22
  value: string;
21
23
  }[]>;
22
24
  constructor(exportService: ExportDatagridService);
25
+ ngOnDestroy(): void;
23
26
  private exportExcel;
24
27
  onExport(type: ExportTypeEnum): void;
25
28
  /**
@@ -15458,6 +15458,7 @@ class ExportDatagridButtonComponent {
15458
15458
  this.exportButtonPosition = input('right');
15459
15459
  this.possibleExportTypes = signal([ExportTypeEnum.ALL]);
15460
15460
  this.exportButtonText = input('EXPORT');
15461
+ this.destroy$ = new Subject();
15461
15462
  /* outputs */
15462
15463
  this.backendExport = new EventEmitter();
15463
15464
  this.exportTypes = [
@@ -15466,23 +15467,10 @@ class ExportDatagridButtonComponent {
15466
15467
  { type: ExportTypeEnum.SELECTED, value: 'Selected entries' },
15467
15468
  ];
15468
15469
  this.exportTypesFiltered = computed(() => {
15469
- this.possibleExportTypes();
15470
15470
  let exportTypesToShowVal = this.exportTypesToShow();
15471
15471
  if (!exportTypesToShowVal || exportTypesToShowVal.length === 0) {
15472
15472
  exportTypesToShowVal = this.exportTypes;
15473
15473
  }
15474
- for (const column of this.datagrid().columns) {
15475
- // if a column filter is applied, show the FILTERED export type
15476
- column.filterValueChange.subscribe((col) => {
15477
- this.updateExportType(ExportTypeEnum.FILTERED, !!col, exportTypesToShowVal);
15478
- });
15479
- }
15480
- this.datagrid().selectedChanged.subscribe(() => {
15481
- const hasSelection = this.datagrid().selection.current.length > 0;
15482
- // if a row is selected, show the SELECTED export type
15483
- this.updateExportType(ExportTypeEnum.SELECTED, hasSelection, exportTypesToShowVal);
15484
- });
15485
- // Map to translated value, falling back to default if value is not provided
15486
15474
  return exportTypesToShowVal
15487
15475
  .filter(showType => this.possibleExportTypes().some(et => et === showType.type))
15488
15476
  .map(showType => {
@@ -15493,6 +15481,25 @@ class ExportDatagridButtonComponent {
15493
15481
  };
15494
15482
  });
15495
15483
  });
15484
+ effect(() => {
15485
+ const datagrid = this.datagrid();
15486
+ if (!datagrid) {
15487
+ return undefined;
15488
+ }
15489
+ this.destroy$.next();
15490
+ datagrid.refresh.pipe(delay(0), takeUntil(this.destroy$)).subscribe(dgState => {
15491
+ const hasFilter = dgState.filters && dgState.filters.length > 0;
15492
+ this.updateExportType(ExportTypeEnum.FILTERED, hasFilter, this.exportTypesToShow() || this.exportTypes);
15493
+ });
15494
+ datagrid.selectedChanged.pipe(takeUntil(this.destroy$)).subscribe(() => {
15495
+ const hasSelection = datagrid.selection.current.length > 0;
15496
+ this.updateExportType(ExportTypeEnum.SELECTED, hasSelection, this.exportTypesToShow() || this.exportTypes);
15497
+ });
15498
+ });
15499
+ }
15500
+ ngOnDestroy() {
15501
+ this.destroy$.next();
15502
+ this.destroy$.complete();
15496
15503
  }
15497
15504
  exportExcel(type) {
15498
15505
  if (!this.datagrid() || !this.datagridRef()) {