@sumaris-net/ngx-components 1.12.13 → 1.13.2
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.
- package/bundles/sumaris-net.ngx-components.umd.js +104 -5
- package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
- package/doc/changelog.md +9 -2
- package/esm2015/src/app/core/auth/form/form-auth.js +2 -2
- package/esm2015/src/app/core/install/install-upgrade-card.component.js +3 -3
- package/esm2015/src/app/core/services/base-entity-service.class.js +6 -3
- package/esm2015/src/app/core/services/platform.service.js +4 -1
- package/esm2015/src/app/shared/observables.js +1 -1
- package/esm2015/src/app/shared/validator/validators.js +94 -2
- package/fesm2015/sumaris-net.ngx-components.js +102 -7
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/core/services/platform.service.d.ts +1 -0
- package/src/app/shared/validator/validators.d.ts +30 -1
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -3585,6 +3585,99 @@
|
|
|
3585
3585
|
};
|
|
3586
3586
|
return SharedFormArrayValidators;
|
|
3587
3587
|
}());
|
|
3588
|
+
// @dynamic
|
|
3589
|
+
var SharedAsyncValidators = /** @class */ (function () {
|
|
3590
|
+
function SharedAsyncValidators() {
|
|
3591
|
+
}
|
|
3592
|
+
/**
|
|
3593
|
+
* Add a debounce time to a validator.
|
|
3594
|
+
* @param form
|
|
3595
|
+
* @param validatorFn
|
|
3596
|
+
* @param opts Use opts.stopSubject to stop the validator, before end
|
|
3597
|
+
*/
|
|
3598
|
+
SharedAsyncValidators.debounceTime = function (validatorFn, opts) {
|
|
3599
|
+
// DEBUG only
|
|
3600
|
+
var debug = (opts === null || opts === void 0 ? void 0 : opts.debug) || false;
|
|
3601
|
+
var logPrefix = debug && "[debounceTime-validator] #" + SharedAsyncValidators.DEBOUNCE_TIME_VALIDATOR_ID++ + " - ";
|
|
3602
|
+
var debounceTime = toNumber(opts === null || opts === void 0 ? void 0 : opts.debounceTime, 250);
|
|
3603
|
+
// DEBUG
|
|
3604
|
+
if (debug)
|
|
3605
|
+
console.debug(logPrefix + ("New validator with a debounceTime at " + debounceTime + "ms"));
|
|
3606
|
+
var $disposeSubject = new rxjs.Subject();
|
|
3607
|
+
var disposeEvent$ = (opts === null || opts === void 0 ? void 0 : opts.dispose) ? rxjs.merge($disposeSubject, opts === null || opts === void 0 ? void 0 : opts.dispose)
|
|
3608
|
+
: $disposeSubject;
|
|
3609
|
+
// DEBUG
|
|
3610
|
+
if (debug && (opts === null || opts === void 0 ? void 0 : opts.dispose)) {
|
|
3611
|
+
opts === null || opts === void 0 ? void 0 : opts.dispose.pipe(operators.first()).subscribe(function () {
|
|
3612
|
+
console.debug(logPrefix + 'Stopping');
|
|
3613
|
+
});
|
|
3614
|
+
}
|
|
3615
|
+
return function (control) {
|
|
3616
|
+
if (debug)
|
|
3617
|
+
console.debug(logPrefix + 'Form ask validation...');
|
|
3618
|
+
// Stop previous observables
|
|
3619
|
+
$disposeSubject.next();
|
|
3620
|
+
var now;
|
|
3621
|
+
// Add a delay before execution
|
|
3622
|
+
return rxjs.timer(debounceTime)
|
|
3623
|
+
.pipe(
|
|
3624
|
+
// DEBUG
|
|
3625
|
+
operators.tap(function (_) {
|
|
3626
|
+
if (debug) {
|
|
3627
|
+
console.debug(logPrefix + 'Executing...');
|
|
3628
|
+
now = Date.now();
|
|
3629
|
+
}
|
|
3630
|
+
}), operators.switchMap(function (_) {
|
|
3631
|
+
// Call the validator
|
|
3632
|
+
var res = validatorFn(control);
|
|
3633
|
+
// Make sure to return an Observable
|
|
3634
|
+
if (rxjs.isObservable(res))
|
|
3635
|
+
return res;
|
|
3636
|
+
if (res instanceof Promise)
|
|
3637
|
+
return rxjs.from(res);
|
|
3638
|
+
return rxjs.of(res);
|
|
3639
|
+
}),
|
|
3640
|
+
// DEBUG
|
|
3641
|
+
operators.tap(function (res) { return debug && console.debug(logPrefix + ("Finished in " + (Date.now() - now) + "ms (" + (res ? 'with errors' : 'no error') + ")"), res); }), operators.catchError(function (error) {
|
|
3642
|
+
console.error('[debounceTime-validator] Error while executing validator. Stopping job', error);
|
|
3643
|
+
$disposeSubject.next();
|
|
3644
|
+
throw error;
|
|
3645
|
+
}),
|
|
3646
|
+
// Refresh UI, after a successful execution
|
|
3647
|
+
operators.tap(function () { return (opts === null || opts === void 0 ? void 0 : opts.markForCheck) && (opts === null || opts === void 0 ? void 0 : opts.markForCheck()); }),
|
|
3648
|
+
// Make sure to stop, because of the switchMap
|
|
3649
|
+
operators.takeUntil(disposeEvent$));
|
|
3650
|
+
};
|
|
3651
|
+
};
|
|
3652
|
+
/**
|
|
3653
|
+
* Add an async validator, that can be disposed by the returned subscription
|
|
3654
|
+
* @param form
|
|
3655
|
+
* @param validatorFn the validator or job to execute
|
|
3656
|
+
* @param opts
|
|
3657
|
+
*/
|
|
3658
|
+
SharedAsyncValidators.registerAsyncValidator = function (form, validatorFn, opts) {
|
|
3659
|
+
if (form.asyncValidator)
|
|
3660
|
+
throw Error('Form already have an async validator. Cannot configure job');
|
|
3661
|
+
var debounceTime = toNumber(opts === null || opts === void 0 ? void 0 : opts.debounceTime, 250);
|
|
3662
|
+
var $dispose = new rxjs.Subject();
|
|
3663
|
+
var asyncValidatorFn = SharedAsyncValidators.debounceTime(validatorFn, Object.assign(Object.assign({}, opts), { debounceTime: debounceTime, dispose: $dispose }));
|
|
3664
|
+
form.setAsyncValidators(asyncValidatorFn);
|
|
3665
|
+
var subscription = new rxjs.Subscription();
|
|
3666
|
+
// When unsubscribing, remove async validator
|
|
3667
|
+
subscription.add(function () {
|
|
3668
|
+
// Clear added validator. Must be done NOW (without delay) because generally a new Job is given just after
|
|
3669
|
+
form.clearAsyncValidators();
|
|
3670
|
+
// Stop the job, with a delay to let the last execution finished
|
|
3671
|
+
setTimeout(function () {
|
|
3672
|
+
$dispose.next();
|
|
3673
|
+
$dispose.unsubscribe();
|
|
3674
|
+
}, debounceTime);
|
|
3675
|
+
});
|
|
3676
|
+
return subscription;
|
|
3677
|
+
};
|
|
3678
|
+
return SharedAsyncValidators;
|
|
3679
|
+
}());
|
|
3680
|
+
SharedAsyncValidators.DEBOUNCE_TIME_VALIDATOR_ID = 0;
|
|
3588
3681
|
|
|
3589
3682
|
/**
|
|
3590
3683
|
* Fill a form using a source entity
|
|
@@ -17539,6 +17632,9 @@
|
|
|
17539
17632
|
PlatformService.prototype.isApp = function () {
|
|
17540
17633
|
return this._cordova && (this._android || this._ios);
|
|
17541
17634
|
};
|
|
17635
|
+
PlatformService.prototype.isMobileWeb = function () {
|
|
17636
|
+
return isMobile(window) && this.isWeb();
|
|
17637
|
+
};
|
|
17542
17638
|
Object.defineProperty(PlatformService.prototype, "canDownload", {
|
|
17543
17639
|
get: function () {
|
|
17544
17640
|
return !!this.downloader && this.isAndroidCordova();
|
|
@@ -20374,7 +20470,7 @@
|
|
|
20374
20470
|
_this.showPwd = false;
|
|
20375
20471
|
_this.onCancel = new i0.EventEmitter();
|
|
20376
20472
|
_this.onSubmit = new i0.EventEmitter();
|
|
20377
|
-
_this.mobile =
|
|
20473
|
+
_this.mobile = settings.mobile;
|
|
20378
20474
|
_this.canWorkOffline = _this.settings.hasOfflineFeature();
|
|
20379
20475
|
_this._enable = true;
|
|
20380
20476
|
return _this;
|
|
@@ -22832,10 +22928,10 @@
|
|
|
22832
22928
|
};
|
|
22833
22929
|
AppInstallUpgradeCard.prototype.getCompatibleInstallLinks = function (installLinks) {
|
|
22834
22930
|
// Cordova already running: not need to install
|
|
22835
|
-
if (this.platform.
|
|
22931
|
+
if (this.platform.isCordova())
|
|
22836
22932
|
return undefined;
|
|
22837
22933
|
// If mobile web: return all
|
|
22838
|
-
if (this.platform.
|
|
22934
|
+
if (this.platform.isMobileWeb()) {
|
|
22839
22935
|
return installLinks;
|
|
22840
22936
|
}
|
|
22841
22937
|
return undefined;
|
|
@@ -24219,8 +24315,10 @@
|
|
|
24219
24315
|
var _this = this;
|
|
24220
24316
|
if (isNil(id))
|
|
24221
24317
|
throw Error('Missing argument \'id\' ');
|
|
24222
|
-
if (!this.subscriptions.listenChanges)
|
|
24223
|
-
|
|
24318
|
+
if (!this.subscriptions.listenChanges) {
|
|
24319
|
+
console.warn(this.constructor.name + ".listenChanges() not implemented yet. Will empty observable");
|
|
24320
|
+
return rxjs.of();
|
|
24321
|
+
}
|
|
24224
24322
|
var variables = opts && opts.variables || {
|
|
24225
24323
|
id: id,
|
|
24226
24324
|
interval: toNumber(opts && opts.interval, 0) // no timer by default
|
|
@@ -30907,6 +31005,7 @@
|
|
|
30907
31005
|
exports.SPACE_PLACEHOLDER_CHAR = SPACE_PLACEHOLDER_CHAR;
|
|
30908
31006
|
exports.SelectPeerModal = SelectPeerModal;
|
|
30909
31007
|
exports.SettingsPage = SettingsPage;
|
|
31008
|
+
exports.SharedAsyncValidators = SharedAsyncValidators;
|
|
30910
31009
|
exports.SharedDirectivesModule = SharedDirectivesModule;
|
|
30911
31010
|
exports.SharedFormArrayValidators = SharedFormArrayValidators;
|
|
30912
31011
|
exports.SharedFormGroupValidators = SharedFormGroupValidators;
|