@esfaenza/extensions 19.2.29 → 20.3.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,13 +1,14 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, Optional, Inject, Injectable, Pipe, NgModule, Injector } from '@angular/core';
2
+ import { InjectionToken, Optional, Inject, Injectable, Pipe, NgModule, Injector, PLATFORM_ID } from '@angular/core';
3
3
  import * as i1 from '@esfaenza/localizations';
4
4
  import { LocalizationModule } from '@esfaenza/localizations';
5
5
  import { first, filter, take, map } from 'rxjs/operators';
6
6
  import { ReplaySubject, of, Subject, filter as filter$1 } from 'rxjs';
7
+ import * as i3 from '@angular/common';
8
+ import { isPlatformBrowser } from '@angular/common';
7
9
  import { ToastrService } from 'ngx-toastr';
8
10
  import swal from 'sweetalert2';
9
11
  import * as i2 from '@angular/router';
10
- import * as i3 from '@angular/common';
11
12
  import * as XLSX from 'xlsx';
12
13
 
13
14
  /**
@@ -249,10 +250,10 @@ class DateService {
249
250
  return null;
250
251
  return date.format(small ? this.cfg.smallDate : seconds ? this.cfg.fulldateDisplay : this.cfg.fulldateDisplayNoSS);
251
252
  }
252
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: DateService, deps: [{ token: i1.BaseLocalization, optional: true }, { token: EXT_ALLOW_UTC, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
253
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: DateService, providedIn: "root" });
253
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: DateService, deps: [{ token: i1.BaseLocalization, optional: true }, { token: EXT_ALLOW_UTC, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
254
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: DateService, providedIn: "root" });
254
255
  }
255
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: DateService, decorators: [{
256
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: DateService, decorators: [{
256
257
  type: Injectable,
257
258
  args: [{ providedIn: "root" }]
258
259
  }], ctorParameters: () => [{ type: i1.BaseLocalization, decorators: [{
@@ -291,10 +292,10 @@ class LocDatePipe {
291
292
  var dt = this.dts.getDateConvertion(detatchedValue);
292
293
  return dt.format(format);
293
294
  }
294
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: LocDatePipe, deps: [{ token: DateService }], target: i0.ɵɵFactoryTarget.Pipe });
295
- static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.15", ngImport: i0, type: LocDatePipe, isStandalone: false, name: "loc_date" });
295
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: LocDatePipe, deps: [{ token: DateService }], target: i0.ɵɵFactoryTarget.Pipe });
296
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.3.13", ngImport: i0, type: LocDatePipe, isStandalone: false, name: "loc_date" });
296
297
  }
297
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: LocDatePipe, decorators: [{
298
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: LocDatePipe, decorators: [{
298
299
  type: Pipe,
299
300
  args: [{
300
301
  name: "loc_date", pure: true,
@@ -314,11 +315,11 @@ class ExtensionsModule {
314
315
  ]
315
316
  };
316
317
  }
317
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ExtensionsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
318
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.15", ngImport: i0, type: ExtensionsModule, declarations: [LocDatePipe], imports: [LocalizationModule], exports: [LocDatePipe] });
319
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ExtensionsModule, imports: [LocalizationModule] });
318
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: ExtensionsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
319
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.13", ngImport: i0, type: ExtensionsModule, declarations: [LocDatePipe], imports: [LocalizationModule], exports: [LocDatePipe] });
320
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: ExtensionsModule, imports: [LocalizationModule] });
320
321
  }
321
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ExtensionsModule, decorators: [{
322
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: ExtensionsModule, decorators: [{
322
323
  type: NgModule,
323
324
  args: [{
324
325
  imports: [LocalizationModule],
@@ -625,10 +626,10 @@ class HashingService {
625
626
  add32(a, b) {
626
627
  return (a + b) & 0xFFFFFFFF;
627
628
  }
628
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: HashingService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
629
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: HashingService, providedIn: "root" });
629
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: HashingService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
630
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: HashingService, providedIn: "root" });
630
631
  }
631
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: HashingService, decorators: [{
632
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: HashingService, decorators: [{
632
633
  type: Injectable,
633
634
  args: [{ providedIn: "root" }]
634
635
  }] });
@@ -673,12 +674,20 @@ class MessageService {
673
674
  Embedded = false;
674
675
  MainWindow = null;
675
676
  MessageObserver = null;
677
+ isBrowser = true;
676
678
  /** Costruttore @ignore */
677
- constructor(injector, locProvider, hash) {
679
+ constructor(injector, locProvider, hash, platformId) {
678
680
  this.injector = injector;
679
681
  this.locProvider = locProvider;
680
682
  this.hash = hash;
681
- this.init();
683
+ this.isBrowser = isPlatformBrowser(platformId);
684
+ if (this.isBrowser)
685
+ this.init();
686
+ }
687
+ browserCheck() {
688
+ if (!this.isBrowser)
689
+ console.error("@esfaenza/extensions MessageService is only able to display browser messages at this time. Since you are not running in a browser, all functions witll do nothing");
690
+ return this.isBrowser;
682
691
  }
683
692
  configureEmbeddability(mainWindow, messageObserver) {
684
693
  this.Embedded = true;
@@ -786,6 +795,8 @@ class MessageService {
786
795
  * @param {"toastr" | "swal" | null} secondaryNotificationType Qualora sia una notifica secondaria, ne indica il tipo
787
796
  */
788
797
  simpleSuccess(text, secondaryNotificationType = null, secondaryNotificationTimeout = null) {
798
+ if (!this.browserCheck())
799
+ return;
789
800
  if (this.Embedded) {
790
801
  this.MainWindow.postMessage({ type: "alert", level: 'success', msg: text }, "*");
791
802
  return;
@@ -806,6 +817,8 @@ class MessageService {
806
817
  * @param {"toastr" | "swal" | null} secondaryNotificationType Qualora sia una notifica secondaria, ne indica il tipo
807
818
  */
808
819
  simpleInfo(text, secondaryNotificationType = null, secondaryNotificationTimeout = null) {
820
+ if (!this.browserCheck())
821
+ return;
809
822
  if (this.Embedded) {
810
823
  this.MainWindow.postMessage({ type: "alert", level: 'info', msg: text }, "*");
811
824
  return;
@@ -826,6 +839,8 @@ class MessageService {
826
839
  * @param {"toastr" | "swal" | null} secondaryNotificationType Qualora sia una notifica secondaria, ne indica il tipo
827
840
  */
828
841
  simpleError(text, secondaryNotificationType = null, secondaryNotificationTimeout = null) {
842
+ if (!this.browserCheck())
843
+ return;
829
844
  if (this.Embedded) {
830
845
  this.MainWindow.postMessage({ type: "alert", level: 'error', msg: text }, "*");
831
846
  return;
@@ -846,6 +861,8 @@ class MessageService {
846
861
  * @param {"toastr" | "swal" | null} secondaryNotificationType Qualora sia una notifica secondaria, ne indica il tipo
847
862
  */
848
863
  simpleWarning(text, secondaryNotificationType = null, secondaryNotificationTimeout = null) {
864
+ if (!this.browserCheck())
865
+ return;
849
866
  if (this.Embedded) {
850
867
  this.MainWindow.postMessage({ type: "alert", level: 'warning', msg: text }, "*");
851
868
  return;
@@ -860,6 +877,8 @@ class MessageService {
860
877
  * Ripulisce tutti i messaggi presenti in un dato momento sullo schermo
861
878
  */
862
879
  clearMessages() {
880
+ if (!this.browserCheck())
881
+ return;
863
882
  this.toastr.clear();
864
883
  swal.close();
865
884
  }
@@ -872,6 +891,8 @@ class MessageService {
872
891
  * @returns {Promise} Restituisce una Promise col risultato scelto dall'utente (conferma o no)
873
892
  */
874
893
  promiseWarningWithChoice(title, text) {
894
+ if (!this.browserCheck())
895
+ return;
875
896
  return this.warningSwalWithCancel.fire(title, text);
876
897
  }
877
898
  /**
@@ -888,9 +909,13 @@ class MessageService {
888
909
  }
889
910
  GuidRepsonseFunctionsMap = {};
890
911
  simpleWarningWithChoice(title, text, onsuccess, onerror, confirmtext = "", aborttext = '') {
912
+ if (!this.browserCheck())
913
+ return;
891
914
  this.withChoiceBase("warning", title, text, onsuccess, onerror, confirmtext, aborttext);
892
915
  }
893
916
  simpleSuccessWithChoice(title, text, onsuccess, onerror, confirmtext = "", aborttext = '') {
917
+ if (!this.browserCheck())
918
+ return;
894
919
  this.withChoiceBase("success", title, text, onsuccess, onerror, confirmtext, aborttext);
895
920
  }
896
921
  withChoiceBase(level, title, text, onsuccess, onerror, confirmtext = "", aborttext = '') {
@@ -969,6 +994,8 @@ class MessageService {
969
994
  * @param {string} text Contenuto del messaggio
970
995
  */
971
996
  observableSimpleWarningWithChoice(title, text) {
997
+ if (!this.browserCheck())
998
+ return of(false);
972
999
  return of(this.warningSwalWithCancel.fire(title, text)).pipe(map(t => !!t.value));
973
1000
  }
974
1001
  /**
@@ -980,6 +1007,8 @@ class MessageService {
980
1007
  * @param {Function} onnavigate Callback da chimare su navigazione in corso
981
1008
  */
982
1009
  expiredSessionMessage(title, text, onnavigate = null) {
1010
+ if (!this.browserCheck())
1011
+ return;
983
1012
  this.expiredSessionSwal.fire(title, text).then((result) => {
984
1013
  if (result.value && onnavigate)
985
1014
  onnavigate();
@@ -995,6 +1024,8 @@ class MessageService {
995
1024
  * @param {Function} postFailure Callback da chimare in caso di fallimento
996
1025
  */
997
1026
  manageCallResultResponse(response, successMsg, errorMsg, postSuccess = null, postFailure = null) {
1027
+ if (!this.browserCheck())
1028
+ return;
998
1029
  let anyReponse = response;
999
1030
  if (response.success || anyReponse.Success) {
1000
1031
  if (response.haswarning || anyReponse.HasWarning)
@@ -1024,6 +1055,8 @@ class MessageService {
1024
1055
  * @param {Function} postFailure Callback da chimare in caso di fallimento
1025
1056
  */
1026
1057
  manageStringResponse(response, successMsg, errorMsg, postSuccess = null, postFailure = null) {
1058
+ if (!this.browserCheck())
1059
+ return;
1027
1060
  if (!response) {
1028
1061
  if (successMsg)
1029
1062
  this.simpleSuccess(successMsg);
@@ -1047,6 +1080,8 @@ class MessageService {
1047
1080
  * @param {Function} postFailure Callback da chimare in caso di fallimento
1048
1081
  */
1049
1082
  manageStringResponseBool(response, successMsg, errorMsg, postSuccess = null, postFailure = null) {
1083
+ if (!this.browserCheck())
1084
+ return;
1050
1085
  if (response) {
1051
1086
  if (successMsg)
1052
1087
  this.simpleSuccess(successMsg);
@@ -1060,10 +1095,10 @@ class MessageService {
1060
1095
  postFailure();
1061
1096
  }
1062
1097
  }
1063
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: MessageService, deps: [{ token: Injector }, { token: i1.BaseLocalization, optional: true }, { token: HashingService }], target: i0.ɵɵFactoryTarget.Injectable });
1064
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: MessageService, providedIn: "root" });
1098
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: MessageService, deps: [{ token: Injector }, { token: i1.BaseLocalization, optional: true }, { token: HashingService }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
1099
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: MessageService, providedIn: "root" });
1065
1100
  }
1066
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: MessageService, decorators: [{
1101
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: MessageService, decorators: [{
1067
1102
  type: Injectable,
1068
1103
  args: [{ providedIn: "root" }]
1069
1104
  }], ctorParameters: () => [{ type: i0.Injector, decorators: [{
@@ -1071,7 +1106,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
1071
1106
  args: [Injector]
1072
1107
  }] }, { type: i1.BaseLocalization, decorators: [{
1073
1108
  type: Optional
1074
- }] }, { type: HashingService }] });
1109
+ }] }, { type: HashingService }, { type: Object, decorators: [{
1110
+ type: Inject,
1111
+ args: [PLATFORM_ID]
1112
+ }] }] });
1075
1113
 
1076
1114
  // Angular
1077
1115
  /* Classe che contiene tutte le informazioni sull'embedding in un unico contenitore per semplicità */
@@ -1088,10 +1126,14 @@ class AppEmbeddingExtensions {
1088
1126
  _reloadAllowed = true;
1089
1127
  EmbeddedModule;
1090
1128
  pushedHistories = [];
1091
- constructor(msgService, router, location) {
1129
+ isBrowser = true;
1130
+ constructor(msgService, router, location, platformId) {
1092
1131
  this.msgService = msgService;
1093
1132
  this.router = router;
1094
1133
  this.location = location;
1134
+ this.isBrowser = isPlatformBrowser(platformId);
1135
+ if (!this.isBrowser)
1136
+ return;
1095
1137
  this.MainWindow = window;
1096
1138
  while (this.MainWindow.parent != this.MainWindow) {
1097
1139
  this.MainWindow = this.MainWindow.parent;
@@ -1122,6 +1164,8 @@ class AppEmbeddingExtensions {
1122
1164
  });
1123
1165
  }
1124
1166
  waitForMyConfigAndForceEmbeddedModule() {
1167
+ if (!this.isBrowser)
1168
+ return;
1125
1169
  // Aspetto di ricevere il myconfig e setto con lui l'embeddedmodule. Questo viene eseguito solo se this.location.path() per qualche motivo non contiene il module
1126
1170
  let interval = setInterval(() => {
1127
1171
  if (myconfig?.AppData?.ModuleId) {
@@ -1141,6 +1185,8 @@ class AppEmbeddingExtensions {
1141
1185
  return `${JSON.parse(JSON.stringify(event?.data))}`;
1142
1186
  }
1143
1187
  configureEmbeddability() {
1188
+ if (!this.isBrowser)
1189
+ return;
1144
1190
  if (this.Embedded)
1145
1191
  this.MainWindow.postMessage({ type: "whois" }, "*");
1146
1192
  else
@@ -1297,6 +1343,8 @@ class AppEmbeddingExtensions {
1297
1343
  document.body.style.setProperty("overflow-y", "auto", "important");
1298
1344
  }
1299
1345
  onNavigateBack() {
1346
+ if (!this.isBrowser)
1347
+ return;
1300
1348
  if (history?.state?._pushed) {
1301
1349
  this._reloadAllowed = false;
1302
1350
  this.pushedHistories.pop();
@@ -1304,6 +1352,8 @@ class AppEmbeddingExtensions {
1304
1352
  }
1305
1353
  }
1306
1354
  replaceState(basePath, url) {
1355
+ if (!this.isBrowser)
1356
+ return;
1307
1357
  // Esempio basePath: pages
1308
1358
  // Esempio url: parties/leads_search
1309
1359
  // Normalizzazione senza slash prima o dopo
@@ -1313,6 +1363,8 @@ class AppEmbeddingExtensions {
1313
1363
  this.MainWindow.postMessage({ type: "replace-state", url: `pages/embed/${this.EmbeddedModule}/${url}` }, "*");
1314
1364
  }
1315
1365
  refreshBoundariesOnMenuCollapse() {
1366
+ if (!this.isBrowser)
1367
+ return;
1316
1368
  const wrapper = document.body.getElementsByClassName("main-wrapper")[0];
1317
1369
  let wrapperStyles = window.getComputedStyle(wrapper);
1318
1370
  const wrapperPaddingLeft = parseInt(wrapperStyles.getPropertyValue("padding-left"));
@@ -1326,17 +1378,20 @@ class AppEmbeddingExtensions {
1326
1378
  if (left)
1327
1379
  left.style.setProperty("width", leftSpace + "px");
1328
1380
  }
1329
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: AppEmbeddingExtensions, deps: [{ token: MessageService }, { token: i2.Router }, { token: i3.Location }], target: i0.ɵɵFactoryTarget.Injectable });
1330
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: AppEmbeddingExtensions, providedIn: "root" });
1381
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: AppEmbeddingExtensions, deps: [{ token: MessageService }, { token: i2.Router }, { token: i3.Location }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
1382
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: AppEmbeddingExtensions, providedIn: "root" });
1331
1383
  }
1332
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: AppEmbeddingExtensions, decorators: [{
1384
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: AppEmbeddingExtensions, decorators: [{
1333
1385
  type: Injectable,
1334
1386
  args: [{ providedIn: "root" }]
1335
- }], ctorParameters: () => [{ type: MessageService }, { type: i2.Router }, { type: i3.Location }] });
1387
+ }], ctorParameters: () => [{ type: MessageService }, { type: i2.Router }, { type: i3.Location }, { type: Object, decorators: [{
1388
+ type: Inject,
1389
+ args: [PLATFORM_ID]
1390
+ }] }] });
1336
1391
 
1337
1392
  // Angular
1338
1393
  /**
1339
- * Service che fornisce un accesso base in lettura/scrittura sulla clipboard
1394
+ * WIP: per razionalizzare il fill della routesmap (vedi CRM app.extensions.ts)
1340
1395
  */
1341
1396
  class BaseExtensionsService {
1342
1397
  emb;
@@ -1353,10 +1408,10 @@ class BaseExtensionsService {
1353
1408
  };
1354
1409
  }
1355
1410
  }
1356
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: BaseExtensionsService, deps: [{ token: AppEmbeddingExtensions }], target: i0.ɵɵFactoryTarget.Injectable });
1357
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: BaseExtensionsService, providedIn: "root" });
1411
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: BaseExtensionsService, deps: [{ token: AppEmbeddingExtensions }], target: i0.ɵɵFactoryTarget.Injectable });
1412
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: BaseExtensionsService, providedIn: "root" });
1358
1413
  }
1359
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: BaseExtensionsService, decorators: [{
1414
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: BaseExtensionsService, decorators: [{
1360
1415
  type: Injectable,
1361
1416
  args: [{ providedIn: "root" }]
1362
1417
  }], ctorParameters: () => [{ type: AppEmbeddingExtensions }] });
@@ -1427,14 +1482,14 @@ class UtilityService {
1427
1482
  * Deseleziona il testo eventualmente selezionato
1428
1483
  */
1429
1484
  clearTextSelection() {
1430
- if (window.getSelection) {
1431
- if (window.getSelection().empty) // Chrome
1432
- window.getSelection().empty();
1433
- else if (window.getSelection().removeAllRanges) // Firefox
1434
- window.getSelection().removeAllRanges();
1485
+ if (!window) {
1486
+ console.error("This function access the javascript window object which is not defined. Are you executing this outside of browser context?");
1487
+ return;
1435
1488
  }
1436
- else if (document.selection) // IE?
1437
- document.selection.empty();
1489
+ if (window.getSelection().empty) // Chrome
1490
+ window.getSelection().empty();
1491
+ else if (window.getSelection().removeAllRanges) // Firefox
1492
+ window.getSelection().removeAllRanges();
1438
1493
  }
1439
1494
  /**
1440
1495
  * Partendo da una lista, dato il nome della proprietà chiave e il valore della chiave selezionata,
@@ -1481,6 +1536,10 @@ class UtilityService {
1481
1536
  * @param {string} filename Nome del file suggerito in fase di salvataggio
1482
1537
  */
1483
1538
  fileDownload(url, fileName) {
1539
+ if (!document) {
1540
+ console.error("This function access the javascript document object which is not defined. Are you executing this outside of browser context?");
1541
+ return;
1542
+ }
1484
1543
  var a = document.createElement("a");
1485
1544
  document.body.appendChild(a);
1486
1545
  a.className = "ta-display-none";
@@ -1540,6 +1599,10 @@ class UtilityService {
1540
1599
  * @param {string} filename Nome del file suggerito in fase di salvataggio
1541
1600
  */
1542
1601
  saveByteArray(byte, filename) {
1602
+ if (!document) {
1603
+ console.error("This function access the javascript document object which is not defined. Are you executing this outside of browser context?");
1604
+ return;
1605
+ }
1543
1606
  var blob = new Blob([byte]);
1544
1607
  var link = document.createElement("a");
1545
1608
  document.body.appendChild(link);
@@ -1656,10 +1719,10 @@ class UtilityService {
1656
1719
  //Ricreo il timeout per eseguire quella funzione dopo throttleTime millisecondi
1657
1720
  this.executionTimers[id] = setTimeout(() => { func(); this.executionTimers[id] = null; }, throttleTime);
1658
1721
  }
1659
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: UtilityService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1660
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: UtilityService, providedIn: "root" });
1722
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: UtilityService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1723
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: UtilityService, providedIn: "root" });
1661
1724
  }
1662
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: UtilityService, decorators: [{
1725
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: UtilityService, decorators: [{
1663
1726
  type: Injectable,
1664
1727
  args: [{ providedIn: "root" }]
1665
1728
  }] });
@@ -2175,6 +2238,12 @@ class ExportService {
2175
2238
  * Effettua l'esportazione in file CSV
2176
2239
  */
2177
2240
  exportCSV(fn, headers, data) {
2241
+ var buffer = this.exportCSVBuffer(fn, headers, data);
2242
+ var blob = new Blob([new TextDecoder().decode(buffer)], { type: 'text/csv' });
2243
+ var objectUrl = URL.createObjectURL(blob);
2244
+ this.utiExts.fileDownload(objectUrl, fn.endsWith('.xlsx') ? fn.replace('.xlsx', '.csv') : fn.endsWith('.csv') ? fn : fn + ".csv");
2245
+ }
2246
+ exportCSVBuffer(fn, headers, data) {
2178
2247
  let csvData = '', row = '', sep = ';';
2179
2248
  for (let i = 0; i < headers.length; i++) {
2180
2249
  let h = headers[i];
@@ -2190,13 +2259,18 @@ class ExportService {
2190
2259
  }
2191
2260
  csvData += row + '\r\n';
2192
2261
  }
2193
- var BOM = new Uint8Array([0xEF, 0xBB, 0xBF]);
2194
- var blob = new Blob([BOM, csvData], { type: 'text/csv' });
2195
- var objectUrl = URL.createObjectURL(blob);
2196
- this.utiExts.fileDownload(objectUrl, fn.endsWith('.xlsx') ? fn.replace('.xlsx', '.csv') : fn.endsWith('.csv') ? fn : fn + ".csv");
2262
+ var BOM = [0xEF, 0xBB, 0xBF];
2263
+ var buffer = new Uint8Array([...BOM, ...new TextEncoder().encode(csvData)]);
2264
+ return buffer;
2197
2265
  }
2198
2266
  /** Effettua l'esportazione del file Excel basandosi sul modulo **ExcelJS**, sugli header **headers** e sui dati **data** */
2199
2267
  async exportExcel(fn, headers, data) {
2268
+ let buffer = this.exportExcelBuffer(fn, headers, data);
2269
+ let blob = new Blob([buffer], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;" });
2270
+ let objectUrl = URL.createObjectURL(blob);
2271
+ this.utiExts.fileDownload(objectUrl, fn.endsWith('.csv') ? fn.replace('.csv', '.xlsx') : fn.endsWith('.xlsx') ? fn : fn + ".xlsx");
2272
+ }
2273
+ exportExcelBuffer(fn, headers, data) {
2200
2274
  var toExport = [];
2201
2275
  headers = headers.sort((a, b) => a.order - b.order);
2202
2276
  for (let d = 0; d < data.length; d++) {
@@ -2218,9 +2292,7 @@ class ExportService {
2218
2292
  const wb = XLSX.utils.book_new();
2219
2293
  XLSX.utils.book_append_sheet(wb, ws, 'Data');
2220
2294
  let buffer = XLSX.write(wb, { bookType: 'xlsx', type: 'array', cellDates: true });
2221
- let blob = new Blob([buffer], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;" });
2222
- let objectUrl = URL.createObjectURL(blob);
2223
- this.utiExts.fileDownload(objectUrl, fn.endsWith('.csv') ? fn.replace('.csv', '.xlsx') : fn.endsWith('.xlsx') ? fn : fn + ".xlsx");
2295
+ return buffer;
2224
2296
  }
2225
2297
  /**
2226
2298
  * Metodo che effettivamente genera gli header e i dati per l'esportazione con **ngx-csv**
@@ -2234,10 +2306,21 @@ class ExportService {
2234
2306
  (format == "CSV" ? this.exportCSV : this.exportExcel).bind(this)(fileName, headers, createdItems);
2235
2307
  return headers;
2236
2308
  }
2237
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ExportService, deps: [{ token: DateService }, { token: UtilityService }, { token: i1.LocalizationService }], target: i0.ɵɵFactoryTarget.Injectable });
2238
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ExportService, providedIn: "root" });
2309
+ /**
2310
+ * Metodo che effettivamente genera gli header e i dati per l'esportazione con **ngx-csv**
2311
+ *
2312
+ * @param {any[]} items Oggetti da esportare
2313
+ */
2314
+ exportBuffer(items, format, fileName, type, columnsFilter, genericHeaders) {
2315
+ // Deepclone con assegnatura del tipo
2316
+ var createdItems = items.map(t => this.utiExts.deepClone(t, type));
2317
+ let headers = genericHeaders ? this.setupForGenericExport(createdItems, genericHeaders) : this.setupForExport(createdItems, columnsFilter);
2318
+ return (format == "CSV" ? this.exportCSVBuffer : this.exportExcelBuffer).bind(this)(fileName, headers, createdItems);
2319
+ }
2320
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: ExportService, deps: [{ token: DateService }, { token: UtilityService }, { token: i1.LocalizationService }], target: i0.ɵɵFactoryTarget.Injectable });
2321
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: ExportService, providedIn: "root" });
2239
2322
  }
2240
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ExportService, decorators: [{
2323
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: ExportService, decorators: [{
2241
2324
  type: Injectable,
2242
2325
  args: [{ providedIn: "root" }]
2243
2326
  }], ctorParameters: () => [{ type: DateService }, { type: UtilityService }, { type: i1.LocalizationService }] });
@@ -2290,14 +2373,16 @@ class ClipboardService {
2290
2373
  'it-IT': "Annulla"
2291
2374
  },
2292
2375
  };
2376
+ isBrowser = true;
2293
2377
  /**
2294
2378
  * Costruttore
2295
2379
  *
2296
2380
  * @ignore
2297
2381
  */
2298
- constructor(msgService, locProvider) {
2382
+ constructor(msgService, locProvider, platformId) {
2299
2383
  this.msgService = msgService;
2300
2384
  this.locProvider = locProvider;
2385
+ this.isBrowser = isPlatformBrowser(platformId);
2301
2386
  }
2302
2387
  /**
2303
2388
  * Prende il valore della clipboard.
@@ -2307,6 +2392,11 @@ class ClipboardService {
2307
2392
  * @param {Function} valueFoundCallback Callback che questa funzione chiamerà una volta ottenuto i valori richiesti dalla clipboard
2308
2393
  */
2309
2394
  async getClipboard(style, valueFoundCallback) {
2395
+ if (!this.isBrowser) {
2396
+ console.log("@esfaenza/extensions ClipboardService requires browser environment to function. Every call will return the default for the expected value");
2397
+ valueFoundCallback([]);
2398
+ return;
2399
+ }
2310
2400
  let LOCALE = this.locProvider ? await this.locProvider.Locale.pipe(first()).toPromise() : 'it-IT';
2311
2401
  if (navigator.userAgent.indexOf("Firefox") != -1) {
2312
2402
  swal.fire({
@@ -2400,6 +2490,10 @@ class ClipboardService {
2400
2490
  * @param {string} text Testo da inserire nella clipboard
2401
2491
  */
2402
2492
  async copyTextToClipboard(text) {
2493
+ if (!this.isBrowser) {
2494
+ console.log("@esfaenza/extensions ClipboardService requires browser environment to function. Every call will return the default for the expected value");
2495
+ return;
2496
+ }
2403
2497
  let LOCALE = this.locProvider ? await this.locProvider.Locale.pipe(first()).toPromise() : 'it-IT';
2404
2498
  var textArea = document.createElement("textarea");
2405
2499
  //
@@ -2446,14 +2540,17 @@ class ClipboardService {
2446
2540
  }
2447
2541
  document.body.removeChild(textArea);
2448
2542
  }
2449
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ClipboardService, deps: [{ token: MessageService }, { token: i1.BaseLocalization, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
2450
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ClipboardService, providedIn: "root" });
2543
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: ClipboardService, deps: [{ token: MessageService }, { token: i1.BaseLocalization, optional: true }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
2544
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: ClipboardService, providedIn: "root" });
2451
2545
  }
2452
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ClipboardService, decorators: [{
2546
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: ClipboardService, decorators: [{
2453
2547
  type: Injectable,
2454
2548
  args: [{ providedIn: "root" }]
2455
2549
  }], ctorParameters: () => [{ type: MessageService }, { type: i1.BaseLocalization, decorators: [{
2456
2550
  type: Optional
2551
+ }] }, { type: Object, decorators: [{
2552
+ type: Inject,
2553
+ args: [PLATFORM_ID]
2457
2554
  }] }] });
2458
2555
 
2459
2556
  /**
@@ -2577,10 +2674,10 @@ class InterComService {
2577
2674
  throw "@esfaenza/extensions - InterComService: Impossibile registrare più volte lo stesso modulo";
2578
2675
  this.outbounds[key] = new Subject();
2579
2676
  }
2580
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: InterComService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2581
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: InterComService, providedIn: "root" });
2677
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: InterComService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2678
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: InterComService, providedIn: "root" });
2582
2679
  }
2583
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: InterComService, decorators: [{
2680
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.13", ngImport: i0, type: InterComService, decorators: [{
2584
2681
  type: Injectable,
2585
2682
  args: [{ providedIn: "root" }]
2586
2683
  }] });