@sumaris-net/ngx-components 1.19.17 → 1.19.18

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.
@@ -1366,6 +1366,7 @@
1366
1366
  if (_cache.mobile === null || _cache.mobile === undefined) {
1367
1367
  _cache.mobile = isCordova(window)
1368
1368
  || isAndroid(win) || isIOS(window)
1369
+ // Workaround, for MS Windows touch screen (detected as mobile, but forced as desktop)
1369
1370
  || (isTouchUi(win) && !isWindows(win));
1370
1371
  }
1371
1372
  return _cache.mobile;
@@ -13869,6 +13870,58 @@
13869
13870
  enumerable: false,
13870
13871
  configurable: true
13871
13872
  });
13873
+ EntitiesStorage.prototype.ngOnStart = function () {
13874
+ return __awaiter(this, void 0, void 0, function () {
13875
+ var now;
13876
+ var _this = this;
13877
+ return __generator(this, function (_a) {
13878
+ switch (_a.label) {
13879
+ case 0:
13880
+ now = Date.now();
13881
+ console.info("[entities-storage] Starting entity storage...");
13882
+ // Restore stores
13883
+ return [4 /*yield*/, this.restoreLocally()];
13884
+ case 1:
13885
+ // Restore stores
13886
+ _a.sent();
13887
+ // Start a save timer
13888
+ this.registerSubscription(rxjs.merge(this._$save, rxjs.timer(this._saveTimerPeriod, this._saveTimerPeriod))
13889
+ .pipe(
13890
+ // Avoid to many call (e.g. when $save AND timer are triggered
13891
+ operators.throttleTime(this._saveTimerPeriod))
13892
+ .subscribe(function () { return _this.storeLocally({ skipIfPristine: true }); }));
13893
+ // Save, when platform is in pause
13894
+ this.registerSubscription(this.platform.pause.subscribe(function () { return __awaiter(_this, void 0, void 0, function () {
13895
+ return __generator(this, function (_a) {
13896
+ switch (_a.label) {
13897
+ case 0:
13898
+ console.warn("[entities-storage] Platform will pause: saving...");
13899
+ return [4 /*yield*/, this.storeLocally({ skipIfPristine: true })];
13900
+ case 1:
13901
+ _a.sent();
13902
+ console.warn("[entities-storage] Platform will pause: saving [OK]");
13903
+ return [2 /*return*/];
13904
+ }
13905
+ });
13906
+ }); }));
13907
+ console.info("[entities-storage] Starting [OK] in " + (Date.now() - now) + "ms");
13908
+ return [2 /*return*/, this._data];
13909
+ }
13910
+ });
13911
+ });
13912
+ };
13913
+ EntitiesStorage.prototype.ngOnStop = function () {
13914
+ return __awaiter(this, void 0, void 0, function () {
13915
+ return __generator(this, function (_a) {
13916
+ switch (_a.label) {
13917
+ case 0: return [4 /*yield*/, this.storeLocally({ skipIfPristine: true })];
13918
+ case 1:
13919
+ _a.sent();
13920
+ return [2 /*return*/];
13921
+ }
13922
+ });
13923
+ });
13924
+ };
13872
13925
  EntitiesStorage.prototype.watchAll = function (entityName, variables, opts) {
13873
13926
  var _this = this;
13874
13927
  // Make sure store is ready
@@ -14279,52 +14332,8 @@
14279
14332
  };
14280
14333
  EntitiesStorage.prototype.persist = function (opts) {
14281
14334
  if (opts === void 0) { opts = { skipIfPristine: true }; }
14282
- // Skip if pristine
14283
- if (opts.skipIfPristine && !this._dirty)
14284
- return Promise.resolve();
14285
14335
  return this.storeLocally(opts);
14286
14336
  };
14287
- EntitiesStorage.prototype.ngOnStart = function () {
14288
- return __awaiter(this, void 0, void 0, function () {
14289
- var now;
14290
- var _this = this;
14291
- return __generator(this, function (_a) {
14292
- switch (_a.label) {
14293
- case 0:
14294
- now = Date.now();
14295
- console.info("[entities-storage] Starting entity storage...");
14296
- // Restore sequences
14297
- return [4 /*yield*/, this.restoreLocally()];
14298
- case 1:
14299
- // Restore sequences
14300
- _a.sent();
14301
- // Start a save timer
14302
- this.registerSubscription(rxjs.merge(this._$save, rxjs.timer(this._saveTimerPeriod, this._saveTimerPeriod))
14303
- .pipe(
14304
- // Avoid to many call (e.g. when $save AND timer are triggered
14305
- operators.throttleTime(this._saveTimerPeriod))
14306
- .subscribe(function () { return _this.storeLocally(); }));
14307
- console.info("[entities-storage] Starting [OK] in " + (Date.now() - now) + "ms");
14308
- return [2 /*return*/, this._data];
14309
- }
14310
- });
14311
- });
14312
- };
14313
- EntitiesStorage.prototype.ngOnStop = function () {
14314
- return __awaiter(this, void 0, void 0, function () {
14315
- return __generator(this, function (_a) {
14316
- switch (_a.label) {
14317
- case 0:
14318
- if (!this.dirty) return [3 /*break*/, 2];
14319
- return [4 /*yield*/, this.storeLocally()];
14320
- case 1:
14321
- _a.sent();
14322
- _a.label = 2;
14323
- case 2: return [2 /*return*/];
14324
- }
14325
- });
14326
- });
14327
- };
14328
14337
  /* -- protected methods -- */
14329
14338
  EntitiesStorage.prototype.getEntityStore = function (name, opts) {
14330
14339
  var store = this._data[name];
@@ -18275,7 +18284,7 @@
18275
18284
  switch (platformName) {
18276
18285
  case 'mobile':
18277
18286
  case 'mobileweb':
18278
- // Exclude Windows touch screens - see SUMARIS issue #323
18287
+ // Exclude Windows touch screens - see sumaris-app issues #323 and #346
18279
18288
  return this.platform.is(platformName) && !isWindows(window);
18280
18289
  default:
18281
18290
  return this.platform.is(platformName);
@@ -18348,6 +18357,7 @@
18348
18357
  this._cordova = this.is('cordova');
18349
18358
  this._android = this.is('android');
18350
18359
  this._ios = this.is('ios');
18360
+ this.configureHtmlClassList(this._mobile);
18351
18361
  this.configureCordovaPlugins();
18352
18362
  // Force some settings
18353
18363
  this.settings.mobile = this._mobile;
@@ -18393,7 +18403,7 @@
18393
18403
  _this.accountService.tokenType = tokenType;
18394
18404
  });
18395
18405
  // Hide the splashscreen (if mobile) - after 1s - and play start sound
18396
- if (this.mobile) {
18406
+ if (this._mobile) {
18397
18407
  setTimeout(function () {
18398
18408
  var _a;
18399
18409
  (_a = _this.splashScreen) === null || _a === void 0 ? void 0 : _a.hide();
@@ -18498,6 +18508,16 @@
18498
18508
  //}
18499
18509
  };
18500
18510
  /* -- protected methods -- */
18511
+ PlatformService.prototype.configureHtmlClassList = function (mobile, win) {
18512
+ if (win === void 0) { win = window; }
18513
+ if (mobile)
18514
+ return; // Nothing to do
18515
+ // Workaround, for MS Windows touch screen (detected as mobile, but forced as desktop)
18516
+ if (!mobile && win.document.documentElement.classList.contains('plt-mobile')) {
18517
+ console.warn('[platform] Force class list to: <html class="plt-desktop">. Workaround for Windows touch screen.');
18518
+ win.document.documentElement.classList.replace('plt-mobile', 'plt-desktop');
18519
+ }
18520
+ };
18501
18521
  PlatformService.prototype.configureCordovaPlugins = function () {
18502
18522
  console.info('[platform] Configuring Cordova plugins...');
18503
18523
  if (this.statusBar) {
@@ -22013,7 +22033,7 @@
22013
22033
  };
22014
22034
  AccountPage.prototype.refresh = function (event) {
22015
22035
  return __awaiter(this, void 0, void 0, function () {
22016
- return __generator(this, function (_b) {
22036
+ return __generator(this, function (_c) {
22017
22037
  this.disable();
22018
22038
  this.markAsLoading();
22019
22039
  return [2 /*return*/, this.accountService.reload()];
@@ -22034,8 +22054,8 @@
22034
22054
  AccountPage.prototype.sendConfirmationEmail = function (event) {
22035
22055
  return __awaiter(this, void 0, void 0, function () {
22036
22056
  var json, err_1;
22037
- return __generator(this, function (_b) {
22038
- switch (_b.label) {
22057
+ return __generator(this, function (_c) {
22058
+ switch (_c.label) {
22039
22059
  case 0:
22040
22060
  json = this.form.value;
22041
22061
  json.email = this.form.controls['email'].value;
@@ -22045,17 +22065,17 @@
22045
22065
  }
22046
22066
  this.email.sending = true;
22047
22067
  console.debug('[account] Sending confirmation email...');
22048
- _b.label = 1;
22068
+ _c.label = 1;
22049
22069
  case 1:
22050
- _b.trys.push([1, 3, , 4]);
22070
+ _c.trys.push([1, 3, , 4]);
22051
22071
  return [4 /*yield*/, this.accountService.sendConfirmationEmail(json.email, json.settings && json.settings.locale || this.translate.currentLang)];
22052
22072
  case 2:
22053
- _b.sent();
22073
+ _c.sent();
22054
22074
  console.debug('[account] Confirmation email sent.');
22055
22075
  this.email.sending = false;
22056
22076
  return [3 /*break*/, 4];
22057
22077
  case 3:
22058
- err_1 = _b.sent();
22078
+ err_1 = _c.sent();
22059
22079
  this.email.sending = false;
22060
22080
  this.email.error = err_1 && err_1.message || err_1;
22061
22081
  return [3 /*break*/, 4];
@@ -22067,38 +22087,38 @@
22067
22087
  AccountPage.prototype.save = function (event) {
22068
22088
  return __awaiter(this, void 0, void 0, function () {
22069
22089
  var newAccount, err_2;
22070
- return __generator(this, function (_b) {
22071
- switch (_b.label) {
22090
+ return __generator(this, function (_c) {
22091
+ switch (_c.label) {
22072
22092
  case 0:
22073
22093
  if (this.saving)
22074
22094
  return [2 /*return*/, false];
22075
22095
  if (!!this.form.valid) return [3 /*break*/, 2];
22076
22096
  return [4 /*yield*/, AppFormUtils.waitWhilePending(this.form)];
22077
22097
  case 1:
22078
- _b.sent();
22098
+ _c.sent();
22079
22099
  if (this.form.invalid) {
22080
22100
  AppFormUtils.logFormErrors(this.form);
22081
22101
  this.form.markAllAsTouched();
22082
22102
  return [2 /*return*/, false];
22083
22103
  }
22084
- _b.label = 2;
22104
+ _c.label = 2;
22085
22105
  case 2:
22086
22106
  this.submitted = true;
22087
22107
  this.saving = true;
22088
22108
  this.error = undefined;
22089
22109
  newAccount = exports.Account.fromObject(Object.assign(Object.assign({}, (this.accountService.account.asObject())), (this.form.value)));
22090
22110
  console.debug('[account] Saving account...', newAccount);
22091
- _b.label = 3;
22111
+ _c.label = 3;
22092
22112
  case 3:
22093
- _b.trys.push([3, 5, 6, 7]);
22113
+ _c.trys.push([3, 5, 6, 7]);
22094
22114
  this.disable();
22095
22115
  return [4 /*yield*/, this.accountService.save(newAccount)];
22096
22116
  case 4:
22097
- _b.sent();
22117
+ _c.sent();
22098
22118
  this.markAsPristine();
22099
22119
  return [2 /*return*/, true];
22100
22120
  case 5:
22101
- err_2 = _b.sent();
22121
+ err_2 = _c.sent();
22102
22122
  console.error(err_2);
22103
22123
  this.error = err_2 && err_2.message || err_2;
22104
22124
  return [2 /*return*/, false];
@@ -22120,9 +22140,21 @@
22120
22140
  this.form.controls.pubkey.disable();
22121
22141
  // Always disable some additional fields
22122
22142
  this.additionalFields
22123
- .filter(function (field) { return field.extra && field.extra.account && field.extra.account.disabled || false; })
22124
22143
  .forEach(function (field) {
22125
- _this.form.controls[field.key].disable();
22144
+ var _a, _b;
22145
+ var control = _this.form.controls[field.key];
22146
+ if (!control)
22147
+ return; // Skip
22148
+ var disabled = ((_a = field.extra) === null || _a === void 0 ? void 0 : _a.account) && field.extra.account.disabled || false;
22149
+ if (disabled && control.enabled) {
22150
+ control.disable();
22151
+ }
22152
+ var required = ((_b = field.extra) === null || _b === void 0 ? void 0 : _b.account) && field.extra.account.required || false;
22153
+ if (!field.required && required) {
22154
+ control.setValidators(control.validator
22155
+ ? i1.Validators.compose([control.validator, i1.Validators.required])
22156
+ : i1.Validators.required);
22157
+ }
22126
22158
  });
22127
22159
  this.markForCheck();
22128
22160
  };
@@ -22131,7 +22163,7 @@
22131
22163
  cancel: { get: function () { return _super_1.prototype.cancel; } }
22132
22164
  });
22133
22165
  return __awaiter(this, void 0, void 0, function () {
22134
- return __generator(this, function (_b) {
22166
+ return __generator(this, function (_c) {
22135
22167
  _super.cancel.call(this);
22136
22168
  return [2 /*return*/];
22137
22169
  });