@esfaenza/extensions 11.2.22 → 11.2.25

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,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('ngx-toastr'), require('sweetalert2'), require('cerialize')) :
3
- typeof define === 'function' && define.amd ? define('@esfaenza/extensions', ['exports', '@angular/core', 'ngx-toastr', 'sweetalert2', 'cerialize'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.esfaenza = global.esfaenza || {}, global.esfaenza.extensions = {}), global.ng.core, global.ngxToastr, global.swal, global.cerialize));
5
- }(this, (function (exports, core, ngxToastr, swal, cerialize) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('ngx-toastr'), require('sweetalert2'), require('rxjs'), require('rxjs/operators'), require('cerialize')) :
3
+ typeof define === 'function' && define.amd ? define('@esfaenza/extensions', ['exports', '@angular/core', 'ngx-toastr', 'sweetalert2', 'rxjs', 'rxjs/operators', 'cerialize'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.esfaenza = global.esfaenza || {}, global.esfaenza.extensions = {}), global.ng.core, global.ngxToastr, global.swal, global.rxjs, global.rxjs.operators, global.cerialize));
5
+ }(this, (function (exports, core, ngxToastr, swal, rxjs, operators, cerialize) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -267,6 +267,15 @@
267
267
  onerror();
268
268
  });
269
269
  };
270
+ /**
271
+ * Mostra un messaggio di avviso con richiesta di conferma e gestisce il risultato chiamato i callback **onsuccess** o **onerror**
272
+ *
273
+ * @param {string} title Titolo del messaggio
274
+ * @param {string} text Contenuto del messaggio
275
+ */
276
+ MessageService.prototype.observableSimpleWarningWithChoice = function (title, text) {
277
+ return rxjs.of(this.warningSwalWithCancel.fire(title, text)).pipe(operators.map(function (t) { return !!t.value; }));
278
+ };
270
279
  /**
271
280
  * Mostra un messaggio di avviso che la sessione corrente è scaduta e propone all'utente di navigare al login. Qualora l'utente decidesse di farlo
272
281
  * verrà chiamata la funzione di callback **onnavigate
@@ -710,7 +719,7 @@
710
719
  tryThis = toCall(date, this.cfg.smallDate);
711
720
  else if (length == this.cfg.fulldateNoSS.length)
712
721
  tryThis = toCall(date, this.cfg.fulldateNoSS);
713
- if (tryThis.isValid())
722
+ if (tryThis && tryThis.isValid())
714
723
  return tryThis;
715
724
  // Se niente funziona, null.
716
725
  // Ricondurre l'Input ad una data non è possibile.
@@ -1788,6 +1797,67 @@
1788
1797
  { type: core.Injectable }
1789
1798
  ];
1790
1799
 
1800
+ /** Classe che rappresenta un generico messaggio scambiato fra applicazione e moduli */
1801
+ var InterComMessage = /** @class */ (function () {
1802
+ /**
1803
+ * Costruttore
1804
+ *
1805
+ * @param type Tipo di messaggio
1806
+ * @param message Contenuto del messaggio
1807
+ */
1808
+ function InterComMessage(type, message) {
1809
+ this.type = type;
1810
+ this.message = message;
1811
+ }
1812
+ return InterComMessage;
1813
+ }());
1814
+
1815
+ // Angular
1816
+ /** Service che si occupa di gestire la comunicazione fra i moduli interni ed esterni dell'applicativo */
1817
+ var InterComService = /** @class */ (function () {
1818
+ function InterComService() {
1819
+ /** Messaggi in uscita, uno per ogni recipient registratosi dall'entrypoint **register** */
1820
+ this.outbounds = {};
1821
+ /** Messaggi in entrata, unico per applicazione principale */
1822
+ this.inbounds = new rxjs.Subject();
1823
+ }
1824
+ /**
1825
+ * Metodo che permette di inviare un messaggio dall'applicazione ad un modulo esterno o viceversa
1826
+ *
1827
+ * @param {any} messageType Tipologia di messaggio. Sarà di tipo **InboundMessageTypes** per tutti i messaggi inbound, dinamico per tutti i mesaggi outbound (il tipo dipenderà dagli enum dei messaggi dei moduli esterni)
1828
+ * @param {any} message Messaggio da inviare che può essere un dto in casi complessi ma dovrà essere gestito a dovere lato implementativo
1829
+ * @param {string} recipient Destinatario del messaggio. Per i messaggi inbound dev'essere lasciato vuoto, per i messaggi outbound sarà valorizzato alla chiave del modulo a cui si vuole inviare il messaggio
1830
+ */
1831
+ InterComService.prototype.send = function (messageType, message, recipient) {
1832
+ var msg = new InterComMessage(messageType, message);
1833
+ // Se non c'è un recipient significa che è un modulo esterno che invia messaggi al modulo main (quindi messaggio in entrata - inbound)
1834
+ // Altrimenti significa che è il modulo main ad inviare messaggi ai moduli esterni (messaggio in uscita - outbound)
1835
+ if (!recipient) {
1836
+ this.inbounds.next(msg);
1837
+ }
1838
+ else {
1839
+ if (!this.outbounds[recipient])
1840
+ console.warn("@esfaenza/extensions - InterComService: Impossibile inviare il messaggio al recipient " + recipient + " assicurarsi che il modulo sia caricato e che effettui la chiamata al metodo 'regisster'");
1841
+ else
1842
+ this.outbounds[recipient].next(msg);
1843
+ }
1844
+ };
1845
+ /**
1846
+ * Permette di registrare un modulo esterno alla lista dei moduli in listening sulla coda di messaggi
1847
+ *
1848
+ * @param {string} key Chiave del modulo da registrare. Tutti i messaggi inbound saranno inviati dall'applicazione principale su questa chiave
1849
+ */
1850
+ InterComService.prototype.register = function (key) {
1851
+ if (this.outbounds[key])
1852
+ throw "@esfaenza/extensions - InterComService: Impossibile registrare più volte lo stesso modulo";
1853
+ this.outbounds[key] = new rxjs.Subject();
1854
+ };
1855
+ return InterComService;
1856
+ }());
1857
+ InterComService.decorators = [
1858
+ { type: core.Injectable }
1859
+ ];
1860
+
1791
1861
  // Angular
1792
1862
  /**
1793
1863
  * Modulo di estensione che registra autonomamente **TUTTI** i servizi di estensione:
@@ -1797,6 +1867,7 @@
1797
1867
  * HashingService,
1798
1868
  * MessageService,
1799
1869
  * UtilityService
1870
+ * InterComService
1800
1871
  *
1801
1872
  * con eventuali provider che utilizzano
1802
1873
  */
@@ -1813,6 +1884,7 @@
1813
1884
  HashingService,
1814
1885
  MessageService,
1815
1886
  UtilityService,
1887
+ InterComService,
1816
1888
  { provide: EXT_LOCALE, useValue: (config === null || config === void 0 ? void 0 : config.locale) || 'it-IT' },
1817
1889
  { provide: EXT_FANCY_ALERTS, useValue: (config === null || config === void 0 ? void 0 : config.fancy_alerts) || true },
1818
1890
  { provide: APPSEARCH_PREFIX, useValue: (config === null || config === void 0 ? void 0 : config.appsearch_prefix) || 'Hot' },
@@ -1853,6 +1925,13 @@
1853
1925
  return GenericItem;
1854
1926
  }());
1855
1927
 
1928
+ /** Enumeratore dei tipi di messaggio che i moduli esterni possono contattare sull'applicazione principale */
1929
+ exports.InboundMessageTypes = void 0;
1930
+ (function (InboundMessageTypes) {
1931
+ /** Evento di navigazione */
1932
+ InboundMessageTypes[InboundMessageTypes["Navigation"] = 0] = "Navigation";
1933
+ })(exports.InboundMessageTypes || (exports.InboundMessageTypes = {}));
1934
+
1856
1935
  /*
1857
1936
  * Public API Surface of extensions
1858
1937
  */
@@ -1878,6 +1957,8 @@
1878
1957
  exports.FullExtensionsModule = FullExtensionsModule;
1879
1958
  exports.GenericItem = GenericItem;
1880
1959
  exports.HashingService = HashingService;
1960
+ exports.InterComMessage = InterComMessage;
1961
+ exports.InterComService = InterComService;
1881
1962
  exports.MessageService = MessageService;
1882
1963
  exports.UtilityService = UtilityService;
1883
1964