@esfaenza/extensions 11.2.25 → 11.2.28

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.
@@ -154,12 +154,12 @@ class MessageService {
154
154
  * @param {string} text Testo da mostrare
155
155
  * @param {"toastr" | "swal" | null} secondaryNotificationType Qualora sia una notifica secondaria, ne indica il tipo
156
156
  */
157
- simpleSuccess(text, secondaryNotificationType = null) {
157
+ simpleSuccess(text, secondaryNotificationType = null, secondaryNotificationTimeout = null) {
158
158
  let tos = this.toastrOrSwal(secondaryNotificationType);
159
159
  if (tos == "swal")
160
160
  this.successSwal.fire("", text);
161
161
  else
162
- this.toastr.success(text, null, { positionClass: tos == "toastr" ? "toast-top-right" : "toast-top-center", timeOut: tos == "toastr" ? 0 : 5000, extendedTimeOut: tos == "toastr" ? 0 : 1000 });
162
+ this.toastr.success(text, null, { positionClass: tos == "toastr" ? "toast-top-right" : "toast-top-center", timeOut: secondaryNotificationTimeout || (tos == "toastr" ? 0 : 5000), extendedTimeOut: tos == "toastr" ? 0 : 1000 });
163
163
  }
164
164
  /**
165
165
  * Presentazione di un semplice messaggio di informazione
@@ -170,12 +170,12 @@ class MessageService {
170
170
  * @param {string} text Testo da mostrare
171
171
  * @param {"toastr" | "swal" | null} secondaryNotificationType Qualora sia una notifica secondaria, ne indica il tipo
172
172
  */
173
- simpleInfo(text, secondaryNotificationType = null) {
173
+ simpleInfo(text, secondaryNotificationType = null, secondaryNotificationTimeout = null) {
174
174
  let tos = this.toastrOrSwal(secondaryNotificationType);
175
175
  if (tos == "swal")
176
176
  this.infoSwal.fire("", text);
177
177
  else
178
- this.toastr.info(text, null, { positionClass: tos == "toastr" ? "toast-top-right" : "toast-top-center", timeOut: tos == "toastr" ? 0 : 5000, extendedTimeOut: tos == "toastr" ? 0 : 1000 });
178
+ this.toastr.info(text, null, { positionClass: tos == "toastr" ? "toast-top-right" : "toast-top-center", timeOut: secondaryNotificationTimeout || (tos == "toastr" ? 0 : 5000), extendedTimeOut: tos == "toastr" ? 0 : 1000 });
179
179
  }
180
180
  /**
181
181
  * Presentazione di un semplice messaggio di errore
@@ -186,12 +186,12 @@ class MessageService {
186
186
  * @param {string} text Testo da mostrare
187
187
  * @param {"toastr" | "swal" | null} secondaryNotificationType Qualora sia una notifica secondaria, ne indica il tipo
188
188
  */
189
- simpleError(text, secondaryNotificationType = null) {
189
+ simpleError(text, secondaryNotificationType = null, secondaryNotificationTimeout = null) {
190
190
  let tos = this.toastrOrSwal(secondaryNotificationType);
191
191
  if (tos == "swal")
192
192
  this.errorSwal.fire("", text);
193
193
  else
194
- this.toastr.error(text, null, { positionClass: tos == "toastr" ? "toast-top-right" : "toast-top-center", timeOut: tos == "toastr" ? 0 : 5000, extendedTimeOut: tos == "toastr" ? 0 : 1000 });
194
+ this.toastr.error(text, null, { positionClass: tos == "toastr" ? "toast-top-right" : "toast-top-center", timeOut: secondaryNotificationTimeout || (tos == "toastr" ? 0 : 5000), extendedTimeOut: tos == "toastr" ? 0 : 1000 });
195
195
  }
196
196
  /**
197
197
  * Presentazione di un semplice messaggio di avviso
@@ -202,12 +202,12 @@ class MessageService {
202
202
  * @param {string} text Testo da mostrare
203
203
  * @param {"toastr" | "swal" | null} secondaryNotificationType Qualora sia una notifica secondaria, ne indica il tipo
204
204
  */
205
- simpleWarning(text, secondaryNotificationType = null) {
205
+ simpleWarning(text, secondaryNotificationType = null, secondaryNotificationTimeout = null) {
206
206
  let tos = this.toastrOrSwal(secondaryNotificationType);
207
207
  if (tos == "swal")
208
208
  this.warningSwal.fire("", text);
209
209
  else
210
- this.toastr.warning(text, null, { positionClass: tos == "toastr" ? "toast-top-right" : "toast-top-center", timeOut: tos == "toastr" ? 0 : 5000, extendedTimeOut: tos == "toastr" ? 0 : 1000 });
210
+ this.toastr.warning(text, null, { positionClass: tos == "toastr" ? "toast-top-right" : "toast-top-center", timeOut: secondaryNotificationTimeout || (tos == "toastr" ? 0 : 5000), extendedTimeOut: tos == "toastr" ? 0 : 1000 });
211
211
  }
212
212
  /**
213
213
  * Ripulisce tutti i messaggi presenti in un dato momento sullo schermo
@@ -289,7 +289,9 @@ class MessageService {
289
289
  */
290
290
  manageCallResultResponse(response, successMsg, errorMsg, postSuccess = null, postFailure = null) {
291
291
  if (response.success) {
292
- if (successMsg)
292
+ if (response.haswarning)
293
+ this.simpleWarning(response.warning);
294
+ else if (successMsg)
293
295
  this.simpleSuccess(successMsg);
294
296
  if (postSuccess)
295
297
  postSuccess();
@@ -299,9 +301,6 @@ class MessageService {
299
301
  if (postFailure)
300
302
  postFailure();
301
303
  }
302
- else if (response.haswarning) {
303
- this.simpleWarning(response.warning);
304
- }
305
304
  }
306
305
  /**
307
306
  * Metodo helper per gestire in maniera standardizzata una risposta di tipo **string**, considerando che:
@@ -695,7 +694,7 @@ class DateService {
695
694
  tryThis = toCall(date, this.cfg.smallDate);
696
695
  else if (length == this.cfg.fulldateNoSS.length)
697
696
  tryThis = toCall(date, this.cfg.fulldateNoSS);
698
- if (tryThis && tryThis.isValid())
697
+ if (tryThis && tryThis.isValid && tryThis.isValid())
699
698
  return tryThis;
700
699
  // Se niente funziona, null.
701
700
  // Ricondurre l'Input ad una data non è possibile.
@@ -1741,6 +1740,48 @@ class UtilityService {
1741
1740
  return "string";
1742
1741
  }
1743
1742
  }
1743
+ /**
1744
+ * Effettua la clonazione profonda di un oggetto in maniera molto più performante che JSON.parse(JSON.stringify()).
1745
+ *
1746
+ * Usare solo per oggetti puri e quantomeno semplici per evitare complicazioni derivanti dalle semplificazioni che questo metodo assume
1747
+ *
1748
+ * @param {any} source Oggetto da clonare
1749
+ *
1750
+ * @return {any} Clone dell'oggetto passato
1751
+ */
1752
+ deepClone(source) {
1753
+ // Valori semplici
1754
+ if (source == null || typeof source !== 'object')
1755
+ return source;
1756
+ // Pseudo Struct
1757
+ switch (toString.call(source)) {
1758
+ case '[object Boolean]':
1759
+ case '[object Number]':
1760
+ case '[object String]':
1761
+ case '[object Date]':
1762
+ return new source.constructor(source.valueOf());
1763
+ default: break;
1764
+ }
1765
+ // Oggetti Complessi
1766
+ return this.recursiveStep(source, Array.isArray(source) || source instanceof Array ? [] : Object.create(Object.getPrototypeOf(source)));
1767
+ }
1768
+ /**
1769
+ * @ignore
1770
+ * Step ricorsivo per la clonatura degli oggetti. Vedere **deepClone**
1771
+ */
1772
+ recursiveStep(source, destination) {
1773
+ if (Array.isArray(source) || source instanceof Array) {
1774
+ for (var i = 0, ii = source.length; i < ii; i++)
1775
+ destination.push(this.deepClone(source[i]));
1776
+ }
1777
+ else if (source && typeof source.hasOwnProperty === 'function') {
1778
+ for (let key in source) {
1779
+ if (source.hasOwnProperty(key))
1780
+ destination[key] = this.deepClone(source[key]);
1781
+ }
1782
+ }
1783
+ return destination;
1784
+ }
1744
1785
  }
1745
1786
  UtilityService.decorators = [
1746
1787
  { type: Injectable }