kwikid-forms 0.5.1 → 0.5.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/kwikid-forms.umd.js +109 -76
- package/bundles/kwikid-forms.umd.js.map +1 -1
- package/esm2015/lib/renderer/form-view/definitions/form-view.actions.definition.js +2 -1
- package/esm2015/lib/renderer/form-view/form-view.component.js +49 -19
- package/fesm2015/kwikid-forms.js +49 -18
- package/fesm2015/kwikid-forms.js.map +1 -1
- package/lib/renderer/form-view/definitions/form-view.actions.definition.d.ts +3 -2
- package/lib/renderer/form-view/form-view.component.d.ts +2 -1
- package/package.json +1 -1
package/fesm2015/kwikid-forms.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate, __awaiter } from 'tslib';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
3
|
import { EventEmitter, Component, Input, Output, ChangeDetectionStrategy, Inject, ViewChild, HostListener, NgModule } from '@angular/core';
|
|
4
|
-
import { checkObjectKeyExists, setValueToObjectPath, isEmptyValue, getObjectDeepCopy, logMethod, isNotEmptyValue, mergeObjects, checkObjectPathExists, setMissingKeyValue, getObjectValueFromPath, getObjectFromLocalStorage, Source, Rule, Condition, Action, PATTERNS, Validation, ESourceKey, replaceString, isUndefined, isNull } from 'kwikid-toolkit';
|
|
4
|
+
import { checkObjectKeyExists, setValueToObjectPath, isEmptyValue, getObjectDeepCopy, logMethod, isNotEmptyValue, mergeObjects, checkObjectPathExists, setMissingKeyValue, getObjectValueFromPath, getObjectFromLocalStorage, Source, Rule, Condition, Action, PATTERNS, Validation, ESourceKey, replaceString, isUndefined, isNull, isEmptyString } from 'kwikid-toolkit';
|
|
5
5
|
import * as i3$1 from '@angular/forms';
|
|
6
6
|
import { FormGroup, FormControl, Validators, FormArray, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
7
7
|
import * as i2 from 'kwikui';
|
|
@@ -1881,6 +1881,7 @@ var EActionKey;
|
|
|
1881
1881
|
EActionKey["DIALOG_HIDE"] = "DIALOG_HIDE";
|
|
1882
1882
|
EActionKey["RESUME_TASK_EXECUTION"] = "RESUME_TASK_EXECUTION";
|
|
1883
1883
|
EActionKey["STOP_TASK_EXECUTION"] = "STOP_TASK_EXECUTION";
|
|
1884
|
+
EActionKey["REDIRECT_TO_URL"] = "REDIRECT_TO_URL";
|
|
1884
1885
|
})(EActionKey || (EActionKey = {}));
|
|
1885
1886
|
|
|
1886
1887
|
var EApiStatusType;
|
|
@@ -2920,7 +2921,7 @@ class KwikIDFormViewComponent {
|
|
|
2920
2921
|
PREVIOUS_FORM_DATA: this.previousFormData,
|
|
2921
2922
|
ALL_FORMS_DATA: this.allFormsData
|
|
2922
2923
|
});
|
|
2923
|
-
if (this.
|
|
2924
|
+
if (this.isValidRequestHeadersAndBody(api)) {
|
|
2924
2925
|
if (checkObjectKeyExists(field.api, "request")) {
|
|
2925
2926
|
this.formData = Object.assign(Object.assign({}, this.formData), { [field.key]: api.response.value });
|
|
2926
2927
|
this.formGroup.patchValue({
|
|
@@ -2930,6 +2931,7 @@ class KwikIDFormViewComponent {
|
|
|
2930
2931
|
const apis = new Apis({
|
|
2931
2932
|
FIELD_CONFIG: field,
|
|
2932
2933
|
API_CONFIG: api,
|
|
2934
|
+
API_RESPONSE: api.response,
|
|
2933
2935
|
FORM_FIELDS: this.formFields,
|
|
2934
2936
|
FORM_DATA: this.formData,
|
|
2935
2937
|
TASK_DATA: this.taskData,
|
|
@@ -2967,7 +2969,7 @@ class KwikIDFormViewComponent {
|
|
|
2967
2969
|
PREVIOUS_FORM_DATA: this.previousFormData,
|
|
2968
2970
|
ALL_FORMS_DATA: this.allFormsData
|
|
2969
2971
|
}, this.takeAction.bind(this));
|
|
2970
|
-
if (this.
|
|
2972
|
+
if (this.isValidRequestHeadersAndBody(api)) {
|
|
2971
2973
|
api = yield apis.validateResponse();
|
|
2972
2974
|
}
|
|
2973
2975
|
return { api: api };
|
|
@@ -2983,7 +2985,8 @@ class KwikIDFormViewComponent {
|
|
|
2983
2985
|
api = yield apis.setRequestBody();
|
|
2984
2986
|
api = yield apis.validateRequestBody();
|
|
2985
2987
|
let apiCallResponse = {};
|
|
2986
|
-
|
|
2988
|
+
let apiCallResponseStatusCode;
|
|
2989
|
+
if (this.isValidRequestHeadersAndBody(api)) {
|
|
2987
2990
|
if (api.request.url.hasOwnProperty("type") &&
|
|
2988
2991
|
api.request.url.type === EApiRequestUrlType.MOCK) {
|
|
2989
2992
|
apiCallResponse = yield new Promise((resolve) => {
|
|
@@ -3004,6 +3007,7 @@ class KwikIDFormViewComponent {
|
|
|
3004
3007
|
headers: Object.assign({}, headers)
|
|
3005
3008
|
});
|
|
3006
3009
|
apiCallResponse = yield response.json();
|
|
3010
|
+
apiCallResponseStatusCode = response.status;
|
|
3007
3011
|
}
|
|
3008
3012
|
catch (err) {
|
|
3009
3013
|
apiCallResponse = {};
|
|
@@ -3017,6 +3021,7 @@ class KwikIDFormViewComponent {
|
|
|
3017
3021
|
body: JSON.stringify(body)
|
|
3018
3022
|
});
|
|
3019
3023
|
apiCallResponse = yield response.json();
|
|
3024
|
+
apiCallResponseStatusCode = response.status;
|
|
3020
3025
|
}
|
|
3021
3026
|
catch (err) {
|
|
3022
3027
|
apiCallResponse = {};
|
|
@@ -3024,15 +3029,14 @@ class KwikIDFormViewComponent {
|
|
|
3024
3029
|
}
|
|
3025
3030
|
}
|
|
3026
3031
|
api.response = setValueToObjectPath(api.response, "value", apiCallResponse);
|
|
3032
|
+
api.response = setValueToObjectPath(api.response, "status", apiCallResponseStatusCode);
|
|
3027
3033
|
}
|
|
3028
3034
|
return api;
|
|
3029
3035
|
});
|
|
3030
3036
|
}
|
|
3031
|
-
|
|
3032
|
-
return
|
|
3033
|
-
|
|
3034
|
-
api.request.headers.validation.is_valid);
|
|
3035
|
-
});
|
|
3037
|
+
isValidRequestHeadersAndBody(api) {
|
|
3038
|
+
return (api.request.body.validation.is_valid &&
|
|
3039
|
+
api.request.headers.validation.is_valid);
|
|
3036
3040
|
}
|
|
3037
3041
|
showApiLoader() {
|
|
3038
3042
|
this.apiLoading = true;
|
|
@@ -3552,6 +3556,20 @@ class KwikIDFormViewComponent {
|
|
|
3552
3556
|
this.dialogRef.complete();
|
|
3553
3557
|
}
|
|
3554
3558
|
}
|
|
3559
|
+
redirectToUrl(action) {
|
|
3560
|
+
if (checkObjectKeyExists(action.props, "url")) {
|
|
3561
|
+
if (checkObjectKeyExists(action.props.url, "url")) {
|
|
3562
|
+
let timeout = 2000;
|
|
3563
|
+
if (checkObjectKeyExists(action.props.url, "timeout") &&
|
|
3564
|
+
typeof action.props.url.timeout == "number") {
|
|
3565
|
+
timeout = action.props.url.timeout;
|
|
3566
|
+
}
|
|
3567
|
+
setTimeout(() => {
|
|
3568
|
+
window.location.replace(action.props.url.url);
|
|
3569
|
+
}, timeout);
|
|
3570
|
+
}
|
|
3571
|
+
}
|
|
3572
|
+
}
|
|
3555
3573
|
patchFieldControlValue(key, value) {
|
|
3556
3574
|
this.formGroup.controls[key].patchValue(value, { emitEvent: false });
|
|
3557
3575
|
}
|
|
@@ -3775,21 +3793,31 @@ class KwikIDFormViewComponent {
|
|
|
3775
3793
|
case EActionKey.TASK_API_CALL_MULTIPLE_END:
|
|
3776
3794
|
yield this.taskMultipleApiCallsEnd(action, object);
|
|
3777
3795
|
break;
|
|
3796
|
+
case EActionKey.REDIRECT_TO_URL:
|
|
3797
|
+
if (checkObjectKeyExists(action.props.url, "source")) {
|
|
3798
|
+
const redirectToUrl_Source = new Source(object);
|
|
3799
|
+
let redirectToUrlSourceValue = yield redirectToUrl_Source.getValueFromSource(action.props.url.source);
|
|
3800
|
+
if (isEmptyString(redirectToUrlSourceValue)) {
|
|
3801
|
+
redirectToUrlSourceValue = "";
|
|
3802
|
+
}
|
|
3803
|
+
action = setValueToObjectPath(action, "props.url.url", redirectToUrlSourceValue);
|
|
3804
|
+
}
|
|
3805
|
+
this.redirectToUrl(action);
|
|
3778
3806
|
case EActionKey.PREVIEW_DIALOG_SHOW:
|
|
3779
3807
|
this.showPreview(action.props);
|
|
3780
3808
|
break;
|
|
3781
3809
|
case EActionKey.PREVIEW_ERROR_SHOW:
|
|
3782
3810
|
if (checkObjectKeyExists(action.props.message, "source")) {
|
|
3783
|
-
const
|
|
3784
|
-
let
|
|
3785
|
-
if (typeof
|
|
3786
|
-
typeof
|
|
3787
|
-
|
|
3811
|
+
const previewErrorShow_Source = new Source(object);
|
|
3812
|
+
let previewErrorShowSourceValue = yield previewErrorShow_Source.getValueFromSource(action.props.message.source);
|
|
3813
|
+
if (typeof previewErrorShowSourceValue == "string" ||
|
|
3814
|
+
typeof previewErrorShowSourceValue == "number") {
|
|
3815
|
+
previewErrorShowSourceValue = String(previewErrorShowSourceValue);
|
|
3788
3816
|
}
|
|
3789
3817
|
else {
|
|
3790
|
-
|
|
3818
|
+
previewErrorShowSourceValue = "";
|
|
3791
3819
|
}
|
|
3792
|
-
action = setValueToObjectPath(action, "props.message.message",
|
|
3820
|
+
action = setValueToObjectPath(action, "props.message.message", previewErrorShowSourceValue);
|
|
3793
3821
|
}
|
|
3794
3822
|
this.showErrorPreview(action.props);
|
|
3795
3823
|
break;
|
|
@@ -3895,7 +3923,7 @@ __decorate([
|
|
|
3895
3923
|
], KwikIDFormViewComponent.prototype, "executeApiCall", null);
|
|
3896
3924
|
__decorate([
|
|
3897
3925
|
logMethod
|
|
3898
|
-
], KwikIDFormViewComponent.prototype, "
|
|
3926
|
+
], KwikIDFormViewComponent.prototype, "isValidRequestHeadersAndBody", null);
|
|
3899
3927
|
__decorate([
|
|
3900
3928
|
logMethod
|
|
3901
3929
|
], KwikIDFormViewComponent.prototype, "handleOnClickApiCall", null);
|
|
@@ -3986,6 +4014,9 @@ __decorate([
|
|
|
3986
4014
|
__decorate([
|
|
3987
4015
|
logMethod
|
|
3988
4016
|
], KwikIDFormViewComponent.prototype, "dialogHide", null);
|
|
4017
|
+
__decorate([
|
|
4018
|
+
logMethod
|
|
4019
|
+
], KwikIDFormViewComponent.prototype, "redirectToUrl", null);
|
|
3989
4020
|
__decorate([
|
|
3990
4021
|
logMethod
|
|
3991
4022
|
], KwikIDFormViewComponent.prototype, "patchFieldControlValue", null);
|
|
@@ -4069,7 +4100,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
4069
4100
|
type: Output
|
|
4070
4101
|
}], onActionShowPopupForm: [{
|
|
4071
4102
|
type: Output
|
|
4072
|
-
}], ngOnInit: [], ngAfterViewInit: [], ngOnChanges: [], initFormConfig: [], setFormFieldsFromFormConfig: [], setFormFieldGroupsFromFormConfig: [], setFormDataFromAllFormsData: [], handleConnectedElementFieldGroupActions: [], handleConnectedElementFieldGroup: [], handleConnectedElementFieldActions: [], handleConnectedElementFields: [], handleConnectedElements: [], handleRemovedFile: [], handleGetKeyValueFile: [], updateFiles: [], uploadFile: [], handleGetKeyValue: [], handleOnClickResetFormFields: [], handleFieldApiCall: [], handleApiCall: [], executeApiCall: [],
|
|
4103
|
+
}], ngOnInit: [], ngAfterViewInit: [], ngOnChanges: [], initFormConfig: [], setFormFieldsFromFormConfig: [], setFormFieldGroupsFromFormConfig: [], setFormDataFromAllFormsData: [], handleConnectedElementFieldGroupActions: [], handleConnectedElementFieldGroup: [], handleConnectedElementFieldActions: [], handleConnectedElementFields: [], handleConnectedElements: [], handleRemovedFile: [], handleGetKeyValueFile: [], updateFiles: [], uploadFile: [], handleGetKeyValue: [], handleOnClickResetFormFields: [], handleFieldApiCall: [], handleApiCall: [], executeApiCall: [], isValidRequestHeadersAndBody: [], handleOnClickApiCall: [], handleOnClickGoBack: [], handleOnClickViewForms: [], handleOnClickSaveForm: [], toggleErrorNotification: [], fieldHide: [], fieldGroupHide: [], fieldShow: [], fieldGroupShow: [], fieldDisable: [], fieldGroupDisable: [], fieldEnable: [], fieldGroupEnable: [], fieldReset: [], fieldErrorShow: [], fieldErrorHide: [], fieldMessageShow: [], fieldMessageHide: [], setValue: [], setFieldDefaultValue: [], setDropdownOptions: [], apiCall: [], fieldApiCall: [], fieldMultipleApiCalls: [], fieldMultipleApiCallsEnd: [], taskApiCall: [], taskMultipleApiCalls: [], taskMultipleApiCallsEnd: [], dialogShow: [], dialogHide: [], redirectToUrl: [], patchFieldControlValue: [], setFieldControlValue: [], patchFormGroup: [], isFieldValid: [], isFieldEnabled: [], getFormGroupRawValues: [], showPreview: [], showErrorPreview: [], showPopupForm: [], takeActionOnFieldGroup: [], takeAction: [] } });
|
|
4073
4104
|
|
|
4074
4105
|
var EFormType;
|
|
4075
4106
|
(function (EFormType) {
|