@esfaenza/extensions 14.2.0 → 14.3.0

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,9 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, NgModule, Injectable, Optional, Inject } from '@angular/core';
2
+ import { InjectionToken, NgModule, Injector, Injectable, Inject, Optional } from '@angular/core';
3
3
  import swal from 'sweetalert2';
4
+ import { ToastrService } from 'ngx-toastr';
4
5
  import { of, Subject } from 'rxjs';
5
6
  import { map } from 'rxjs/operators';
6
- import * as i1 from 'ngx-toastr';
7
7
  import { Deserialize } from 'cerialize';
8
8
 
9
9
  /**
@@ -40,10 +40,10 @@ class ExtensionsModule {
40
40
  };
41
41
  }
42
42
  }
43
- ExtensionsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ExtensionsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
44
- ExtensionsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.12", ngImport: i0, type: ExtensionsModule });
45
- ExtensionsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ExtensionsModule });
46
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ExtensionsModule, decorators: [{
43
+ ExtensionsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ExtensionsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
44
+ ExtensionsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: ExtensionsModule });
45
+ ExtensionsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ExtensionsModule });
46
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ExtensionsModule, decorators: [{
47
47
  type: NgModule
48
48
  }] });
49
49
 
@@ -57,8 +57,8 @@ class MessageService {
57
57
  *
58
58
  * @ignore
59
59
  */
60
- constructor(toastr, FANCY_ALERTS, LOCALE) {
61
- this.toastr = toastr;
60
+ constructor(injector, FANCY_ALERTS, LOCALE) {
61
+ this.injector = injector;
62
62
  this.FANCY_ALERTS = FANCY_ALERTS;
63
63
  this.LOCALE = LOCALE;
64
64
  /**
@@ -85,6 +85,20 @@ class MessageService {
85
85
  allowOutsideClick: false,
86
86
  icon: "warning"
87
87
  });
88
+ this.successSwalWithCancel = swal.mixin({
89
+ title: this.loc["Success"][this.LOCALE ?? 'it-IT'],
90
+ customClass: {
91
+ confirmButton: "btn btn-primary",
92
+ cancelButton: "btn btn-secondary app-margin-right-10",
93
+ container: "app-wrap",
94
+ },
95
+ buttonsStyling: false,
96
+ reverseButtons: true,
97
+ showCancelButton: true,
98
+ confirmButtonText: this.loc["Confirm"][this.LOCALE ?? 'it-IT'],
99
+ cancelButtonText: this.loc["Cancel"][this.LOCALE ?? 'it-IT'],
100
+ icon: "success"
101
+ });
88
102
  this.warningSwalWithCancel = swal.mixin({
89
103
  title: this.loc["Warning"][this.LOCALE ?? 'it-IT'],
90
104
  customClass: {
@@ -148,6 +162,9 @@ class MessageService {
148
162
  icon: "info"
149
163
  });
150
164
  }
165
+ get toastr() {
166
+ return this.injector.get(ToastrService);
167
+ }
151
168
  /**
152
169
  * Presentazione di un semplice messaggio di successo
153
170
  *
@@ -258,6 +275,32 @@ class MessageService {
258
275
  onerror();
259
276
  });
260
277
  }
278
+ /**
279
+ * Mostra un messaggio di success con richiesta di conferma e gestisce il risultato chiamato i callback **onconfirm** o **onabort**
280
+ *
281
+ * @param {string} title Titolo del messaggio
282
+ * @param {string} text Contenuto del messaggio
283
+ * @param {Function} onconfirm Callback da chimare su conferma
284
+ * @param {Function} onabort Callback da chimare su annullamento
285
+ * @param {string} confirmtext Testo del pulsante di azione
286
+ * @param {string} aborttext Testo del pulsante di annullamento
287
+ */
288
+ simpleSuccessWithChoice(title, text, onconfirm = null, onabort = null, confirmtext = "", aborttext = '') {
289
+ var configuration = {
290
+ title: title,
291
+ html: text
292
+ };
293
+ if (confirmtext)
294
+ configuration["confirmButtonText"] = confirmtext;
295
+ if (aborttext)
296
+ configuration["cancelButtonText"] = aborttext;
297
+ this.successSwalWithCancel.fire(configuration).then((result) => {
298
+ if (result.value && onconfirm)
299
+ onconfirm();
300
+ else if (onabort)
301
+ onabort();
302
+ });
303
+ }
261
304
  /**
262
305
  * Mostra un messaggio di avviso con richiesta di conferma e gestisce il risultato chiamato i callback **onsuccess** o **onerror**
263
306
  *
@@ -299,8 +342,8 @@ class MessageService {
299
342
  if (postSuccess)
300
343
  postSuccess();
301
344
  }
302
- else if (response.haserror) {
303
- this.simpleError((errorMsg ? errorMsg + ": " : "") + response.error);
345
+ else {
346
+ this.simpleError((errorMsg ? errorMsg + ": " : "") + response.haserror ? response.error : '[NO ERR.]');
304
347
  if (postFailure)
305
348
  postFailure();
306
349
  }
@@ -356,11 +399,14 @@ class MessageService {
356
399
  }
357
400
  }
358
401
  }
359
- MessageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: MessageService, deps: [{ token: i1.ToastrService }, { token: EXT_FANCY_ALERTS, optional: true }, { token: EXT_LOCALE, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
360
- MessageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: MessageService });
361
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: MessageService, decorators: [{
402
+ MessageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: MessageService, deps: [{ token: Injector }, { token: EXT_FANCY_ALERTS, optional: true }, { token: EXT_LOCALE, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
403
+ MessageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: MessageService });
404
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: MessageService, decorators: [{
362
405
  type: Injectable
363
- }], ctorParameters: function () { return [{ type: i1.ToastrService }, { type: undefined, decorators: [{
406
+ }], ctorParameters: function () { return [{ type: i0.Injector, decorators: [{
407
+ type: Inject,
408
+ args: [Injector]
409
+ }] }, { type: undefined, decorators: [{
364
410
  type: Optional
365
411
  }, {
366
412
  type: Inject,
@@ -404,7 +450,27 @@ class ClipboardService {
404
450
  "Error during Clipboard content copy operation": {
405
451
  'en-US': "Error during Clipboard content copy operation",
406
452
  'it-IT': "Errore nella scrittura del contenuto nella Clipboard"
407
- }
453
+ },
454
+ "Please insert your clipboard content": {
455
+ 'en-US': "Please insert your clipboard content",
456
+ 'it-IT': "Si prega di incollare il contenuto della Clipboard"
457
+ },
458
+ "User input required": {
459
+ 'en-US': "User input required",
460
+ 'it-IT': "Richiesto Input utente"
461
+ },
462
+ "Your current browser does not support reading from the clipboard directly. Please paste your clipboard's content in this Input field and confirm the operation": {
463
+ 'en-US': "Your current browser does not support reading from the clipboard directly. Please paste your clipboard's content in this Input field and confirm the operation",
464
+ 'it-IT': "Il browser corrente non supporta la lettura diretta dei dati della Clipboard, si prega di effettuare un'incolla (CTRL + V) nella casella di testo e confermare l'operazione"
465
+ },
466
+ "Confirm": {
467
+ 'en-US': "Confirm",
468
+ 'it-IT': "Conferma"
469
+ },
470
+ "Cancel": {
471
+ 'en-US': "Cancel",
472
+ 'it-IT': "Annulla"
473
+ },
408
474
  };
409
475
  }
410
476
  /**
@@ -416,35 +482,63 @@ class ClipboardService {
416
482
  */
417
483
  getClipboard(style, valueFoundCallback) {
418
484
  if (navigator.userAgent.indexOf("Firefox") != -1) {
419
- //https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/readText
420
- this.msgService.simpleError(this.loc["Unfortunately Firefox doesn't yet support direct Clipboard access if not via extensions, Please use Chrome to do this operation"][this.LOCALE ?? 'it-IT']);
485
+ swal.fire({
486
+ title: this.loc["User input required"][this.LOCALE ?? 'it-IT'],
487
+ text: this.loc["Your current browser does not support reading from the clipboard directly. Please paste your clipboard's content in this Input field and confirm the operation"][this.LOCALE ?? 'it-IT'],
488
+ input: 'textarea',
489
+ icon: "warning",
490
+ confirmButtonText: this.loc["Confirm"][this.LOCALE ?? 'it-IT'],
491
+ cancelButtonText: this.loc["Cancel"][this.LOCALE ?? 'it-IT'],
492
+ showCancelButton: true,
493
+ customClass: {
494
+ confirmButton: "btn btn-primary",
495
+ cancelButton: "btn btn-secondary app-margin-right-15",
496
+ container: "app-wrap",
497
+ },
498
+ reverseButtons: true,
499
+ allowOutsideClick: false,
500
+ inputValidator: (value) => {
501
+ if (!value)
502
+ return this.loc["Please insert your clipboard content"][this.LOCALE ?? 'it-IT'];
503
+ }
504
+ }).then(t => {
505
+ if (t.isConfirmed) {
506
+ console.log("[@esfaenza/extensions] Retrieving input data from user input");
507
+ this.doClipboardDataGet(t.value, style, valueFoundCallback);
508
+ }
509
+ });
421
510
  return;
422
511
  }
423
512
  if (window.clipboardData) {
513
+ console.log("[@esfaenza/extensions] Found clipboardData");
424
514
  let data = window.clipboardData.getData("Text");
425
- var value = style == "array" ? this.getClipboardLines(data) :
426
- style == "matrix" ? this.getClipboardMatrix(data) : [];
427
- if (valueFoundCallback)
428
- valueFoundCallback(value);
515
+ this.doClipboardDataGet(data, style, valueFoundCallback);
429
516
  }
430
517
  else if (window.navigator.clipboard) {
518
+ console.log("[@esfaenza/extensions] Found navigator clipboard");
431
519
  window.navigator.permissions.query({ name: 'clipboard-read' }).then(result => {
432
- if (!(result.state === 'granted' || result.state === 'prompt'))
520
+ if (!(result.state === 'granted' || result.state === 'prompt')) {
521
+ console.error("[@esfaenza/extensions] Clipboard permission not granted");
433
522
  if (valueFoundCallback)
434
523
  valueFoundCallback([]);
524
+ return;
525
+ }
526
+ console.log("[@esfaenza/extensions] Clipboard permission granted, retrieving values");
435
527
  window.navigator.clipboard.readText()
436
- .then(t => {
437
- var value = style == "array" ? this.getClipboardLines(t) :
438
- style == "matrix" ? this.getClipboardMatrix(t) : [];
439
- if (valueFoundCallback)
440
- valueFoundCallback(value);
441
- })
442
- .catch(err => {
443
- this.msgService.simpleError(this.loc["Error during Clipboard content read operation"][this.LOCALE ?? 'it-IT'] + ": " + err);
444
- });
528
+ .then((t) => this.doClipboardDataGet(t, style, valueFoundCallback))
529
+ .catch((err) => this.msgService.simpleError(this.loc["Error during Clipboard content read operation"][this.LOCALE ?? 'it-IT'] + ": " + err));
445
530
  });
446
531
  }
447
532
  }
533
+ /** @ignore */
534
+ doClipboardDataGet(clipboardText, style, valueFoundCallback) {
535
+ console.log("[@esfaenza/extensions] Retrieved clipboard values: " + clipboardText);
536
+ let value = style == "array" ? this.getClipboardLines(clipboardText) :
537
+ style == "matrix" ? this.getClipboardMatrix(clipboardText) : [];
538
+ console.log(`[@esfaenza/extensions] Adapted for ${style}: ${JSON.stringify(value)}`);
539
+ if (valueFoundCallback)
540
+ valueFoundCallback(value);
541
+ }
448
542
  /**
449
543
  * Ottiene il contenuto della clipboard diviso per righe (separate da newline)
450
544
  *
@@ -453,7 +547,10 @@ class ClipboardService {
453
547
  * @returns {string[]} Array contenente il testo preso dalla clipboard diviso per riga
454
548
  */
455
549
  getClipboardLines(data) {
456
- return data.trim().split("\r\n");
550
+ let trimmedData = data.trim();
551
+ if (!trimmedData.includes("\r\n") && trimmedData.includes("\n"))
552
+ return trimmedData.split("\n");
553
+ return trimmedData.split("\r\n");
457
554
  }
458
555
  /**
459
556
  * Ottiene il contenuto della clipboard diviso per righe (separate da newline) e colonne (separate da tab)
@@ -464,7 +561,7 @@ class ClipboardService {
464
561
  */
465
562
  getClipboardMatrix(data) {
466
563
  var ret = [];
467
- var rows = data.split("\r\n");
564
+ var rows = !data.includes("\r\n") && data.includes("\n") ? data.split("\n") : data.split("\r\n");
468
565
  // A quanto pare ogni valore è separato da un \t... spero che sia uno standard di quando si copia da excel altrimenti ciao
469
566
  for (let i = 0; i < rows.length; i++)
470
567
  ret.push(rows[i].split('\t').map(t => t.trim()));
@@ -522,9 +619,9 @@ class ClipboardService {
522
619
  document.body.removeChild(textArea);
523
620
  }
524
621
  }
525
- ClipboardService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ClipboardService, deps: [{ token: MessageService }, { token: EXT_LOCALE, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
526
- ClipboardService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ClipboardService });
527
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ClipboardService, decorators: [{
622
+ ClipboardService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ClipboardService, deps: [{ token: MessageService }, { token: EXT_LOCALE, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
623
+ ClipboardService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ClipboardService });
624
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ClipboardService, decorators: [{
528
625
  type: Injectable
529
626
  }], ctorParameters: function () { return [{ type: MessageService }, { type: undefined, decorators: [{
530
627
  type: Optional
@@ -750,9 +847,9 @@ class DateService {
750
847
  return date.format(small ? this.cfg.smallDate : seconds ? this.cfg.fulldateDisplay : this.cfg.fulldateDisplayNoSS);
751
848
  }
752
849
  }
753
- DateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: DateService, deps: [{ token: EXT_LOCALE, optional: true }, { token: EXT_ALLOW_UTC, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
754
- DateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: DateService });
755
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: DateService, decorators: [{
850
+ DateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DateService, deps: [{ token: EXT_LOCALE, optional: true }, { token: EXT_ALLOW_UTC, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
851
+ DateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DateService });
852
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DateService, decorators: [{
756
853
  type: Injectable
757
854
  }], ctorParameters: function () { return [{ type: undefined, decorators: [{
758
855
  type: Optional
@@ -783,6 +880,10 @@ const csvVisPrefix = "_csvvis";
783
880
  * Suffisso della proprietà da generare in cui salvare il nome della colonna in cui salvare questa proprietà
784
881
  */
785
882
  const csvHdrPrefix = "_csvhdr";
883
+ /**
884
+ * Suffisso della proprietà da generare in cui salvare il codice del th a cui si riferisce questo campo
885
+ */
886
+ const csvPropKey = "_csvkey";
786
887
  /**
787
888
  * Suffisso della proprietà da generare in cui salvare il valore da prendere per una proprietà di tipo Lista
788
889
  */
@@ -806,7 +907,11 @@ const dictionaryCsvHdrPrefix = "_flatlistcsvhdr";
806
907
  /**
807
908
  * Suffisso della proprietà da generare in cui salvare il formato della proprietà che si sta esportando
808
909
  */
809
- const csvFormatPrefix = "_csvfmt";
910
+ const csvFormatPrefix = "_csvfmt";
911
+ /**
912
+ * Nome della proprietà che contiene tutti i nomi di tutte le proprietà da esportare
913
+ */
914
+ const exportList = "__export_list__";
810
915
 
811
916
  // Angular
812
917
  /**
@@ -834,12 +939,18 @@ const csvFormatPrefix = "_csvfmt";
834
939
  * @param {string} header Titolo della colonna nel file CSV esportato
835
940
  * @param {string} format Formato di esportazione. Può essere un formato data per i campi data o 'F' per i campi floating point
836
941
  */
837
- const Export = (order, header, format = null) => (target, propertyKey) => {
942
+ const Export = (order, header, format = null, tableid = null) => (target, propertyKey) => {
838
943
  if (format)
839
944
  Object.defineProperty(target, propertyKey + csvFormatPrefix, { value: format, writable: false });
840
945
  Object.defineProperty(target, propertyKey + csvOrdPrefix, { value: order, writable: false });
841
946
  Object.defineProperty(target, propertyKey + csvVisPrefix, { value: !!header, writable: false });
842
947
  Object.defineProperty(target, propertyKey + csvHdrPrefix, { value: header, writable: false });
948
+ if (tableid)
949
+ Object.defineProperty(target, propertyKey + csvPropKey, { value: tableid, writable: false });
950
+ if (target[exportList])
951
+ target[exportList].push(propertyKey + csvVisPrefix);
952
+ else
953
+ target[exportList] = [propertyKey + csvVisPrefix];
843
954
  };
844
955
  /**
845
956
  * Decoratore di esportazione utilizzabile su un oggetto.
@@ -873,8 +984,9 @@ const Export = (order, header, format = null) => (target, propertyKey) => {
873
984
  */
874
985
  const ExportAs = (order, type) => (target, propertyKey) => {
875
986
  var t = new type();
876
- for (var prop in t) {
877
- //Niente hasownproperty perché le proprietà dell'oggetto interno sono dentro al prototype
987
+ var props = t[exportList];
988
+ for (let i = 0; i < props.length; i++) {
989
+ let prop = props[i].replace(csvVisPrefix, '');
878
990
  if (typeof t[prop + csvVisPrefix] !== "undefined") {
879
991
  var toEmit = t[prop + csvVisPrefix];
880
992
  var lbl = t[prop + csvHdrPrefix];
@@ -887,6 +999,10 @@ const ExportAs = (order, type) => (target, propertyKey) => {
887
999
  Object.defineProperty(target, propertyKey + prop + csvValueNavigator, { value: propertyKey + "." + prop, writable: false });
888
1000
  Object.defineProperty(target, propertyKey + prop + csvVisPrefix, { value: toEmit, writable: false });
889
1001
  Object.defineProperty(target, propertyKey + prop + csvHdrPrefix, { value: lbl, writable: false });
1002
+ if (target[exportList])
1003
+ target[exportList].push(propertyKey + prop + csvVisPrefix);
1004
+ else
1005
+ target[exportList] = [propertyKey + prop + csvVisPrefix];
890
1006
  }
891
1007
  }
892
1008
  };
@@ -913,6 +1029,10 @@ const ExportList = (order, headernavigator, valuenavigator, valueformat = null)
913
1029
  Object.defineProperty(target, propertyKey + listCsvValPrefix, { value: valuenavigator, writable: false });
914
1030
  Object.defineProperty(target, propertyKey + listCsvHdrPrefix, { value: headernavigator, writable: false });
915
1031
  Object.defineProperty(target, propertyKey + listCsvValFormat, { value: valueformat, writable: false });
1032
+ if (target[exportList])
1033
+ target[exportList].push(propertyKey + listCsvHdrPrefix);
1034
+ else
1035
+ target[exportList] = [propertyKey + listCsvHdrPrefix];
916
1036
  };
917
1037
  /**
918
1038
  * Decoratore di esportazione utilizzabile su un dizionario. Se ad esempio si vogliono generare le colonne
@@ -933,6 +1053,10 @@ const ExportDictionary = (order, headernavigator, valuenavigator) => (target, pr
933
1053
  Object.defineProperty(target, propertyKey + csvOrdPrefix, { value: order, writable: false });
934
1054
  Object.defineProperty(target, propertyKey + dictionaryCsvValPrefix, { value: valuenavigator, writable: false });
935
1055
  Object.defineProperty(target, propertyKey + dictionaryCsvHdrPrefix, { value: headernavigator, writable: false });
1056
+ if (target[exportList])
1057
+ target[exportList].push(propertyKey + dictionaryCsvHdrPrefix);
1058
+ else
1059
+ target[exportList] = [propertyKey + dictionaryCsvHdrPrefix];
936
1060
  };
937
1061
  /**
938
1062
  * Service che si occupa dell'esportazione degli oggetti marcati dai Decoratori **ExportDictionary**, **ExportList**, **ExportAs** o **Export**
@@ -953,15 +1077,19 @@ class ExportService {
953
1077
  *
954
1078
  * @returns {CsvHeaders[]} Header di esportazione già ordinati correttamente
955
1079
  */
956
- setupForExport(objs) {
1080
+ setupForExport(objs, columns = []) {
957
1081
  let headers = [];
958
1082
  let headersCache = {};
959
1083
  if (!objs || objs.length == 0)
960
1084
  return headers;
961
1085
  // Devo per forza farlo per tutti gli oggetti dato che devo esporre le proprietà che mi servono da esportare
962
1086
  // Gli header li raccolgo tutti poi faccio uan distinct in modo da esportare tutte le proprietà per bene
1087
+ let columnSelectionDictionary = {};
1088
+ if (columns?.length > 0)
1089
+ for (let i = 0; i < columns?.length; i++)
1090
+ columnSelectionDictionary[columns[i]] = true;
963
1091
  for (let i = 0; i < objs.length; i++) {
964
- let hds = this.parseAndGetHeaders(objs[i]);
1092
+ let hds = this.parseAndGetHeaders(objs[i], columnSelectionDictionary);
965
1093
  // Aggiungo gli header facendo in modo di non aggiungerne mai due uguali per non dover fare una distinct dopo
966
1094
  // che costerebbe comunque risorse. Utilizzo un dizionario d'appoggio per lookup istantanei
967
1095
  for (let k = 0; k < hds.length; k++) {
@@ -971,7 +1099,23 @@ class ExportService {
971
1099
  }
972
1100
  }
973
1101
  }
974
- return headers.sort((a, b) => a.order - b.order);
1102
+ if (!columns || columns.length == 0)
1103
+ return headers.sort((a, b) => a.order - b.order);
1104
+ else {
1105
+ // Se mi arriva la lista di colonne non mi dà solo la visibilità, ma anche l'ordinamento
1106
+ // le esporto di conseguenza
1107
+ let orderedHeaders = [];
1108
+ for (let i = 0; i < columns.length; i++) {
1109
+ let thisId = columns[i];
1110
+ for (let i = 0; i < headers.length; i++) {
1111
+ if (headers[i].propKey == thisId) {
1112
+ orderedHeaders.push(headers[i]);
1113
+ break;
1114
+ }
1115
+ }
1116
+ }
1117
+ return orderedHeaders;
1118
+ }
975
1119
  }
976
1120
  /**
977
1121
  * Data una lista di oggetti generici genera gli header per l'esportazione e integra ogni oggetto con le proprietà esportabili dalla libreria **@ctrl/ngx-csv**
@@ -1012,7 +1156,7 @@ class ExportService {
1012
1156
  columns.forEach(t => {
1013
1157
  var propValue = obj.properties[t.key];
1014
1158
  Object.defineProperty(obj, t.key + "_exp", { value: propValue, writable: false, enumerable: true });
1015
- headers.push({ label: t.label, key: t.key + "_exp", order: t.order, type: t.type });
1159
+ headers.push({ label: t.label, key: t.key + "_exp", order: t.order, type: t.type, propKey: null });
1016
1160
  });
1017
1161
  //Tirati fuori tutti gli header faccio sort sull'ordinamento
1018
1162
  return headers.sort((a, b) => { return a.order - b.order; });
@@ -1026,14 +1170,14 @@ class ExportService {
1026
1170
  *
1027
1171
  * @returns {CsvHeaders[]} Header di esportazione già ordinati correttamente
1028
1172
  */
1029
- parseAndGetHeaders(obj) {
1173
+ parseAndGetHeaders(obj, columnsSelection) {
1030
1174
  var headers = [];
1031
1175
  // Miracle incoming
1032
- let propsDictionary = Object.getOwnPropertyNames(Object.getPrototypeOf(obj));
1033
- for (var propId in propsDictionary) {
1034
- if (!propsDictionary.hasOwnProperty(propId))
1035
- continue;
1036
- let prop = propsDictionary[propId];
1176
+ let exportProps = obj[exportList] || [];
1177
+ if (exportProps.length == 0)
1178
+ console.warn("[@esfaenza/extensions] Nessuna colonna configurata da esportare!");
1179
+ for (let i = 0; i < exportProps.length; i++) {
1180
+ let prop = exportProps[i];
1037
1181
  let propBase = "";
1038
1182
  let toCall;
1039
1183
  if (prop.endsWith(listCsvHdrPrefix)) {
@@ -1052,7 +1196,7 @@ class ExportService {
1052
1196
  toCall = this.parseProperty.bind(this);
1053
1197
  }
1054
1198
  if (toCall)
1055
- toCall(obj, propBase, headers);
1199
+ toCall(obj, propBase, headers, columnsSelection);
1056
1200
  }
1057
1201
  return headers;
1058
1202
  }
@@ -1064,9 +1208,14 @@ class ExportService {
1064
1208
  * @param {string} prop Proprietà da esportare
1065
1209
  * @param {CsvHeaders} headers Contenitore degli header, verrà riempito da questa funzione
1066
1210
  */
1067
- parseProperty(obj, prop, headers) {
1211
+ parseProperty(obj, prop, headers, columnsSelection) {
1068
1212
  let toEmit = obj[prop + csvVisPrefix];
1069
1213
  let format = obj[prop + csvFormatPrefix];
1214
+ let propKey = obj[prop + csvPropKey];
1215
+ if (propKey && !columnsSelection[propKey] && Object.keys(columnsSelection).length > 0) {
1216
+ console.log("[@esfaenza/extensions] Colonna da non esportare: " + propKey);
1217
+ return;
1218
+ }
1070
1219
  let lbl = obj[prop + csvHdrPrefix];
1071
1220
  let order = obj[prop + csvOrdPrefix];
1072
1221
  if (toEmit && lbl !== "undefined") {
@@ -1075,7 +1224,7 @@ class ExportService {
1075
1224
  // Se è un formato data mi assicuro di non stampare mai una data 00:00:00 altrimenti in esportazione viene uno schifo
1076
1225
  var val = obj[prop] ? this.dates.trimSeconds(obj[prop].toString()) : "";
1077
1226
  Object.defineProperty(obj, prop + "_nofmt", { value: val, writable: false, enumerable: true });
1078
- headers.push({ label: lbl ? lbl : prop + "_nofmt", key: prop + "_nofmt", order: order, type: "string" });
1227
+ headers.push({ label: lbl ? lbl : prop + "_nofmt", key: prop + "_nofmt", order: order, type: "string", propKey: propKey });
1079
1228
  }
1080
1229
  else {
1081
1230
  // Caso formato numerico
@@ -1087,7 +1236,7 @@ class ExportService {
1087
1236
  // Il singolo punto che c'è, se presente (separatore decimali) lo trasformo in virgola
1088
1237
  let valConverted = val.replace(".", ",");
1089
1238
  Object.defineProperty(obj, prop + "_fmt", { value: valConverted, writable: false, enumerable: true });
1090
- headers.push({ label: lbl ? lbl : prop + "_fmt", key: prop + "_fmt", order: order, type: "number" });
1239
+ headers.push({ label: lbl ? lbl : prop + "_fmt", key: prop + "_fmt", order: order, type: "number", propKey: propKey });
1091
1240
  }
1092
1241
  else {
1093
1242
  // Se ho un formato data trasformo in dayjs, formatto ed esporto
@@ -1095,7 +1244,7 @@ class ExportService {
1095
1244
  // Se non funziona provo a definirgli la formattazione standard del metering per quel linguaggio
1096
1245
  let val = this.dates.getFormatted(obj[prop], format.length <= 10, format.length > 16);
1097
1246
  Object.defineProperty(obj, prop + "_fmt", { value: val ?? "", writable: false, enumerable: true });
1098
- headers.push({ label: lbl ? lbl : prop + "_fmt", key: prop + "_fmt", order: order, type: "date" });
1247
+ headers.push({ label: lbl ? lbl : prop + "_fmt", key: prop + "_fmt", order: order, type: "date", propKey: propKey });
1099
1248
  }
1100
1249
  }
1101
1250
  }
@@ -1139,8 +1288,8 @@ class ExportService {
1139
1288
  value = this.dates.getFormatted(value, format.length <= 10, format.length > 16);
1140
1289
  type = "date";
1141
1290
  }
1142
- Object.defineProperty(obj, prop, { value: value, writable: false, enumerable: true });
1143
- headers.push({ label: lbl ? lbl : prop, key: prop, order: order, type: type });
1291
+ Object.defineProperty(obj, prop, { value: value ?? "", writable: false, enumerable: true });
1292
+ headers.push({ label: lbl ? lbl : prop, key: prop, order: order, type: type, propKey: null });
1144
1293
  }
1145
1294
  /**
1146
1295
  * Setup per l'esportazione di una lista di valori pivottati dinamicamente:
@@ -1193,8 +1342,8 @@ class ExportService {
1193
1342
  value = this.dates.getFormatted(obj[prop], valueformat.length <= 10, valueformat.length > 16);
1194
1343
  type = "date";
1195
1344
  }
1196
- Object.defineProperty(obj, prop + idx, { value: value, writable: false });
1197
- headers.push({ label: header, key: prop + idx, order: order + idx, type: type });
1345
+ Object.defineProperty(obj, prop + idx, { value: value ?? "", writable: false });
1346
+ headers.push({ label: header, key: prop + idx, order: order + idx, type: type, propKey: null });
1198
1347
  }
1199
1348
  }
1200
1349
  /**
@@ -1240,8 +1389,8 @@ class ExportService {
1240
1389
  jumps.forEach(pp => { tmpRes = tmpRes[pp]; });
1241
1390
  let value = tmpRes;
1242
1391
  let propname = prop + idx.toString() + idxinternal.toString();
1243
- Object.defineProperty(obj, propname, { value: value, writable: false });
1244
- headers.push({ label: header + " " + desc, key: propname, order: order + idx, type: 'string' });
1392
+ Object.defineProperty(obj, propname, { value: value ?? "", writable: false });
1393
+ headers.push({ label: header + " " + desc, key: propname, order: order + idx, type: 'string', propKey: null });
1245
1394
  });
1246
1395
  }
1247
1396
  }
@@ -1258,9 +1407,9 @@ class ExportService {
1258
1407
  return Deserialize(items, type);
1259
1408
  }
1260
1409
  }
1261
- ExportService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ExportService, deps: [{ token: DateService }], target: i0.ɵɵFactoryTarget.Injectable });
1262
- ExportService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ExportService });
1263
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ExportService, decorators: [{
1410
+ ExportService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ExportService, deps: [{ token: DateService }], target: i0.ɵɵFactoryTarget.Injectable });
1411
+ ExportService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ExportService });
1412
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ExportService, decorators: [{
1264
1413
  type: Injectable
1265
1414
  }], ctorParameters: function () { return [{ type: DateService }]; } });
1266
1415
 
@@ -1565,9 +1714,9 @@ class HashingService {
1565
1714
  return (a + b) & 0xFFFFFFFF;
1566
1715
  }
1567
1716
  }
1568
- HashingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: HashingService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1569
- HashingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: HashingService });
1570
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: HashingService, decorators: [{
1717
+ HashingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HashingService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1718
+ HashingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HashingService });
1719
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HashingService, decorators: [{
1571
1720
  type: Injectable
1572
1721
  }] });
1573
1722
 
@@ -1816,9 +1965,9 @@ class UtilityService {
1816
1965
  return destination;
1817
1966
  }
1818
1967
  }
1819
- UtilityService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: UtilityService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1820
- UtilityService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: UtilityService });
1821
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: UtilityService, decorators: [{
1968
+ UtilityService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UtilityService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1969
+ UtilityService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UtilityService });
1970
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UtilityService, decorators: [{
1822
1971
  type: Injectable
1823
1972
  }] });
1824
1973
 
@@ -1877,9 +2026,9 @@ class InterComService {
1877
2026
  this.outbounds[key] = new Subject();
1878
2027
  }
1879
2028
  }
1880
- InterComService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: InterComService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1881
- InterComService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: InterComService });
1882
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: InterComService, decorators: [{
2029
+ InterComService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: InterComService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2030
+ InterComService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: InterComService });
2031
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: InterComService, decorators: [{
1883
2032
  type: Injectable
1884
2033
  }] });
1885
2034
 
@@ -1916,10 +2065,10 @@ class FullExtensionsModule {
1916
2065
  };
1917
2066
  }
1918
2067
  }
1919
- FullExtensionsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: FullExtensionsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1920
- FullExtensionsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.12", ngImport: i0, type: FullExtensionsModule });
1921
- FullExtensionsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: FullExtensionsModule });
1922
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: FullExtensionsModule, decorators: [{
2068
+ FullExtensionsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: FullExtensionsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2069
+ FullExtensionsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: FullExtensionsModule });
2070
+ FullExtensionsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: FullExtensionsModule });
2071
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: FullExtensionsModule, decorators: [{
1923
2072
  type: NgModule
1924
2073
  }] });
1925
2074