@sumaris-net/ngx-components 1.19.16 → 1.19.19

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.
@@ -1089,6 +1089,7 @@ const isMobile = (win) => {
1089
1089
  if (_cache.mobile === null || _cache.mobile === undefined) {
1090
1090
  _cache.mobile = isCordova(window)
1091
1091
  || isAndroid(win) || isIOS(window)
1092
+ // Workaround, for MS Windows touch screen (detected as mobile, but forced as desktop)
1092
1093
  || (isTouchUi(win) && !isWindows(win));
1093
1094
  }
1094
1095
  return _cache.mobile;
@@ -2995,7 +2996,7 @@ class SharedValidators {
2995
2996
  return null;
2996
2997
  }
2997
2998
  if (isNotNil(value) && value !== '' && !regexp.test(value)) {
2998
- return isNotNil(opts === null || opts === void 0 ? void 0 : opts.maxDecimals) ? { maxDecimals: { max: opts.maxDecimals } } : { decimal: true };
2999
+ return isNotNil(opts === null || opts === void 0 ? void 0 : opts.maxDecimals) ? { maxDecimals: { maxDecimals: opts.maxDecimals } } : { decimal: true };
2999
3000
  }
3000
3001
  return null;
3001
3002
  };
@@ -12217,6 +12218,33 @@ class EntitiesStorage extends StartableService {
12217
12218
  get dirty() {
12218
12219
  return this._dirty || Object.values(this._data).some(store => store.dirty);
12219
12220
  }
12221
+ ngOnStart() {
12222
+ return __awaiter(this, void 0, void 0, function* () {
12223
+ const now = Date.now();
12224
+ console.info(`[entities-storage] Starting entity storage...`);
12225
+ // Restore stores
12226
+ yield this.restoreLocally();
12227
+ // Start a save timer
12228
+ this.registerSubscription(merge(this._$save, timer(this._saveTimerPeriod, this._saveTimerPeriod))
12229
+ .pipe(
12230
+ // Avoid to many call (e.g. when $save AND timer are triggered
12231
+ throttleTime(this._saveTimerPeriod))
12232
+ .subscribe(() => this.storeLocally({ skipIfPristine: true })));
12233
+ // Save, when platform is in pause
12234
+ this.registerSubscription(this.platform.pause.subscribe(() => __awaiter(this, void 0, void 0, function* () {
12235
+ console.warn(`[entities-storage] Platform will pause: saving...`);
12236
+ yield this.storeLocally({ skipIfPristine: true });
12237
+ console.warn(`[entities-storage] Platform will pause: saving [OK]`);
12238
+ })));
12239
+ console.info(`[entities-storage] Starting [OK] in ${Date.now() - now}ms`);
12240
+ return this._data;
12241
+ });
12242
+ }
12243
+ ngOnStop() {
12244
+ return __awaiter(this, void 0, void 0, function* () {
12245
+ yield this.storeLocally({ skipIfPristine: true });
12246
+ });
12247
+ }
12220
12248
  watchAll(entityName, variables, opts) {
12221
12249
  // Make sure store is ready
12222
12250
  if (!this.started) {
@@ -12483,34 +12511,8 @@ class EntitiesStorage extends StartableService {
12483
12511
  });
12484
12512
  }
12485
12513
  persist(opts = { skipIfPristine: true }) {
12486
- // Skip if pristine
12487
- if (opts.skipIfPristine && !this._dirty)
12488
- return Promise.resolve();
12489
12514
  return this.storeLocally(opts);
12490
12515
  }
12491
- ngOnStart() {
12492
- return __awaiter(this, void 0, void 0, function* () {
12493
- const now = Date.now();
12494
- console.info(`[entities-storage] Starting entity storage...`);
12495
- // Restore sequences
12496
- yield this.restoreLocally();
12497
- // Start a save timer
12498
- this.registerSubscription(merge(this._$save, timer(this._saveTimerPeriod, this._saveTimerPeriod))
12499
- .pipe(
12500
- // Avoid to many call (e.g. when $save AND timer are triggered
12501
- throttleTime(this._saveTimerPeriod))
12502
- .subscribe(() => this.storeLocally()));
12503
- console.info(`[entities-storage] Starting [OK] in ${Date.now() - now}ms`);
12504
- return this._data;
12505
- });
12506
- }
12507
- ngOnStop() {
12508
- return __awaiter(this, void 0, void 0, function* () {
12509
- if (this.dirty) {
12510
- yield this.storeLocally();
12511
- }
12512
- });
12513
- }
12514
12516
  /* -- protected methods -- */
12515
12517
  getEntityStore(name, opts) {
12516
12518
  let store = this._data[name];
@@ -16000,7 +16002,7 @@ class PlatformService extends StartableService {
16000
16002
  switch (platformName) {
16001
16003
  case 'mobile':
16002
16004
  case 'mobileweb':
16003
- // Exclude Windows touch screens - see SUMARIS issue #323
16005
+ // Exclude Windows touch screens - see sumaris-app issues #323 and #346
16004
16006
  return this.platform.is(platformName) && !isWindows(window);
16005
16007
  default:
16006
16008
  return this.platform.is(platformName);
@@ -16054,6 +16056,7 @@ class PlatformService extends StartableService {
16054
16056
  this._cordova = this.is('cordova');
16055
16057
  this._android = this.is('android');
16056
16058
  this._ios = this.is('ios');
16059
+ this.configureHtmlClassList(this._mobile);
16057
16060
  this.configureCordovaPlugins();
16058
16061
  // Force some settings
16059
16062
  this.settings.mobile = this._mobile;
@@ -16088,7 +16091,7 @@ class PlatformService extends StartableService {
16088
16091
  this.accountService.tokenType = tokenType;
16089
16092
  });
16090
16093
  // Hide the splashscreen (if mobile) - after 1s - and play start sound
16091
- if (this.mobile) {
16094
+ if (this._mobile) {
16092
16095
  setTimeout(() => {
16093
16096
  var _a;
16094
16097
  (_a = this.splashScreen) === null || _a === void 0 ? void 0 : _a.hide();
@@ -16190,6 +16193,17 @@ class PlatformService extends StartableService {
16190
16193
  //}
16191
16194
  }
16192
16195
  /* -- protected methods -- */
16196
+ configureHtmlClassList(mobile, win = window) {
16197
+ if (mobile)
16198
+ return; // Nothing to do
16199
+ // Workaround, for MS Windows touch screen (detected as mobile, but forced as desktop)
16200
+ if (!mobile && (win.document.documentElement.classList.contains('plt-mobile')
16201
+ || win.document.documentElement.classList.contains('plt-mobileweb'))) {
16202
+ console.warn('[platform] Force class list to: <html class="plt-desktop">. Workaround for Windows touch screen.');
16203
+ win.document.documentElement.classList.remove('plt-mobile', 'plt-mobileweb');
16204
+ win.document.documentElement.classList.add('plt-desktop');
16205
+ }
16206
+ }
16193
16207
  configureCordovaPlugins() {
16194
16208
  console.info('[platform] Configuring Cordova plugins...');
16195
16209
  if (this.statusBar) {
@@ -19236,9 +19250,21 @@ class AccountPage extends AppForm {
19236
19250
  this.form.controls.pubkey.disable();
19237
19251
  // Always disable some additional fields
19238
19252
  this.additionalFields
19239
- .filter(field => field.extra && field.extra.account && field.extra.account.disabled || false)
19240
19253
  .forEach(field => {
19241
- this.form.controls[field.key].disable();
19254
+ var _a, _b;
19255
+ const control = this.form.controls[field.key];
19256
+ if (!control)
19257
+ return; // Skip
19258
+ const disabled = ((_a = field.extra) === null || _a === void 0 ? void 0 : _a.account) && field.extra.account.disabled || false;
19259
+ if (disabled && control.enabled) {
19260
+ control.disable();
19261
+ }
19262
+ const required = ((_b = field.extra) === null || _b === void 0 ? void 0 : _b.account) && field.extra.account.required || false;
19263
+ if (!field.required && required) {
19264
+ control.setValidators(control.validator
19265
+ ? Validators.compose([control.validator, Validators.required])
19266
+ : Validators.required);
19267
+ }
19242
19268
  });
19243
19269
  this.markForCheck();
19244
19270
  }