@one-paragon/angular-utilities 2.2.7 → 2.2.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.
@@ -6,7 +6,7 @@ import { isObservable, Subject, of, ReplaySubject, filter as filter$1, first, ma
6
6
  import { toObservable, toSignal, outputFromObservable } from '@angular/core/rxjs-interop';
7
7
  import * as i3$2 from '@angular/material/sort';
8
8
  import { MatSort, MatSortModule } from '@angular/material/sort';
9
- import { merge as merge$1, sumBy, difference, groupBy, intersection, set, get } from 'lodash';
9
+ import { merge as merge$1, sumBy, difference, groupBy, cloneDeep, intersection, set, get } from 'lodash';
10
10
  import { CdkColumnDef } from '@angular/cdk/table';
11
11
  import { coerceBooleanProperty } from '@angular/cdk/coercion';
12
12
  import { MatSlideToggle } from '@angular/material/slide-toggle';
@@ -4545,19 +4545,30 @@ class ExportToCsvService {
4545
4545
  const globalSettings = this.config?.defaultTableSettings?.tableSettings?.exportSettings
4546
4546
  || this.config?.export
4547
4547
  || {};
4548
- const globalLinkOptions = globalSettings.mapLinkOptions || {};
4549
- const flattenedGlobal = { ...globalSettings, ...globalLinkOptions };
4550
4548
  const tableSettings = (this.state.$notPersistedTableSettings()?.exportSettings || {});
4551
- const tableLinkOptions = tableSettings.mapLinkOptions || {};
4552
- const flattenedTable = { ...tableSettings, ...tableLinkOptions };
4553
- return merge$1(flattenedGlobal, flattenedTable);
4549
+ return merge$1({}, globalSettings, tableSettings);
4554
4550
  });
4555
4551
  this.exportToCsv = (data) => {
4556
4552
  const hiddenKeys = this.state.selectSignal(s => s.hiddenKeys)();
4557
4553
  const meta = this.state.$metaDataArray().filter(md => !md.noExport && !hiddenKeys.includes(md.key));
4558
- const csv = this.csvData(data, meta);
4554
+ const extraLinkCols = this.getExtraLinkCols(meta);
4555
+ const csv = this.csvData(data, [...meta, ...extraLinkCols]);
4559
4556
  downloadData(csv, 'export.csv', 'text/csv');
4560
4557
  };
4558
+ this.getExtraLinkCols = (meta) => {
4559
+ return meta.filter(md => {
4560
+ if (!md.additional?.link)
4561
+ return;
4562
+ const exportForCol = merge$1({}, this.$exportSettings(), md.additional?.export);
4563
+ return exportForCol.mapLink === 'add link';
4564
+ }).map(md => {
4565
+ const newCol = cloneDeep(md);
4566
+ newCol.additional.export ??= {};
4567
+ newCol.additional.export.mapLink = "as link",
4568
+ newCol.displayName = newCol.additional.export.linkColumnName || ((newCol.displayName || newCol.key) + ' - (Link)');
4569
+ return newCol;
4570
+ });
4571
+ };
4561
4572
  this.csvData = (data, metaData) => {
4562
4573
  const res = data.map(row => metaData.map(meta => this.metaToField(meta, row)).join(','));
4563
4574
  res.unshift(metaData.map(meta => meta.displayName || meta.key).join(','));
@@ -4575,15 +4586,13 @@ class ExportToCsvService {
4575
4586
  const transform = meta.transform;
4576
4587
  return isPipe(transform) ? transform.transform(val) : transform(val);
4577
4588
  }
4578
- if (meta.additional?.link && exportForCol.mapLinkToString) {
4589
+ if (meta.additional?.link && exportForCol.mapLink === 'as link') {
4579
4590
  let mapper = this.state.$getLinkInfo(meta)()?.link;
4580
4591
  if (mapper) {
4581
4592
  let mapped = mapper(row);
4582
4593
  if (exportForCol.domainPrefix) {
4583
- mapped = `${exportForCol.domainPrefix}/${mapped}`;
4584
- }
4585
- if (exportForCol.excellStyle) {
4586
- mapped = this.cleanValForCsv(`=hyperlink("${mapped}", "${this.stringByType(meta, row, val, exportForCol)}")`);
4594
+ const bet = mapped.startsWith('/') ? '' : '/';
4595
+ mapped = `${exportForCol.domainPrefix}${bet}${mapped}`;
4587
4596
  }
4588
4597
  return mapped;
4589
4598
  }