@stemy/ngx-utils 12.0.5 → 12.0.6
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/stemy-ngx-utils.umd.js +35 -18
- package/bundles/stemy-ngx-utils.umd.js.map +1 -1
- package/esm2015/ngx-utils/directives/async-method.base.js +54 -0
- package/esm2015/ngx-utils/directives/async-method.directive.js +8 -46
- package/esm2015/public_api.js +2 -1
- package/fesm2015/stemy-ngx-utils.js +28 -14
- package/fesm2015/stemy-ngx-utils.js.map +1 -1
- package/ngx-utils/directives/async-method.base.d.ts +16 -0
- package/ngx-utils/directives/async-method.directive.d.ts +4 -13
- package/package.json +1 -1
- package/public_api.d.ts +1 -0
- package/stemy-ngx-utils.metadata.json +1 -1
|
@@ -4805,39 +4805,42 @@
|
|
|
4805
4805
|
},] }
|
|
4806
4806
|
];
|
|
4807
4807
|
|
|
4808
|
-
var
|
|
4809
|
-
function
|
|
4808
|
+
var AsyncMethodBase = /** @class */ (function () {
|
|
4809
|
+
function AsyncMethodBase(toaster) {
|
|
4810
4810
|
this.toaster = toaster;
|
|
4811
4811
|
this.onSuccess = new core.EventEmitter();
|
|
4812
4812
|
this.onError = new core.EventEmitter();
|
|
4813
4813
|
}
|
|
4814
|
-
Object.defineProperty(
|
|
4814
|
+
Object.defineProperty(AsyncMethodBase.prototype, "isDisabled", {
|
|
4815
4815
|
get: function () {
|
|
4816
4816
|
return this.disabled;
|
|
4817
4817
|
},
|
|
4818
4818
|
enumerable: false,
|
|
4819
4819
|
configurable: true
|
|
4820
4820
|
});
|
|
4821
|
-
Object.defineProperty(
|
|
4821
|
+
Object.defineProperty(AsyncMethodBase.prototype, "isLoading", {
|
|
4822
4822
|
get: function () {
|
|
4823
4823
|
return this.loading;
|
|
4824
4824
|
},
|
|
4825
4825
|
enumerable: false,
|
|
4826
4826
|
configurable: true
|
|
4827
4827
|
});
|
|
4828
|
-
|
|
4828
|
+
AsyncMethodBase.prototype.click = function () {
|
|
4829
4829
|
if (this.disabled)
|
|
4830
4830
|
return;
|
|
4831
4831
|
this.callMethod();
|
|
4832
4832
|
};
|
|
4833
|
-
|
|
4833
|
+
AsyncMethodBase.prototype.callMethod = function () {
|
|
4834
4834
|
var _this = this;
|
|
4835
4835
|
if (this.loading)
|
|
4836
4836
|
return true;
|
|
4837
|
-
var result = !this.method ? null : this.method(this.context);
|
|
4838
|
-
if (!(result instanceof Promise))
|
|
4839
|
-
return false;
|
|
4840
4837
|
this.loading = true;
|
|
4838
|
+
var method = this.getMethod();
|
|
4839
|
+
var result = !method ? null : method(this.context);
|
|
4840
|
+
if (!(result instanceof Promise)) {
|
|
4841
|
+
this.loading = false;
|
|
4842
|
+
return false;
|
|
4843
|
+
}
|
|
4841
4844
|
result.then(function (result) {
|
|
4842
4845
|
_this.loading = false;
|
|
4843
4846
|
if (result) {
|
|
@@ -4853,8 +4856,28 @@
|
|
|
4853
4856
|
});
|
|
4854
4857
|
return true;
|
|
4855
4858
|
};
|
|
4856
|
-
return
|
|
4859
|
+
return AsyncMethodBase;
|
|
4857
4860
|
}());
|
|
4861
|
+
AsyncMethodBase.propDecorators = {
|
|
4862
|
+
disabled: [{ type: core.Input }],
|
|
4863
|
+
context: [{ type: core.Input }],
|
|
4864
|
+
onSuccess: [{ type: core.Output }],
|
|
4865
|
+
onError: [{ type: core.Output }],
|
|
4866
|
+
isDisabled: [{ type: core.HostBinding, args: ["class.disabled",] }],
|
|
4867
|
+
isLoading: [{ type: core.HostBinding, args: ["class.loading",] }],
|
|
4868
|
+
click: [{ type: core.HostListener, args: ["click",] }]
|
|
4869
|
+
};
|
|
4870
|
+
|
|
4871
|
+
var AsyncMethodDirective = /** @class */ (function (_super) {
|
|
4872
|
+
__extends(AsyncMethodDirective, _super);
|
|
4873
|
+
function AsyncMethodDirective(toaster) {
|
|
4874
|
+
return _super.call(this, toaster) || this;
|
|
4875
|
+
}
|
|
4876
|
+
AsyncMethodDirective.prototype.getMethod = function () {
|
|
4877
|
+
return this.method;
|
|
4878
|
+
};
|
|
4879
|
+
return AsyncMethodDirective;
|
|
4880
|
+
}(AsyncMethodBase));
|
|
4858
4881
|
AsyncMethodDirective.decorators = [
|
|
4859
4882
|
{ type: core.Directive, args: [{
|
|
4860
4883
|
selector: "[async-method]",
|
|
@@ -4865,14 +4888,7 @@
|
|
|
4865
4888
|
{ type: undefined, decorators: [{ type: core.Inject, args: [TOASTER_SERVICE,] }] }
|
|
4866
4889
|
]; };
|
|
4867
4890
|
AsyncMethodDirective.propDecorators = {
|
|
4868
|
-
method: [{ type: core.Input, args: ["async-method",] }]
|
|
4869
|
-
disabled: [{ type: core.Input }],
|
|
4870
|
-
context: [{ type: core.Input }],
|
|
4871
|
-
onSuccess: [{ type: core.Output }],
|
|
4872
|
-
onError: [{ type: core.Output }],
|
|
4873
|
-
isDisabled: [{ type: core.HostBinding, args: ["class.disabled",] }],
|
|
4874
|
-
isLoading: [{ type: core.HostBinding, args: ["class.loading",] }],
|
|
4875
|
-
click: [{ type: core.HostListener, args: ["click",] }]
|
|
4891
|
+
method: [{ type: core.Input, args: ["async-method",] }]
|
|
4876
4892
|
};
|
|
4877
4893
|
|
|
4878
4894
|
var defaultClass = "default-image";
|
|
@@ -5975,6 +5991,7 @@
|
|
|
5975
5991
|
exports.AjaxRequestHandler = AjaxRequestHandler;
|
|
5976
5992
|
exports.ApiService = ApiService;
|
|
5977
5993
|
exports.ArrayUtils = ArrayUtils;
|
|
5994
|
+
exports.AsyncMethodBase = AsyncMethodBase;
|
|
5978
5995
|
exports.AsyncMethodDirective = AsyncMethodDirective;
|
|
5979
5996
|
exports.AuthGuard = AuthGuard;
|
|
5980
5997
|
exports.BASE_CONFIG = BASE_CONFIG;
|