@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,9 +57,9 @@ class MessageService {
57
57
  *
58
58
  * @ignore
59
59
  */
60
- constructor(toastr, FANCY_ALERTS, LOCALE) {
61
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
62
- this.toastr = toastr;
60
+ constructor(injector, FANCY_ALERTS, LOCALE) {
61
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
62
+ this.injector = injector;
63
63
  this.FANCY_ALERTS = FANCY_ALERTS;
64
64
  this.LOCALE = LOCALE;
65
65
  /**
@@ -86,8 +86,8 @@ class MessageService {
86
86
  allowOutsideClick: false,
87
87
  icon: "warning"
88
88
  });
89
- this.warningSwalWithCancel = swal.mixin({
90
- title: this.loc["Warning"][(_a = this.LOCALE) !== null && _a !== void 0 ? _a : 'it-IT'],
89
+ this.successSwalWithCancel = swal.mixin({
90
+ title: this.loc["Success"][(_a = this.LOCALE) !== null && _a !== void 0 ? _a : 'it-IT'],
91
91
  customClass: {
92
92
  confirmButton: "btn btn-primary",
93
93
  cancelButton: "btn btn-secondary app-margin-right-10",
@@ -98,10 +98,24 @@ class MessageService {
98
98
  showCancelButton: true,
99
99
  confirmButtonText: this.loc["Confirm"][(_b = this.LOCALE) !== null && _b !== void 0 ? _b : 'it-IT'],
100
100
  cancelButtonText: this.loc["Cancel"][(_c = this.LOCALE) !== null && _c !== void 0 ? _c : 'it-IT'],
101
+ icon: "success"
102
+ });
103
+ this.warningSwalWithCancel = swal.mixin({
104
+ title: this.loc["Warning"][(_d = this.LOCALE) !== null && _d !== void 0 ? _d : 'it-IT'],
105
+ customClass: {
106
+ confirmButton: "btn btn-primary",
107
+ cancelButton: "btn btn-secondary app-margin-right-10",
108
+ container: "app-wrap",
109
+ },
110
+ buttonsStyling: false,
111
+ reverseButtons: true,
112
+ showCancelButton: true,
113
+ confirmButtonText: this.loc["Confirm"][(_e = this.LOCALE) !== null && _e !== void 0 ? _e : 'it-IT'],
114
+ cancelButtonText: this.loc["Cancel"][(_f = this.LOCALE) !== null && _f !== void 0 ? _f : 'it-IT'],
101
115
  icon: "warning"
102
116
  });
103
117
  this.warningSwal = swal.mixin({
104
- title: this.loc["Warning"][(_d = this.LOCALE) !== null && _d !== void 0 ? _d : 'it-IT'],
118
+ title: this.loc["Warning"][(_g = this.LOCALE) !== null && _g !== void 0 ? _g : 'it-IT'],
105
119
  customClass: {
106
120
  confirmButton: "btn btn-primary",
107
121
  container: "app-wrap",
@@ -109,11 +123,11 @@ class MessageService {
109
123
  buttonsStyling: false,
110
124
  reverseButtons: true,
111
125
  showCancelButton: false,
112
- confirmButtonText: this.loc["Close"][(_e = this.LOCALE) !== null && _e !== void 0 ? _e : 'it-IT'],
126
+ confirmButtonText: this.loc["Close"][(_h = this.LOCALE) !== null && _h !== void 0 ? _h : 'it-IT'],
113
127
  icon: "warning"
114
128
  });
115
129
  this.successSwal = swal.mixin({
116
- title: this.loc["Success"][(_f = this.LOCALE) !== null && _f !== void 0 ? _f : 'it-IT'],
130
+ title: this.loc["Success"][(_j = this.LOCALE) !== null && _j !== void 0 ? _j : 'it-IT'],
117
131
  customClass: {
118
132
  confirmButton: "btn btn-primary",
119
133
  container: "app-wrap",
@@ -121,11 +135,11 @@ class MessageService {
121
135
  buttonsStyling: false,
122
136
  reverseButtons: true,
123
137
  showCancelButton: false,
124
- confirmButtonText: this.loc["Close"][(_g = this.LOCALE) !== null && _g !== void 0 ? _g : 'it-IT'],
138
+ confirmButtonText: this.loc["Close"][(_k = this.LOCALE) !== null && _k !== void 0 ? _k : 'it-IT'],
125
139
  icon: "success"
126
140
  });
127
141
  this.errorSwal = swal.mixin({
128
- title: this.loc["Error"][(_h = this.LOCALE) !== null && _h !== void 0 ? _h : 'it-IT'],
142
+ title: this.loc["Error"][(_l = this.LOCALE) !== null && _l !== void 0 ? _l : 'it-IT'],
129
143
  customClass: {
130
144
  confirmButton: "btn btn-primary",
131
145
  container: "app-wrap",
@@ -133,11 +147,11 @@ class MessageService {
133
147
  buttonsStyling: false,
134
148
  reverseButtons: true,
135
149
  showCancelButton: false,
136
- confirmButtonText: this.loc["Close"][(_j = this.LOCALE) !== null && _j !== void 0 ? _j : 'it-IT'],
150
+ confirmButtonText: this.loc["Close"][(_m = this.LOCALE) !== null && _m !== void 0 ? _m : 'it-IT'],
137
151
  icon: "error"
138
152
  });
139
153
  this.infoSwal = swal.mixin({
140
- title: this.loc["Info"][(_k = this.LOCALE) !== null && _k !== void 0 ? _k : 'it-IT'],
154
+ title: this.loc["Info"][(_o = this.LOCALE) !== null && _o !== void 0 ? _o : 'it-IT'],
141
155
  customClass: {
142
156
  confirmButton: "btn btn-primary",
143
157
  container: "app-wrap",
@@ -145,10 +159,13 @@ class MessageService {
145
159
  buttonsStyling: false,
146
160
  reverseButtons: true,
147
161
  showCancelButton: false,
148
- confirmButtonText: this.loc["Close"][(_l = this.LOCALE) !== null && _l !== void 0 ? _l : 'it-IT'],
162
+ confirmButtonText: this.loc["Close"][(_p = this.LOCALE) !== null && _p !== void 0 ? _p : 'it-IT'],
149
163
  icon: "info"
150
164
  });
151
165
  }
166
+ get toastr() {
167
+ return this.injector.get(ToastrService);
168
+ }
152
169
  /**
153
170
  * Presentazione di un semplice messaggio di successo
154
171
  *
@@ -259,6 +276,32 @@ class MessageService {
259
276
  onerror();
260
277
  });
261
278
  }
279
+ /**
280
+ * Mostra un messaggio di success con richiesta di conferma e gestisce il risultato chiamato i callback **onconfirm** o **onabort**
281
+ *
282
+ * @param {string} title Titolo del messaggio
283
+ * @param {string} text Contenuto del messaggio
284
+ * @param {Function} onconfirm Callback da chimare su conferma
285
+ * @param {Function} onabort Callback da chimare su annullamento
286
+ * @param {string} confirmtext Testo del pulsante di azione
287
+ * @param {string} aborttext Testo del pulsante di annullamento
288
+ */
289
+ simpleSuccessWithChoice(title, text, onconfirm = null, onabort = null, confirmtext = "", aborttext = '') {
290
+ var configuration = {
291
+ title: title,
292
+ html: text
293
+ };
294
+ if (confirmtext)
295
+ configuration["confirmButtonText"] = confirmtext;
296
+ if (aborttext)
297
+ configuration["cancelButtonText"] = aborttext;
298
+ this.successSwalWithCancel.fire(configuration).then((result) => {
299
+ if (result.value && onconfirm)
300
+ onconfirm();
301
+ else if (onabort)
302
+ onabort();
303
+ });
304
+ }
262
305
  /**
263
306
  * Mostra un messaggio di avviso con richiesta di conferma e gestisce il risultato chiamato i callback **onsuccess** o **onerror**
264
307
  *
@@ -300,8 +343,8 @@ class MessageService {
300
343
  if (postSuccess)
301
344
  postSuccess();
302
345
  }
303
- else if (response.haserror) {
304
- this.simpleError((errorMsg ? errorMsg + ": " : "") + response.error);
346
+ else {
347
+ this.simpleError((errorMsg ? errorMsg + ": " : "") + response.haserror ? response.error : '[NO ERR.]');
305
348
  if (postFailure)
306
349
  postFailure();
307
350
  }
@@ -357,12 +400,15 @@ class MessageService {
357
400
  }
358
401
  }
359
402
  }
360
- 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 });
361
- MessageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: MessageService });
362
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: MessageService, decorators: [{
403
+ 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 });
404
+ MessageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: MessageService });
405
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: MessageService, decorators: [{
363
406
  type: Injectable
364
407
  }], ctorParameters: function () {
365
- return [{ type: i1.ToastrService }, { type: undefined, decorators: [{
408
+ return [{ type: i0.Injector, decorators: [{
409
+ type: Inject,
410
+ args: [Injector]
411
+ }] }, { type: undefined, decorators: [{
366
412
  type: Optional
367
413
  }, {
368
414
  type: Inject,
@@ -407,7 +453,27 @@ class ClipboardService {
407
453
  "Error during Clipboard content copy operation": {
408
454
  'en-US': "Error during Clipboard content copy operation",
409
455
  'it-IT': "Errore nella scrittura del contenuto nella Clipboard"
410
- }
456
+ },
457
+ "Please insert your clipboard content": {
458
+ 'en-US': "Please insert your clipboard content",
459
+ 'it-IT': "Si prega di incollare il contenuto della Clipboard"
460
+ },
461
+ "User input required": {
462
+ 'en-US': "User input required",
463
+ 'it-IT': "Richiesto Input utente"
464
+ },
465
+ "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": {
466
+ '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",
467
+ '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"
468
+ },
469
+ "Confirm": {
470
+ 'en-US': "Confirm",
471
+ 'it-IT': "Conferma"
472
+ },
473
+ "Cancel": {
474
+ 'en-US': "Cancel",
475
+ 'it-IT': "Annulla"
476
+ },
411
477
  };
412
478
  }
413
479
  /**
@@ -418,38 +484,66 @@ class ClipboardService {
418
484
  * @param {Function} valueFoundCallback Callback che questa funzione chiamerà una volta ottenuto i valori richiesti dalla clipboard
419
485
  */
420
486
  getClipboard(style, valueFoundCallback) {
421
- var _a;
487
+ var _a, _b, _c, _d;
422
488
  if (navigator.userAgent.indexOf("Firefox") != -1) {
423
- //https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/readText
424
- 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"][(_a = this.LOCALE) !== null && _a !== void 0 ? _a : 'it-IT']);
489
+ swal.fire({
490
+ title: this.loc["User input required"][(_a = this.LOCALE) !== null && _a !== void 0 ? _a : 'it-IT'],
491
+ 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"][(_b = this.LOCALE) !== null && _b !== void 0 ? _b : 'it-IT'],
492
+ input: 'textarea',
493
+ icon: "warning",
494
+ confirmButtonText: this.loc["Confirm"][(_c = this.LOCALE) !== null && _c !== void 0 ? _c : 'it-IT'],
495
+ cancelButtonText: this.loc["Cancel"][(_d = this.LOCALE) !== null && _d !== void 0 ? _d : 'it-IT'],
496
+ showCancelButton: true,
497
+ customClass: {
498
+ confirmButton: "btn btn-primary",
499
+ cancelButton: "btn btn-secondary app-margin-right-15",
500
+ container: "app-wrap",
501
+ },
502
+ reverseButtons: true,
503
+ allowOutsideClick: false,
504
+ inputValidator: (value) => {
505
+ var _a;
506
+ if (!value)
507
+ return this.loc["Please insert your clipboard content"][(_a = this.LOCALE) !== null && _a !== void 0 ? _a : 'it-IT'];
508
+ }
509
+ }).then(t => {
510
+ if (t.isConfirmed) {
511
+ console.log("[@esfaenza/extensions] Retrieving input data from user input");
512
+ this.doClipboardDataGet(t.value, style, valueFoundCallback);
513
+ }
514
+ });
425
515
  return;
426
516
  }
427
517
  if (window.clipboardData) {
518
+ console.log("[@esfaenza/extensions] Found clipboardData");
428
519
  let data = window.clipboardData.getData("Text");
429
- var value = style == "array" ? this.getClipboardLines(data) :
430
- style == "matrix" ? this.getClipboardMatrix(data) : [];
431
- if (valueFoundCallback)
432
- valueFoundCallback(value);
520
+ this.doClipboardDataGet(data, style, valueFoundCallback);
433
521
  }
434
522
  else if (window.navigator.clipboard) {
523
+ console.log("[@esfaenza/extensions] Found navigator clipboard");
435
524
  window.navigator.permissions.query({ name: 'clipboard-read' }).then(result => {
436
- if (!(result.state === 'granted' || result.state === 'prompt'))
525
+ if (!(result.state === 'granted' || result.state === 'prompt')) {
526
+ console.error("[@esfaenza/extensions] Clipboard permission not granted");
437
527
  if (valueFoundCallback)
438
528
  valueFoundCallback([]);
529
+ return;
530
+ }
531
+ console.log("[@esfaenza/extensions] Clipboard permission granted, retrieving values");
439
532
  window.navigator.clipboard.readText()
440
- .then(t => {
441
- var value = style == "array" ? this.getClipboardLines(t) :
442
- style == "matrix" ? this.getClipboardMatrix(t) : [];
443
- if (valueFoundCallback)
444
- valueFoundCallback(value);
445
- })
446
- .catch(err => {
447
- var _a;
448
- this.msgService.simpleError(this.loc["Error during Clipboard content read operation"][(_a = this.LOCALE) !== null && _a !== void 0 ? _a : 'it-IT'] + ": " + err);
449
- });
533
+ .then((t) => this.doClipboardDataGet(t, style, valueFoundCallback))
534
+ .catch((err) => { var _a; return this.msgService.simpleError(this.loc["Error during Clipboard content read operation"][(_a = this.LOCALE) !== null && _a !== void 0 ? _a : 'it-IT'] + ": " + err); });
450
535
  });
451
536
  }
452
537
  }
538
+ /** @ignore */
539
+ doClipboardDataGet(clipboardText, style, valueFoundCallback) {
540
+ console.log("[@esfaenza/extensions] Retrieved clipboard values: " + clipboardText);
541
+ let value = style == "array" ? this.getClipboardLines(clipboardText) :
542
+ style == "matrix" ? this.getClipboardMatrix(clipboardText) : [];
543
+ console.log(`[@esfaenza/extensions] Adapted for ${style}: ${JSON.stringify(value)}`);
544
+ if (valueFoundCallback)
545
+ valueFoundCallback(value);
546
+ }
453
547
  /**
454
548
  * Ottiene il contenuto della clipboard diviso per righe (separate da newline)
455
549
  *
@@ -458,7 +552,10 @@ class ClipboardService {
458
552
  * @returns {string[]} Array contenente il testo preso dalla clipboard diviso per riga
459
553
  */
460
554
  getClipboardLines(data) {
461
- return data.trim().split("\r\n");
555
+ let trimmedData = data.trim();
556
+ if (!trimmedData.includes("\r\n") && trimmedData.includes("\n"))
557
+ return trimmedData.split("\n");
558
+ return trimmedData.split("\r\n");
462
559
  }
463
560
  /**
464
561
  * Ottiene il contenuto della clipboard diviso per righe (separate da newline) e colonne (separate da tab)
@@ -469,7 +566,7 @@ class ClipboardService {
469
566
  */
470
567
  getClipboardMatrix(data) {
471
568
  var ret = [];
472
- var rows = data.split("\r\n");
569
+ var rows = !data.includes("\r\n") && data.includes("\n") ? data.split("\n") : data.split("\r\n");
473
570
  // A quanto pare ogni valore è separato da un \t... spero che sia uno standard di quando si copia da excel altrimenti ciao
474
571
  for (let i = 0; i < rows.length; i++)
475
572
  ret.push(rows[i].split('\t').map(t => t.trim()));
@@ -528,9 +625,9 @@ class ClipboardService {
528
625
  document.body.removeChild(textArea);
529
626
  }
530
627
  }
531
- 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 });
532
- ClipboardService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ClipboardService });
533
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ClipboardService, decorators: [{
628
+ 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 });
629
+ ClipboardService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ClipboardService });
630
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ClipboardService, decorators: [{
534
631
  type: Injectable
535
632
  }], ctorParameters: function () {
536
633
  return [{ type: MessageService }, { type: undefined, decorators: [{
@@ -759,9 +856,9 @@ class DateService {
759
856
  return date.format(small ? this.cfg.smallDate : seconds ? this.cfg.fulldateDisplay : this.cfg.fulldateDisplayNoSS);
760
857
  }
761
858
  }
762
- 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 });
763
- DateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: DateService });
764
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: DateService, decorators: [{
859
+ 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 });
860
+ DateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DateService });
861
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DateService, decorators: [{
765
862
  type: Injectable
766
863
  }], ctorParameters: function () {
767
864
  return [{ type: undefined, decorators: [{
@@ -794,6 +891,10 @@ const csvVisPrefix = "_csvvis";
794
891
  * Suffisso della proprietà da generare in cui salvare il nome della colonna in cui salvare questa proprietà
795
892
  */
796
893
  const csvHdrPrefix = "_csvhdr";
894
+ /**
895
+ * Suffisso della proprietà da generare in cui salvare il codice del th a cui si riferisce questo campo
896
+ */
897
+ const csvPropKey = "_csvkey";
797
898
  /**
798
899
  * Suffisso della proprietà da generare in cui salvare il valore da prendere per una proprietà di tipo Lista
799
900
  */
@@ -817,7 +918,11 @@ const dictionaryCsvHdrPrefix = "_flatlistcsvhdr";
817
918
  /**
818
919
  * Suffisso della proprietà da generare in cui salvare il formato della proprietà che si sta esportando
819
920
  */
820
- const csvFormatPrefix = "_csvfmt";
921
+ const csvFormatPrefix = "_csvfmt";
922
+ /**
923
+ * Nome della proprietà che contiene tutti i nomi di tutte le proprietà da esportare
924
+ */
925
+ const exportList = "__export_list__";
821
926
 
822
927
  // Angular
823
928
  /**
@@ -845,12 +950,18 @@ const csvFormatPrefix = "_csvfmt";
845
950
  * @param {string} header Titolo della colonna nel file CSV esportato
846
951
  * @param {string} format Formato di esportazione. Può essere un formato data per i campi data o 'F' per i campi floating point
847
952
  */
848
- const Export = (order, header, format = null) => (target, propertyKey) => {
953
+ const Export = (order, header, format = null, tableid = null) => (target, propertyKey) => {
849
954
  if (format)
850
955
  Object.defineProperty(target, propertyKey + csvFormatPrefix, { value: format, writable: false });
851
956
  Object.defineProperty(target, propertyKey + csvOrdPrefix, { value: order, writable: false });
852
957
  Object.defineProperty(target, propertyKey + csvVisPrefix, { value: !!header, writable: false });
853
958
  Object.defineProperty(target, propertyKey + csvHdrPrefix, { value: header, writable: false });
959
+ if (tableid)
960
+ Object.defineProperty(target, propertyKey + csvPropKey, { value: tableid, writable: false });
961
+ if (target[exportList])
962
+ target[exportList].push(propertyKey + csvVisPrefix);
963
+ else
964
+ target[exportList] = [propertyKey + csvVisPrefix];
854
965
  };
855
966
  /**
856
967
  * Decoratore di esportazione utilizzabile su un oggetto.
@@ -884,8 +995,9 @@ const Export = (order, header, format = null) => (target, propertyKey) => {
884
995
  */
885
996
  const ExportAs = (order, type) => (target, propertyKey) => {
886
997
  var t = new type();
887
- for (var prop in t) {
888
- //Niente hasownproperty perché le proprietà dell'oggetto interno sono dentro al prototype
998
+ var props = t[exportList];
999
+ for (let i = 0; i < props.length; i++) {
1000
+ let prop = props[i].replace(csvVisPrefix, '');
889
1001
  if (typeof t[prop + csvVisPrefix] !== "undefined") {
890
1002
  var toEmit = t[prop + csvVisPrefix];
891
1003
  var lbl = t[prop + csvHdrPrefix];
@@ -898,6 +1010,10 @@ const ExportAs = (order, type) => (target, propertyKey) => {
898
1010
  Object.defineProperty(target, propertyKey + prop + csvValueNavigator, { value: propertyKey + "." + prop, writable: false });
899
1011
  Object.defineProperty(target, propertyKey + prop + csvVisPrefix, { value: toEmit, writable: false });
900
1012
  Object.defineProperty(target, propertyKey + prop + csvHdrPrefix, { value: lbl, writable: false });
1013
+ if (target[exportList])
1014
+ target[exportList].push(propertyKey + prop + csvVisPrefix);
1015
+ else
1016
+ target[exportList] = [propertyKey + prop + csvVisPrefix];
901
1017
  }
902
1018
  }
903
1019
  };
@@ -924,6 +1040,10 @@ const ExportList = (order, headernavigator, valuenavigator, valueformat = null)
924
1040
  Object.defineProperty(target, propertyKey + listCsvValPrefix, { value: valuenavigator, writable: false });
925
1041
  Object.defineProperty(target, propertyKey + listCsvHdrPrefix, { value: headernavigator, writable: false });
926
1042
  Object.defineProperty(target, propertyKey + listCsvValFormat, { value: valueformat, writable: false });
1043
+ if (target[exportList])
1044
+ target[exportList].push(propertyKey + listCsvHdrPrefix);
1045
+ else
1046
+ target[exportList] = [propertyKey + listCsvHdrPrefix];
927
1047
  };
928
1048
  /**
929
1049
  * Decoratore di esportazione utilizzabile su un dizionario. Se ad esempio si vogliono generare le colonne
@@ -944,6 +1064,10 @@ const ExportDictionary = (order, headernavigator, valuenavigator) => (target, pr
944
1064
  Object.defineProperty(target, propertyKey + csvOrdPrefix, { value: order, writable: false });
945
1065
  Object.defineProperty(target, propertyKey + dictionaryCsvValPrefix, { value: valuenavigator, writable: false });
946
1066
  Object.defineProperty(target, propertyKey + dictionaryCsvHdrPrefix, { value: headernavigator, writable: false });
1067
+ if (target[exportList])
1068
+ target[exportList].push(propertyKey + dictionaryCsvHdrPrefix);
1069
+ else
1070
+ target[exportList] = [propertyKey + dictionaryCsvHdrPrefix];
947
1071
  };
948
1072
  /**
949
1073
  * Service che si occupa dell'esportazione degli oggetti marcati dai Decoratori **ExportDictionary**, **ExportList**, **ExportAs** o **Export**
@@ -964,15 +1088,19 @@ class ExportService {
964
1088
  *
965
1089
  * @returns {CsvHeaders[]} Header di esportazione già ordinati correttamente
966
1090
  */
967
- setupForExport(objs) {
1091
+ setupForExport(objs, columns = []) {
968
1092
  let headers = [];
969
1093
  let headersCache = {};
970
1094
  if (!objs || objs.length == 0)
971
1095
  return headers;
972
1096
  // Devo per forza farlo per tutti gli oggetti dato che devo esporre le proprietà che mi servono da esportare
973
1097
  // Gli header li raccolgo tutti poi faccio uan distinct in modo da esportare tutte le proprietà per bene
1098
+ let columnSelectionDictionary = {};
1099
+ if ((columns === null || columns === void 0 ? void 0 : columns.length) > 0)
1100
+ for (let i = 0; i < (columns === null || columns === void 0 ? void 0 : columns.length); i++)
1101
+ columnSelectionDictionary[columns[i]] = true;
974
1102
  for (let i = 0; i < objs.length; i++) {
975
- let hds = this.parseAndGetHeaders(objs[i]);
1103
+ let hds = this.parseAndGetHeaders(objs[i], columnSelectionDictionary);
976
1104
  // Aggiungo gli header facendo in modo di non aggiungerne mai due uguali per non dover fare una distinct dopo
977
1105
  // che costerebbe comunque risorse. Utilizzo un dizionario d'appoggio per lookup istantanei
978
1106
  for (let k = 0; k < hds.length; k++) {
@@ -982,7 +1110,23 @@ class ExportService {
982
1110
  }
983
1111
  }
984
1112
  }
985
- return headers.sort((a, b) => a.order - b.order);
1113
+ if (!columns || columns.length == 0)
1114
+ return headers.sort((a, b) => a.order - b.order);
1115
+ else {
1116
+ // Se mi arriva la lista di colonne non mi dà solo la visibilità, ma anche l'ordinamento
1117
+ // le esporto di conseguenza
1118
+ let orderedHeaders = [];
1119
+ for (let i = 0; i < columns.length; i++) {
1120
+ let thisId = columns[i];
1121
+ for (let i = 0; i < headers.length; i++) {
1122
+ if (headers[i].propKey == thisId) {
1123
+ orderedHeaders.push(headers[i]);
1124
+ break;
1125
+ }
1126
+ }
1127
+ }
1128
+ return orderedHeaders;
1129
+ }
986
1130
  }
987
1131
  /**
988
1132
  * 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**
@@ -1023,7 +1167,7 @@ class ExportService {
1023
1167
  columns.forEach(t => {
1024
1168
  var propValue = obj.properties[t.key];
1025
1169
  Object.defineProperty(obj, t.key + "_exp", { value: propValue, writable: false, enumerable: true });
1026
- headers.push({ label: t.label, key: t.key + "_exp", order: t.order, type: t.type });
1170
+ headers.push({ label: t.label, key: t.key + "_exp", order: t.order, type: t.type, propKey: null });
1027
1171
  });
1028
1172
  //Tirati fuori tutti gli header faccio sort sull'ordinamento
1029
1173
  return headers.sort((a, b) => { return a.order - b.order; });
@@ -1037,14 +1181,14 @@ class ExportService {
1037
1181
  *
1038
1182
  * @returns {CsvHeaders[]} Header di esportazione già ordinati correttamente
1039
1183
  */
1040
- parseAndGetHeaders(obj) {
1184
+ parseAndGetHeaders(obj, columnsSelection) {
1041
1185
  var headers = [];
1042
1186
  // Miracle incoming
1043
- let propsDictionary = Object.getOwnPropertyNames(Object.getPrototypeOf(obj));
1044
- for (var propId in propsDictionary) {
1045
- if (!propsDictionary.hasOwnProperty(propId))
1046
- continue;
1047
- let prop = propsDictionary[propId];
1187
+ let exportProps = obj[exportList] || [];
1188
+ if (exportProps.length == 0)
1189
+ console.warn("[@esfaenza/extensions] Nessuna colonna configurata da esportare!");
1190
+ for (let i = 0; i < exportProps.length; i++) {
1191
+ let prop = exportProps[i];
1048
1192
  let propBase = "";
1049
1193
  let toCall;
1050
1194
  if (prop.endsWith(listCsvHdrPrefix)) {
@@ -1063,7 +1207,7 @@ class ExportService {
1063
1207
  toCall = this.parseProperty.bind(this);
1064
1208
  }
1065
1209
  if (toCall)
1066
- toCall(obj, propBase, headers);
1210
+ toCall(obj, propBase, headers, columnsSelection);
1067
1211
  }
1068
1212
  return headers;
1069
1213
  }
@@ -1075,9 +1219,14 @@ class ExportService {
1075
1219
  * @param {string} prop Proprietà da esportare
1076
1220
  * @param {CsvHeaders} headers Contenitore degli header, verrà riempito da questa funzione
1077
1221
  */
1078
- parseProperty(obj, prop, headers) {
1222
+ parseProperty(obj, prop, headers, columnsSelection) {
1079
1223
  let toEmit = obj[prop + csvVisPrefix];
1080
1224
  let format = obj[prop + csvFormatPrefix];
1225
+ let propKey = obj[prop + csvPropKey];
1226
+ if (propKey && !columnsSelection[propKey] && Object.keys(columnsSelection).length > 0) {
1227
+ console.log("[@esfaenza/extensions] Colonna da non esportare: " + propKey);
1228
+ return;
1229
+ }
1081
1230
  let lbl = obj[prop + csvHdrPrefix];
1082
1231
  let order = obj[prop + csvOrdPrefix];
1083
1232
  if (toEmit && lbl !== "undefined") {
@@ -1086,7 +1235,7 @@ class ExportService {
1086
1235
  // Se è un formato data mi assicuro di non stampare mai una data 00:00:00 altrimenti in esportazione viene uno schifo
1087
1236
  var val = obj[prop] ? this.dates.trimSeconds(obj[prop].toString()) : "";
1088
1237
  Object.defineProperty(obj, prop + "_nofmt", { value: val, writable: false, enumerable: true });
1089
- headers.push({ label: lbl ? lbl : prop + "_nofmt", key: prop + "_nofmt", order: order, type: "string" });
1238
+ headers.push({ label: lbl ? lbl : prop + "_nofmt", key: prop + "_nofmt", order: order, type: "string", propKey: propKey });
1090
1239
  }
1091
1240
  else {
1092
1241
  // Caso formato numerico
@@ -1098,7 +1247,7 @@ class ExportService {
1098
1247
  // Il singolo punto che c'è, se presente (separatore decimali) lo trasformo in virgola
1099
1248
  let valConverted = val.replace(".", ",");
1100
1249
  Object.defineProperty(obj, prop + "_fmt", { value: valConverted, writable: false, enumerable: true });
1101
- headers.push({ label: lbl ? lbl : prop + "_fmt", key: prop + "_fmt", order: order, type: "number" });
1250
+ headers.push({ label: lbl ? lbl : prop + "_fmt", key: prop + "_fmt", order: order, type: "number", propKey: propKey });
1102
1251
  }
1103
1252
  else {
1104
1253
  // Se ho un formato data trasformo in dayjs, formatto ed esporto
@@ -1106,7 +1255,7 @@ class ExportService {
1106
1255
  // Se non funziona provo a definirgli la formattazione standard del metering per quel linguaggio
1107
1256
  let val = this.dates.getFormatted(obj[prop], format.length <= 10, format.length > 16);
1108
1257
  Object.defineProperty(obj, prop + "_fmt", { value: val !== null && val !== void 0 ? val : "", writable: false, enumerable: true });
1109
- headers.push({ label: lbl ? lbl : prop + "_fmt", key: prop + "_fmt", order: order, type: "date" });
1258
+ headers.push({ label: lbl ? lbl : prop + "_fmt", key: prop + "_fmt", order: order, type: "date", propKey: propKey });
1110
1259
  }
1111
1260
  }
1112
1261
  }
@@ -1150,8 +1299,8 @@ class ExportService {
1150
1299
  value = this.dates.getFormatted(value, format.length <= 10, format.length > 16);
1151
1300
  type = "date";
1152
1301
  }
1153
- Object.defineProperty(obj, prop, { value: value, writable: false, enumerable: true });
1154
- headers.push({ label: lbl ? lbl : prop, key: prop, order: order, type: type });
1302
+ Object.defineProperty(obj, prop, { value: value !== null && value !== void 0 ? value : "", writable: false, enumerable: true });
1303
+ headers.push({ label: lbl ? lbl : prop, key: prop, order: order, type: type, propKey: null });
1155
1304
  }
1156
1305
  /**
1157
1306
  * Setup per l'esportazione di una lista di valori pivottati dinamicamente:
@@ -1204,8 +1353,8 @@ class ExportService {
1204
1353
  value = this.dates.getFormatted(obj[prop], valueformat.length <= 10, valueformat.length > 16);
1205
1354
  type = "date";
1206
1355
  }
1207
- Object.defineProperty(obj, prop + idx, { value: value, writable: false });
1208
- headers.push({ label: header, key: prop + idx, order: order + idx, type: type });
1356
+ Object.defineProperty(obj, prop + idx, { value: value !== null && value !== void 0 ? value : "", writable: false });
1357
+ headers.push({ label: header, key: prop + idx, order: order + idx, type: type, propKey: null });
1209
1358
  }
1210
1359
  }
1211
1360
  /**
@@ -1251,8 +1400,8 @@ class ExportService {
1251
1400
  jumps.forEach(pp => { tmpRes = tmpRes[pp]; });
1252
1401
  let value = tmpRes;
1253
1402
  let propname = prop + idx.toString() + idxinternal.toString();
1254
- Object.defineProperty(obj, propname, { value: value, writable: false });
1255
- headers.push({ label: header + " " + desc, key: propname, order: order + idx, type: 'string' });
1403
+ Object.defineProperty(obj, propname, { value: value !== null && value !== void 0 ? value : "", writable: false });
1404
+ headers.push({ label: header + " " + desc, key: propname, order: order + idx, type: 'string', propKey: null });
1256
1405
  });
1257
1406
  }
1258
1407
  }
@@ -1269,9 +1418,9 @@ class ExportService {
1269
1418
  return Deserialize(items, type);
1270
1419
  }
1271
1420
  }
1272
- ExportService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ExportService, deps: [{ token: DateService }], target: i0.ɵɵFactoryTarget.Injectable });
1273
- ExportService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ExportService });
1274
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ExportService, decorators: [{
1421
+ ExportService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ExportService, deps: [{ token: DateService }], target: i0.ɵɵFactoryTarget.Injectable });
1422
+ ExportService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ExportService });
1423
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ExportService, decorators: [{
1275
1424
  type: Injectable
1276
1425
  }], ctorParameters: function () { return [{ type: DateService }]; } });
1277
1426
 
@@ -1576,9 +1725,9 @@ class HashingService {
1576
1725
  return (a + b) & 0xFFFFFFFF;
1577
1726
  }
1578
1727
  }
1579
- HashingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: HashingService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1580
- HashingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: HashingService });
1581
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: HashingService, decorators: [{
1728
+ HashingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HashingService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1729
+ HashingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HashingService });
1730
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HashingService, decorators: [{
1582
1731
  type: Injectable
1583
1732
  }] });
1584
1733
 
@@ -1827,9 +1976,9 @@ class UtilityService {
1827
1976
  return destination;
1828
1977
  }
1829
1978
  }
1830
- UtilityService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: UtilityService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1831
- UtilityService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: UtilityService });
1832
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: UtilityService, decorators: [{
1979
+ UtilityService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UtilityService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1980
+ UtilityService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UtilityService });
1981
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UtilityService, decorators: [{
1833
1982
  type: Injectable
1834
1983
  }] });
1835
1984
 
@@ -1888,9 +2037,9 @@ class InterComService {
1888
2037
  this.outbounds[key] = new Subject();
1889
2038
  }
1890
2039
  }
1891
- InterComService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: InterComService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1892
- InterComService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: InterComService });
1893
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: InterComService, decorators: [{
2040
+ InterComService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: InterComService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2041
+ InterComService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: InterComService });
2042
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: InterComService, decorators: [{
1894
2043
  type: Injectable
1895
2044
  }] });
1896
2045
 
@@ -1927,10 +2076,10 @@ class FullExtensionsModule {
1927
2076
  };
1928
2077
  }
1929
2078
  }
1930
- FullExtensionsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: FullExtensionsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1931
- FullExtensionsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.12", ngImport: i0, type: FullExtensionsModule });
1932
- FullExtensionsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: FullExtensionsModule });
1933
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: FullExtensionsModule, decorators: [{
2079
+ FullExtensionsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: FullExtensionsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2080
+ FullExtensionsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: FullExtensionsModule });
2081
+ FullExtensionsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: FullExtensionsModule });
2082
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: FullExtensionsModule, decorators: [{
1934
2083
  type: NgModule
1935
2084
  }] });
1936
2085