@sumaris-net/ngx-components 1.19.0 → 1.19.3

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.
@@ -1331,6 +1331,10 @@
1331
1331
  /* ---
1332
1332
  * Source: https://github.com/ionic-team/ionic-framework/blob/b0d53ca73619585671d8cf4dc24e47f826495a0a/core/src/utils/platform.ts
1333
1333
  * --- */
1334
+ var _cache = {
1335
+ mobile: null,
1336
+ cordova: null
1337
+ };
1334
1338
  var matchMedia = function (win, query) { return win.matchMedia(query).matches; };
1335
1339
  var testUserAgent = function (win, expr) {
1336
1340
  var userAgent = win.navigator.userAgent || win.navigator.vendor || window.opera;
@@ -1338,14 +1342,13 @@
1338
1342
  };
1339
1343
  var isWindows = function (win) { return testUserAgent(win, /windows/i); };
1340
1344
  var isTouchUi = function (win) { return matchMedia(win, '(any-pointer:coarse)'); };
1341
- var isMobile = function (win) { return isCordova(window) || isAndroid(win) || isIOS(window) || (isTouchUi(win) && !isWindows(win)); };
1342
1345
  var isIpad = function (win) {
1343
1346
  // iOS 12 and below
1344
1347
  if (testUserAgent(win, /iPad/i)) {
1345
1348
  return true;
1346
1349
  }
1347
1350
  // iOS 13+
1348
- if (testUserAgent(win, /Macintosh/i) && isMobile(win)) {
1351
+ if (testUserAgent(win, /Macintosh/i) && isTouchUi(win)) {
1349
1352
  return true;
1350
1353
  }
1351
1354
  return false;
@@ -1353,7 +1356,20 @@
1353
1356
  var ɵ0 = isIpad;
1354
1357
  var isIOS = function (win) { return testUserAgent(win, /iPhone|iPod/i) || isIpad(win); };
1355
1358
  var isAndroid = function (win) { return testUserAgent(win, /android|sink/i); };
1356
- var isCordova = function (win) { return !!(win['cordova'] || win['phonegap'] || win['PhoneGap']); };
1359
+ var isCordova = function (win) {
1360
+ if (_cache.cordova === null || _cache.cordova === undefined) {
1361
+ _cache.cordova = !!(win['cordova'] || win['phonegap'] || win['PhoneGap']);
1362
+ }
1363
+ return _cache.cordova;
1364
+ };
1365
+ var isMobile = function (win) {
1366
+ if (_cache.mobile === null || _cache.mobile === undefined) {
1367
+ _cache.mobile = isCordova(window)
1368
+ || isAndroid(win) || isIOS(window)
1369
+ || (isTouchUi(win) && !isWindows(win));
1370
+ }
1371
+ return _cache.mobile;
1372
+ };
1357
1373
 
1358
1374
  var MatAutocompleteConfigHolder = /** @class */ (function () {
1359
1375
  function MatAutocompleteConfigHolder(options) {
@@ -19647,12 +19663,41 @@
19647
19663
  AppForm.prototype.cancel = function () {
19648
19664
  this.onCancel.emit();
19649
19665
  };
19650
- AppForm.prototype.doSubmit = function (event) {
19651
- if (!this.form || !this.form.valid) {
19652
- this.markAllAsTouched({ emitEvent: true });
19653
- return;
19654
- }
19655
- this.onSubmit.emit(event);
19666
+ /**
19667
+ *
19668
+ * @param event
19669
+ * @param opts allow to skip validation check, using {checkValid: false}
19670
+ */
19671
+ AppForm.prototype.doSubmit = function (event, opts) {
19672
+ return __awaiter(this, void 0, void 0, function () {
19673
+ return __generator(this, function (_b) {
19674
+ switch (_b.label) {
19675
+ case 0:
19676
+ if (!this._form) {
19677
+ this.markAllAsTouched({ emitEvent: true });
19678
+ return [2 /*return*/];
19679
+ }
19680
+ if (!((!opts || opts.checkValid !== false) && !this._form.valid)) return [3 /*break*/, 2];
19681
+ // Wait validation end
19682
+ return [4 /*yield*/, AppFormUtils.waitWhilePending(this._form)];
19683
+ case 1:
19684
+ // Wait validation end
19685
+ _b.sent();
19686
+ // Form is invalid: exit (+ log if debug)
19687
+ if (this._form.invalid) {
19688
+ this.markAllAsTouched({ emitEvent: true });
19689
+ if (this.debug)
19690
+ AppFormUtils.logFormErrors(this._form);
19691
+ return [2 /*return*/];
19692
+ }
19693
+ _b.label = 2;
19694
+ case 2:
19695
+ // Emit event
19696
+ this.onSubmit.emit(event);
19697
+ return [2 /*return*/];
19698
+ }
19699
+ });
19700
+ });
19656
19701
  };
19657
19702
  AppForm.prototype.setForm = function (form) {
19658
19703
  var _this = this;
@@ -20937,25 +20982,41 @@
20937
20982
  this.onCancel.emit();
20938
20983
  };
20939
20984
  AuthForm.prototype.doSubmit = function (event) {
20940
- var _this = this;
20941
- if (event) {
20942
- event.preventDefault();
20943
- event.stopPropagation();
20944
- }
20945
- if (this.form.invalid || this.loading)
20946
- return;
20947
- this.markAsLoading();
20948
- var data = this.form.value;
20949
- this.showPwd = false; // Hide password
20950
- this.error = null; // Reset error
20951
- this.registerSubscription(this.onSubmit
20952
- .pipe(operators.debounceTime(500))
20953
- .subscribe(function (res) { return _this.markAsLoaded(); }));
20954
- setTimeout(function () { return _this.onSubmit.emit({
20955
- username: data.username,
20956
- password: data.password,
20957
- offline: data.offline
20958
- }); });
20985
+ return __awaiter(this, void 0, void 0, function () {
20986
+ var data;
20987
+ var _this = this;
20988
+ return __generator(this, function (_a) {
20989
+ switch (_a.label) {
20990
+ case 0:
20991
+ if (event) {
20992
+ event.preventDefault();
20993
+ event.stopPropagation();
20994
+ }
20995
+ if (this.loading)
20996
+ return [2 /*return*/];
20997
+ if (!!this.form.valid) return [3 /*break*/, 2];
20998
+ return [4 /*yield*/, AppFormUtils.waitWhilePending(this.form)];
20999
+ case 1:
21000
+ _a.sent();
21001
+ if (this.form.invalid) {
21002
+ AppFormUtils.logFormErrors(this.form);
21003
+ return [2 /*return*/]; // Skip if invalid
21004
+ }
21005
+ _a.label = 2;
21006
+ case 2:
21007
+ this.markAsLoading();
21008
+ data = this.form.value;
21009
+ this.showPwd = false; // Hide password
21010
+ this.error = null; // Reset error
21011
+ setTimeout(function () { return _this.onSubmit.emit({
21012
+ username: data.username,
21013
+ password: data.password,
21014
+ offline: data.offline
21015
+ }); });
21016
+ return [2 /*return*/];
21017
+ }
21018
+ });
21019
+ });
20959
21020
  };
20960
21021
  AuthForm.prototype.register = function () {
20961
21022
  var _this = this;
@@ -24415,7 +24476,7 @@
24415
24476
  };
24416
24477
  BaseEntityService.prototype.loadAll = function (offset, size, sortBy, sortDirection, filter, opts) {
24417
24478
  return __awaiter(this, void 0, void 0, function () {
24418
- var debug, variables, now, withTotal, query, _b, data, total, entities, res, nextOffset_1;
24479
+ var debug, variables, now, withTotal, query, _b, data, total, entities, result, nextOffset_1;
24419
24480
  var _this = this;
24420
24481
  return __generator(this, function (_c) {
24421
24482
  switch (_c.label) {
@@ -24449,18 +24510,18 @@
24449
24510
  (data || []);
24450
24511
  if (debug)
24451
24512
  console.debug(this._logPrefix + (this._logTypeName + " items loaded in " + (Date.now() - now) + "ms"));
24452
- res = {
24513
+ result = {
24453
24514
  data: entities,
24454
- total: total
24515
+ total: total || entities.length
24455
24516
  };
24456
24517
  // Add fetch more capability, if total was fetched
24457
24518
  if (withTotal) {
24458
24519
  nextOffset_1 = (offset || 0) + entities.length;
24459
- if (nextOffset_1 < res.total) {
24460
- res.fetchMore = function () { return _this.loadAll(nextOffset_1, size, sortBy, sortDirection, filter, opts); };
24520
+ if (nextOffset_1 < result.total) {
24521
+ result.fetchMore = function () { return _this.loadAll(nextOffset_1, size, sortBy, sortDirection, filter, opts); };
24461
24522
  }
24462
24523
  }
24463
- return [2 /*return*/, res];
24524
+ return [2 /*return*/, result];
24464
24525
  }
24465
24526
  });
24466
24527
  });