kwikid-forms 0.1.7 → 0.1.9
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 +724 -1041
- package/bundles/kwikid-forms.umd.js.map +1 -1
- package/esm2015/lib/renderer/form-view/definitions/form-view.actions.definition.js +21 -0
- package/esm2015/lib/renderer/form-view/definitions/form-view.apis.definition.js +8 -0
- package/esm2015/lib/renderer/form-view/definitions/form-view.commons.definition.js +8 -0
- package/esm2015/lib/renderer/form-view/definitions/form-view.fields.definition.js +16 -0
- package/esm2015/lib/renderer/form-view/definitions/form-view.form-validations.definition.js +2 -0
- package/esm2015/lib/renderer/form-view/definitions/form-view.triggers.definition.js +2 -0
- package/esm2015/lib/renderer/form-view/form-view.component.js +173 -163
- package/esm2015/lib/renderer/form-view/form-view.module.js +4 -3
- package/esm2015/lib/renderer/form-view/form-view.service.js +8 -8
- package/esm2015/lib/renderer/form-view/helpers/form-view.apis.helper.js +29 -70
- package/esm2015/lib/renderer/form-view/helpers/form-view.defaults.helper.js +43 -13
- package/esm2015/lib/renderer/form-view/helpers/form-view.fields.helper.js +45 -63
- package/esm2015/lib/renderer/form-view/helpers/form-view.form-validations.helper.js +101 -0
- package/esm2015/lib/renderer/form-view/pipes/safe-html.pipe.js +25 -0
- package/esm2015/lib/renderer/renderer.component.js +8 -7
- package/esm2015/lib/renderer/renderer.config-converter.helper.js +113 -58
- package/esm2015/lib/renderer/renderer.service.js +11 -14
- package/fesm2015/kwikid-forms.js +488 -758
- package/fesm2015/kwikid-forms.js.map +1 -1
- package/lib/renderer/form-view/definitions/{actions/form-view.actions.type.definitions.d.ts → form-view.actions.definition.d.ts} +21 -9
- package/lib/renderer/form-view/definitions/{apis/form-view.apis.type.definitions.d.ts → form-view.apis.definition.d.ts} +7 -3
- package/lib/renderer/form-view/definitions/form-view.commons.definition.d.ts +11 -0
- package/lib/renderer/form-view/definitions/{fields/form-view.fields.type.definitions.d.ts → form-view.fields.definition.d.ts} +27 -6
- package/lib/renderer/form-view/definitions/form-view.form-validations.definition.d.ts +8 -0
- package/lib/renderer/form-view/definitions/{triggers/form-view.triggers.type.definitions.d.ts → form-view.triggers.definition.d.ts} +0 -0
- package/lib/renderer/form-view/form-view.component.d.ts +5 -5
- package/lib/renderer/form-view/form-view.module.d.ts +7 -6
- package/lib/renderer/form-view/helpers/form-view.apis.helper.d.ts +7 -9
- package/lib/renderer/form-view/helpers/form-view.defaults.helper.d.ts +5 -3
- package/lib/renderer/form-view/helpers/form-view.fields.helper.d.ts +12 -17
- package/lib/renderer/form-view/helpers/form-view.form-validations.helper.d.ts +10 -0
- package/lib/renderer/form-view/pipes/safe-html.pipe.d.ts +15 -0
- package/package.json +3 -3
- package/esm2015/lib/renderer/form-view/definitions/actions/form-view.actions.enum.definitions.js +0 -20
- package/esm2015/lib/renderer/form-view/definitions/actions/form-view.actions.type.definitions.js +0 -2
- package/esm2015/lib/renderer/form-view/definitions/apis/form-view.apis.enum.definitions.js +0 -8
- package/esm2015/lib/renderer/form-view/definitions/apis/form-view.apis.type.definitions.js +0 -2
- package/esm2015/lib/renderer/form-view/definitions/common/form-view.common.enum.definitions.js +0 -101
- package/esm2015/lib/renderer/form-view/definitions/common/form-view.common.type.definitions.js +0 -2
- package/esm2015/lib/renderer/form-view/definitions/fields/form-view.fields.enum.definitions.js +0 -15
- package/esm2015/lib/renderer/form-view/definitions/fields/form-view.fields.type.definitions.js +0 -2
- package/esm2015/lib/renderer/form-view/definitions/sources/form-view.sources.type.definitions.js +0 -2
- package/esm2015/lib/renderer/form-view/definitions/triggers/form-view.triggers.type.definitions.js +0 -2
- package/esm2015/lib/renderer/form-view/definitions/validations/form-view.validations.type.definitions.js +0 -2
- package/esm2015/lib/renderer/form-view/helpers/form-view.common.helper.js +0 -136
- package/esm2015/lib/renderer/form-view/helpers/form-view.validations.helper.js +0 -161
- package/esm2015/lib/renderer/renderer.helper.js +0 -50
- package/lib/renderer/form-view/definitions/actions/form-view.actions.enum.definitions.d.ts +0 -18
- package/lib/renderer/form-view/definitions/apis/form-view.apis.enum.definitions.d.ts +0 -6
- package/lib/renderer/form-view/definitions/common/form-view.common.enum.definitions.d.ts +0 -97
- package/lib/renderer/form-view/definitions/common/form-view.common.type.definitions.d.ts +0 -7
- package/lib/renderer/form-view/definitions/fields/form-view.fields.enum.definitions.d.ts +0 -13
- package/lib/renderer/form-view/definitions/sources/form-view.sources.type.definitions.d.ts +0 -16
- package/lib/renderer/form-view/definitions/validations/form-view.validations.type.definitions.d.ts +0 -16
- package/lib/renderer/form-view/helpers/form-view.common.helper.d.ts +0 -19
- package/lib/renderer/form-view/helpers/form-view.validations.helper.d.ts +0 -25
- package/lib/renderer/renderer.helper.d.ts +0 -6
package/fesm2015/kwikid-forms.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { copyArrayItem, moveItemInArray, DragDropModule } from '@angular/cdk/drag-drop';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { VERSION, Component, EventEmitter, Inject, Input, Output, Injectable, HostListener, NgModule } from '@angular/core';
|
|
3
|
+
import { VERSION, Component, Pipe, EventEmitter, Inject, Input, Output, Injectable, HostListener, NgModule } from '@angular/core';
|
|
4
4
|
import * as i6 from '@angular/forms';
|
|
5
5
|
import { FormGroup, FormControl, Validators, FormArray, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
6
6
|
import * as i2 from 'kwikui';
|
|
7
7
|
import { KwikUIButtonComponent, KwikUIProgressSegmentedComponent, KwikUIInputComponent, KwikUIModule } from 'kwikui';
|
|
8
|
-
import
|
|
8
|
+
import { cloneDeep } from 'lodash';
|
|
9
9
|
import { __awaiter, __decorate } from 'tslib';
|
|
10
10
|
import * as i3 from '@taiga-ui/core';
|
|
11
11
|
import { TuiAlertService, TuiLabelModule, TuiSvgModule, TuiLoaderModule } from '@taiga-ui/core';
|
|
12
12
|
import * as i4 from '@taiga-ui/kit';
|
|
13
13
|
import { TuiPushService, TuiPushModule } from '@taiga-ui/kit';
|
|
14
|
-
import {
|
|
14
|
+
import { checkObjectKeyExists, isNotEmptyValue, Source, setValueToObjectPath, Rule, Condition, Action, isEmptyValue, logMethod, PATTERNS, Validation, isUndefined, replaceString, getObjectValueFromPath } from 'kwikid-toolkit';
|
|
15
15
|
import { pairwise } from 'rxjs/operators';
|
|
16
|
-
import jp from 'jsonpath';
|
|
17
16
|
import { TuiDay } from '@taiga-ui/cdk';
|
|
18
17
|
import * as i5 from '@angular/common';
|
|
19
18
|
import { CommonModule } from '@angular/common';
|
|
19
|
+
import * as i1 from '@angular/platform-browser';
|
|
20
20
|
import { trigger, transition, style, animate } from '@angular/animations';
|
|
21
21
|
import { HttpClientModule } from '@angular/common/http';
|
|
22
22
|
|
|
@@ -170,6 +170,7 @@ var EActionKey;
|
|
|
170
170
|
EActionKey["FIELD_GROUP_HIDE"] = "FIELD_GROUP_HIDE";
|
|
171
171
|
EActionKey["FIELD_GROUP_ENABLE"] = "FIELD_GROUP_ENABLE";
|
|
172
172
|
EActionKey["FIELD_GROUP_DISABLE"] = "FIELD_GROUP_DISABLE";
|
|
173
|
+
EActionKey["SET_DROPDOWN_OPTIONS"] = "SET_DROPDOWN_OPTIONS";
|
|
173
174
|
})(EActionKey || (EActionKey = {}));
|
|
174
175
|
|
|
175
176
|
var EApiStatusType;
|
|
@@ -180,99 +181,6 @@ var EApiStatusType;
|
|
|
180
181
|
EApiStatusType["FAILED"] = "failed";
|
|
181
182
|
})(EApiStatusType || (EApiStatusType = {}));
|
|
182
183
|
|
|
183
|
-
var EPatternKey;
|
|
184
|
-
(function (EPatternKey) {
|
|
185
|
-
EPatternKey["CUSTOM"] = "CUSTOM";
|
|
186
|
-
EPatternKey["IS_ADDRESS"] = "IS_ADDRESS";
|
|
187
|
-
EPatternKey["IS_ALPHA"] = "IS_ALPHA";
|
|
188
|
-
EPatternKey["IS_ALPHANUMERIC"] = "IS_ALPHANUMERIC";
|
|
189
|
-
EPatternKey["IS_BOOLEAN"] = "IS_BOOLEAN";
|
|
190
|
-
EPatternKey["IS_EMAIL"] = "IS_EMAIL";
|
|
191
|
-
EPatternKey["IS_EMPTY"] = "IS_EMPTY";
|
|
192
|
-
EPatternKey["IS_FALSE"] = "IS_FALSE";
|
|
193
|
-
EPatternKey["IS_HTML"] = "IS_HTML";
|
|
194
|
-
EPatternKey["IS_INTEGER"] = "IS_INTEGER";
|
|
195
|
-
EPatternKey["IS_IP_ADDRESS"] = "IS_IP_ADDRESS";
|
|
196
|
-
EPatternKey["IS_JSON"] = "IS_JSON";
|
|
197
|
-
EPatternKey["IS_LOWERCASE"] = "IS_LOWERCASE";
|
|
198
|
-
EPatternKey["IS_NOT_EMPTY"] = "IS_NOT_EMPTY";
|
|
199
|
-
EPatternKey["IS_NUMBER"] = "IS_NUMBER";
|
|
200
|
-
EPatternKey["IS_TRUE"] = "IS_TRUE";
|
|
201
|
-
EPatternKey["IS_UPPERCASE"] = "IS_UPPERCASE";
|
|
202
|
-
EPatternKey["IS_URL"] = "IS_URL";
|
|
203
|
-
EPatternKey["IS_AADHAAR_NUMBER"] = "IS_AADHAAR_NUMBER";
|
|
204
|
-
EPatternKey["IS_BANK_ACCOUNT_NO"] = "IS_BANK_ACCOUNT_NO";
|
|
205
|
-
EPatternKey["IS_BANK_SWIFT_CODE"] = "IS_BANK_SWIFT_CODE";
|
|
206
|
-
EPatternKey["IS_BIRTH_CERTIFICATE_NO"] = "IS_BIRTH_CERTIFICATE_NO";
|
|
207
|
-
EPatternKey["IS_CHEQUE_NO"] = "IS_CHEQUE_NO";
|
|
208
|
-
EPatternKey["IS_CIN"] = "IS_CIN";
|
|
209
|
-
EPatternKey["IS_CREDIT_CARD_NO"] = "IS_CREDIT_CARD_NO";
|
|
210
|
-
EPatternKey["IS_DRIVING_LICENSE"] = "IS_DRIVING_LICENSE";
|
|
211
|
-
EPatternKey["IS_GSTIN"] = "IS_GSTIN";
|
|
212
|
-
EPatternKey["IS_IFSC_NO"] = "IS_IFSC_NO";
|
|
213
|
-
EPatternKey["IS_MICR_CODE"] = "IS_MICR_CODE";
|
|
214
|
-
EPatternKey["IS_MOBILE_NO"] = "IS_MOBILE_NO";
|
|
215
|
-
EPatternKey["IS_MOBILE_NO_IN"] = "IS_MOBILE_NO_IN";
|
|
216
|
-
EPatternKey["IS_NEFT_OR_RTGS_NO"] = "IS_NEFT_OR_RTGS_NO";
|
|
217
|
-
EPatternKey["IS_PAN_NUMBER"] = "IS_PAN_NUMBER";
|
|
218
|
-
EPatternKey["IS_PASSPORT"] = "IS_PASSPORT";
|
|
219
|
-
EPatternKey["IS_PHONE_NO"] = "IS_PHONE_NO";
|
|
220
|
-
EPatternKey["IS_PINCODE"] = "IS_PINCODE";
|
|
221
|
-
EPatternKey["IS_PURCHASE_ORDER_NO"] = "IS_PURCHASE_ORDER_NO";
|
|
222
|
-
EPatternKey["IS_RATION_CARD_NO"] = "IS_RATION_CARD_NO";
|
|
223
|
-
EPatternKey["IS_SERVICE_TAX_NO"] = "IS_SERVICE_TAX_NO";
|
|
224
|
-
EPatternKey["IS_SOCIAL_SECURITY_NO"] = "IS_SOCIAL_SECURITY_NO";
|
|
225
|
-
EPatternKey["IS_UPI_TRANSACTION_REFERENCE_NO"] = "IS_UPI_TRANSACTION_REFERENCE_NO";
|
|
226
|
-
EPatternKey["IS_VAT_TIN_NO"] = "IS_VAT_TIN_NO";
|
|
227
|
-
EPatternKey["IS_VEHICLE_REGISTRATION_NO"] = "IS_VEHICLE_REGISTRATION_NO";
|
|
228
|
-
EPatternKey["IS_VOTER_ID"] = "IS_VOTER_ID";
|
|
229
|
-
})(EPatternKey || (EPatternKey = {}));
|
|
230
|
-
var EPattern;
|
|
231
|
-
(function (EPattern) {
|
|
232
|
-
EPattern["IS_ALPHA"] = "^[a-zA-Z]+$";
|
|
233
|
-
EPattern["IS_ADDRESS"] = "^(\\w*\\s*[#-,/.()&]*)+";
|
|
234
|
-
EPattern["IS_ALPHANUMERIC"] = "^[a-zA-Z0-9]+$";
|
|
235
|
-
EPattern["IS_BOOLEAN"] = "(true|false)";
|
|
236
|
-
EPattern["IS_EMAIL"] = "^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+$";
|
|
237
|
-
EPattern["IS_EMPTY"] = "^$";
|
|
238
|
-
EPattern["IS_FALSE"] = "false";
|
|
239
|
-
EPattern["IS_HTML"] = "^<([a-z]+)([^<]+)(?:>(.)</\\1>|\\s+/>)$";
|
|
240
|
-
EPattern["IS_INTEGER"] = "^[+-]?d+$";
|
|
241
|
-
EPattern["IS_IP_ADDRESS"] = "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$";
|
|
242
|
-
EPattern["IS_JSON"] = "^\\s*({(.|\\s)}|[(.|\\s)])\\s*$";
|
|
243
|
-
EPattern["IS_LOWERCASE"] = "^[a-z]+$";
|
|
244
|
-
EPattern["IS_NOT_EMPTY"] = "^.+$";
|
|
245
|
-
EPattern["IS_NUMBER"] = "^[+-]?d+(.d+)?$";
|
|
246
|
-
EPattern["IS_TRUE"] = "true";
|
|
247
|
-
EPattern["IS_UPPERCASE"] = "^[A-Z]+$";
|
|
248
|
-
EPattern["IS_URL"] = "^(?:http(s)?://)?[w.-]+(?:.[w.-]+)+[w-._~:/?#[]@!$&'()*+,;=.]+$";
|
|
249
|
-
EPattern["IS_AADHAAR_NUMBER"] = "^[0-9]{12}$";
|
|
250
|
-
EPattern["IS_BANK_ACCOUNT_NO"] = "^[0-9]{9,18}$";
|
|
251
|
-
EPattern["IS_BANK_SWIFT_CODE"] = "^[A-Z]{4}[A-Z]{2}[0-9A-Z]{2}[0-9A-Z]{3}$";
|
|
252
|
-
EPattern["IS_BIRTH_CERTIFICATE_NO"] = "^[A-Z]{2}[0-9]{6}[A-Z]{1}[0-9]{2}$";
|
|
253
|
-
EPattern["IS_CHEQUE_NO"] = "^[0-9]{6,14}$";
|
|
254
|
-
EPattern["IS_CIN"] = "^[A-Z]{3}[0-9]{5}[0-9A-Z]{3}$";
|
|
255
|
-
EPattern["IS_CREDIT_CARD_NO"] = "^[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{4}$";
|
|
256
|
-
EPattern["IS_DRIVING_LICENSE"] = "^[A-Z]{2}[0-9]{2}((19|20)[0-9][0-9])[0-9]{7}$";
|
|
257
|
-
EPattern["IS_GSTIN"] = "^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$";
|
|
258
|
-
EPattern["IS_IFSC_NO"] = "^[A-Z]{4}[0][A-Z0-9]{6}$";
|
|
259
|
-
EPattern["IS_MICR_CODE"] = "^[0-9]{9}$";
|
|
260
|
-
EPattern["IS_MOBILE_NO"] = "^[6-9]\\d{9}$";
|
|
261
|
-
EPattern["IS_MOBILE_NO_IN"] = "^(\\+91)[6-9]\\d{9}$";
|
|
262
|
-
EPattern["IS_NEFT_OR_RTGS_NO"] = "^[A-Z]{4}[0-9]{7}$";
|
|
263
|
-
EPattern["IS_PAN_NUMBER"] = "^[A-Z]{5}[[0-9]{4}[A-Z]{1}$";
|
|
264
|
-
EPattern["IS_PASSPORT"] = "^[A-PR-WYa-pr-wy][1-9]\\d\\s?\\d{4}[1-9]$";
|
|
265
|
-
EPattern["IS_PHONE_NO"] = "^[6-9]\\d{9}$";
|
|
266
|
-
EPattern["IS_PINCODE"] = "^[1-9][0-9]{5}$";
|
|
267
|
-
EPattern["IS_PURCHASE_ORDER_NO"] = "^[0-9]{1,5}$";
|
|
268
|
-
EPattern["IS_RATION_CARD_NO"] = "^[A-Z]{3}[0-9]{7}$";
|
|
269
|
-
EPattern["IS_SERVICE_TAX_NO"] = "^[A-Z]{5}[0-9]{4}[A-Z]{1}$";
|
|
270
|
-
EPattern["IS_SOCIAL_SECURITY_NO"] = "^[0-9]{3}-[0-9]{2}-[0-9]{4}$";
|
|
271
|
-
EPattern["IS_UPI_TRANSACTION_REFERENCE_NO"] = "^[a-zA-Z0-9]{3,128}@[a-z]{3,9}$";
|
|
272
|
-
EPattern["IS_VAT_TIN_NO"] = "^[0-9]{11}$";
|
|
273
|
-
EPattern["IS_VEHICLE_REGISTRATION_NO"] = "^[A-Z]{2}[0-9]{2}((19|20)[0-9][0-9])[0-9]{6}$";
|
|
274
|
-
EPattern["IS_VOTER_ID"] = "^[A-Z]{3}[0-9]{7}$";
|
|
275
|
-
})(EPattern || (EPattern = {}));
|
|
276
184
|
var EMessageType;
|
|
277
185
|
(function (EMessageType) {
|
|
278
186
|
EMessageType["DEFAULT"] = "default";
|
|
@@ -283,6 +191,7 @@ var EMessageType;
|
|
|
283
191
|
|
|
284
192
|
var EFieldType;
|
|
285
193
|
(function (EFieldType) {
|
|
194
|
+
EFieldType["HTML"] = "html";
|
|
286
195
|
EFieldType["TITLE"] = "title";
|
|
287
196
|
EFieldType["TEXT"] = "text";
|
|
288
197
|
EFieldType["CHECKBOX"] = "checkbox";
|
|
@@ -296,247 +205,7 @@ var EFieldType;
|
|
|
296
205
|
EFieldType["AADHAAR_NUMBER"] = "aadhaar-number";
|
|
297
206
|
})(EFieldType || (EFieldType = {}));
|
|
298
207
|
|
|
299
|
-
const
|
|
300
|
-
return object.hasOwnProperty(key);
|
|
301
|
-
};
|
|
302
|
-
const isEmpty$1 = (value) => {
|
|
303
|
-
if (value === "" || value === undefined || value === null) {
|
|
304
|
-
return true;
|
|
305
|
-
}
|
|
306
|
-
else if (value &&
|
|
307
|
-
Object.keys(value).length === 0 &&
|
|
308
|
-
Object.getPrototypeOf(value) === Object.prototype) {
|
|
309
|
-
return true;
|
|
310
|
-
}
|
|
311
|
-
else if (Array.isArray(value)) {
|
|
312
|
-
if (value.length === 0) {
|
|
313
|
-
return true;
|
|
314
|
-
}
|
|
315
|
-
else {
|
|
316
|
-
return false;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
else {
|
|
320
|
-
return false;
|
|
321
|
-
}
|
|
322
|
-
};
|
|
323
|
-
const isNotEmpty$1 = (value) => {
|
|
324
|
-
return !isEmpty$1(value);
|
|
325
|
-
};
|
|
326
|
-
const handleJPQueryResponse$1 = (value) => {
|
|
327
|
-
/**
|
|
328
|
-
* jp.query doesn't always return an array with one element
|
|
329
|
-
* so directly can't access with [0], need to check conditionally
|
|
330
|
-
*/
|
|
331
|
-
if (Array.isArray(value)) {
|
|
332
|
-
if (value.length > 0) {
|
|
333
|
-
value = value[0];
|
|
334
|
-
}
|
|
335
|
-
else if (value.length === 0) {
|
|
336
|
-
value = "";
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
return value;
|
|
340
|
-
};
|
|
341
|
-
const jpQueryWrapper$1 = (obj, key) => {
|
|
342
|
-
return handleJPQueryResponse$1(jp.query(obj, key));
|
|
343
|
-
};
|
|
344
|
-
const isSingleForm = (formsList) => {
|
|
345
|
-
return formsList.length === 1;
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
const hasKey = (object, key) => {
|
|
349
|
-
return object.hasOwnProperty(key);
|
|
350
|
-
};
|
|
351
|
-
const hasPath = (object, path) => {
|
|
352
|
-
return _.has(object, path);
|
|
353
|
-
};
|
|
354
|
-
const isEmptyString = (value) => {
|
|
355
|
-
return value === "";
|
|
356
|
-
};
|
|
357
|
-
const isUndefined = (value) => {
|
|
358
|
-
return value === undefined;
|
|
359
|
-
};
|
|
360
|
-
const isNull = (value) => {
|
|
361
|
-
return value === null;
|
|
362
|
-
};
|
|
363
|
-
const isEmptyObject = (object) => {
|
|
364
|
-
return (object &&
|
|
365
|
-
Object.keys(object).length === 0 &&
|
|
366
|
-
Object.getPrototypeOf(object) === Object.prototype);
|
|
367
|
-
};
|
|
368
|
-
const isEmptyArray = (arr) => {
|
|
369
|
-
return arr.length === 0;
|
|
370
|
-
};
|
|
371
|
-
const isEmpty = (value) => {
|
|
372
|
-
if (isEmptyString(value) || isUndefined(value) || isNull(value)) {
|
|
373
|
-
return true;
|
|
374
|
-
}
|
|
375
|
-
else if (isEmptyObject(value)) {
|
|
376
|
-
return true;
|
|
377
|
-
}
|
|
378
|
-
else if (Array.isArray(value)) {
|
|
379
|
-
if (isEmptyArray(value)) {
|
|
380
|
-
return true;
|
|
381
|
-
}
|
|
382
|
-
else {
|
|
383
|
-
return false;
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
else {
|
|
387
|
-
return false;
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
const isNotEmpty = (value) => {
|
|
391
|
-
return !isEmpty(value);
|
|
392
|
-
};
|
|
393
|
-
const isEmptyBrowserStorageValue = (value) => {
|
|
394
|
-
return isNull(value) && isUndefined(value);
|
|
395
|
-
};
|
|
396
|
-
const isNotEmptyBrowserStorageValue = (value) => {
|
|
397
|
-
return !isEmptyBrowserStorageValue(value);
|
|
398
|
-
};
|
|
399
|
-
const handleJPQueryResponse = (value) => {
|
|
400
|
-
/**
|
|
401
|
-
* jp.query doesn't always return an array with one element
|
|
402
|
-
* so directly can't access with [0], need to check conditionally
|
|
403
|
-
*/
|
|
404
|
-
if (Array.isArray(value)) {
|
|
405
|
-
if (value.length > 0) {
|
|
406
|
-
value = value[0];
|
|
407
|
-
}
|
|
408
|
-
else if (value.length === 0) {
|
|
409
|
-
value = "";
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
else {
|
|
413
|
-
value = "";
|
|
414
|
-
}
|
|
415
|
-
return value;
|
|
416
|
-
};
|
|
417
|
-
const jpQueryWrapper = (obj, key) => {
|
|
418
|
-
return handleJPQueryResponse(jp.query(obj, key));
|
|
419
|
-
};
|
|
420
|
-
const replaceString = (str, find, replace) => {
|
|
421
|
-
return str.replace(new RegExp(find, "g"), replace);
|
|
422
|
-
};
|
|
423
|
-
const setFieldKeyValue = (field, path, value) => {
|
|
424
|
-
return _.set(field, path, value);
|
|
425
|
-
};
|
|
426
|
-
const setValueToObject = (object, path, value) => {
|
|
427
|
-
return _.set(object, path, value);
|
|
428
|
-
};
|
|
429
|
-
const formatValue = (field, fieldValue) => {
|
|
430
|
-
const fieldType = field.type;
|
|
431
|
-
let value;
|
|
432
|
-
if (isNotEmpty(fieldValue)) {
|
|
433
|
-
switch (fieldType) {
|
|
434
|
-
case EFieldType.DATE:
|
|
435
|
-
const splitDate = fieldValue.split("-");
|
|
436
|
-
value = new TuiDay(Number(splitDate[2]), // Year
|
|
437
|
-
Number(splitDate[1]) - 1, // Month, Why '-1' => Because Taiga-UI Required It, So...
|
|
438
|
-
Number(splitDate[0]) // Day
|
|
439
|
-
);
|
|
440
|
-
break;
|
|
441
|
-
case EFieldType.RADIO:
|
|
442
|
-
const fieldRadio = field;
|
|
443
|
-
value = fieldRadio.options.find((item) => {
|
|
444
|
-
return item.label === fieldValue;
|
|
445
|
-
});
|
|
446
|
-
break;
|
|
447
|
-
case EFieldType.CHECKBOX:
|
|
448
|
-
value = Boolean(fieldValue);
|
|
449
|
-
break;
|
|
450
|
-
default:
|
|
451
|
-
value = fieldValue;
|
|
452
|
-
break;
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
else {
|
|
456
|
-
value = fieldValue;
|
|
457
|
-
}
|
|
458
|
-
return value;
|
|
459
|
-
};
|
|
460
|
-
const setEmptyValue = (field) => {
|
|
461
|
-
const fieldType = field.type;
|
|
462
|
-
let value;
|
|
463
|
-
switch (fieldType) {
|
|
464
|
-
case EFieldType.CHECKBOX:
|
|
465
|
-
value = false;
|
|
466
|
-
break;
|
|
467
|
-
case EFieldType.NUMBER:
|
|
468
|
-
value = null;
|
|
469
|
-
break;
|
|
470
|
-
case EFieldType.DATE:
|
|
471
|
-
value = null;
|
|
472
|
-
break;
|
|
473
|
-
default:
|
|
474
|
-
value = "";
|
|
475
|
-
break;
|
|
476
|
-
}
|
|
477
|
-
return value;
|
|
478
|
-
};
|
|
479
|
-
|
|
480
|
-
class Defaults {
|
|
481
|
-
constructor(field, allFormsData, formData, previousFormData, takeAction) {
|
|
482
|
-
this._field = field;
|
|
483
|
-
this._allFormsData = allFormsData;
|
|
484
|
-
this._formData = formData;
|
|
485
|
-
this._previousFormData = previousFormData;
|
|
486
|
-
this._takeAction = takeAction;
|
|
487
|
-
}
|
|
488
|
-
getDefaultValue() {
|
|
489
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
490
|
-
let defaultValue;
|
|
491
|
-
const sources = this._field.default.value.sources;
|
|
492
|
-
let sourceIndex = 0;
|
|
493
|
-
for (let source of sources) {
|
|
494
|
-
const sources = new Sources({
|
|
495
|
-
FIELD_CONFIG: this._field,
|
|
496
|
-
FORM_DATA: this._formData,
|
|
497
|
-
PREVIOUS_FORM_DATA: this._previousFormData,
|
|
498
|
-
ALL_FORMS_DATA: this._allFormsData
|
|
499
|
-
});
|
|
500
|
-
const value = sources.getValueFromSource(source);
|
|
501
|
-
// Set the Value of current source.
|
|
502
|
-
this._field = setValueToObject(this._field, `default.value.sources.[${sourceIndex}].value`, value);
|
|
503
|
-
const validation = source.validation;
|
|
504
|
-
const triggers = validation.triggers;
|
|
505
|
-
const rules = validation.rules;
|
|
506
|
-
const actions = validation.actions;
|
|
507
|
-
const rulesMapping = new Rules(rules, {
|
|
508
|
-
FIELD_CONFIG: this._field,
|
|
509
|
-
FORM_DATA: this._formData,
|
|
510
|
-
PREVIOUS_FORM_DATA: this._previousFormData,
|
|
511
|
-
ALL_FORMS_DATA: this._allFormsData
|
|
512
|
-
}).mapping();
|
|
513
|
-
for (let action of actions) {
|
|
514
|
-
const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
|
|
515
|
-
if (conditionEvaluation) {
|
|
516
|
-
const actions = new Actions(action, rulesMapping, {
|
|
517
|
-
FIELD_CONFIG: this._field,
|
|
518
|
-
FORM_DATA: this._formData,
|
|
519
|
-
PREVIOUS_FORM_DATA: this._previousFormData,
|
|
520
|
-
ALL_FORMS_DATA: this._allFormsData
|
|
521
|
-
}, this._takeAction);
|
|
522
|
-
yield actions.execute();
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
sourceIndex++;
|
|
526
|
-
}
|
|
527
|
-
defaultValue = this._field.default.value.value;
|
|
528
|
-
if (isEmpty$1(defaultValue)) {
|
|
529
|
-
defaultValue = setEmptyValue(this._field);
|
|
530
|
-
}
|
|
531
|
-
return defaultValue;
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
__decorate([
|
|
536
|
-
logMethod
|
|
537
|
-
], Defaults.prototype, "getDefaultValue", null);
|
|
538
|
-
|
|
539
|
-
const findFieldFromKey = (fields, key) => {
|
|
208
|
+
const getFormFieldByKey = (fields, key) => {
|
|
540
209
|
const field = fields.find((field) => {
|
|
541
210
|
if (field.key === key) {
|
|
542
211
|
return field;
|
|
@@ -544,59 +213,20 @@ const findFieldFromKey = (fields, key) => {
|
|
|
544
213
|
});
|
|
545
214
|
return field;
|
|
546
215
|
};
|
|
547
|
-
const
|
|
216
|
+
const getFormFieldIndexByKey = (fields, key) => {
|
|
548
217
|
let fieldIndex;
|
|
549
218
|
fieldIndex = fields.findIndex((_) => {
|
|
550
219
|
return key === _.key;
|
|
551
220
|
});
|
|
552
221
|
return fieldIndex;
|
|
553
222
|
};
|
|
554
|
-
const
|
|
555
|
-
const parentFieldValue = formGroup.controls[field.key].value;
|
|
556
|
-
// Determine the URL of the remote file to fetch
|
|
557
|
-
let fileUrl;
|
|
558
|
-
if (childField.regexToGetJsonRemoteUrlKey) {
|
|
559
|
-
const fileKey = parentFieldValue.match(childField.regexToGetJsonRemoteUrlKey)[0];
|
|
560
|
-
fileUrl = childField.jsonRemoteUrlMapping[fileKey];
|
|
561
|
-
}
|
|
562
|
-
else {
|
|
563
|
-
fileUrl = childField.fileUrl;
|
|
564
|
-
}
|
|
565
|
-
// Return early if there is no file URL
|
|
566
|
-
if (!fileUrl)
|
|
567
|
-
return;
|
|
568
|
-
// Fetch the remote file and parse its JSON data
|
|
569
|
-
const response = yield fetch(fileUrl);
|
|
570
|
-
const data = yield response.json();
|
|
571
|
-
// Return the data for the given parent field value
|
|
572
|
-
return data[parentFieldValue];
|
|
573
|
-
});
|
|
574
|
-
const getSearchTextOptionsFromFieldConfig = (field, childField, formGroup) => {
|
|
575
|
-
let options;
|
|
576
|
-
const fieldValue = formGroup.controls[field.key].value;
|
|
577
|
-
if (isNotEmptyValue(childField["json"])) {
|
|
578
|
-
options = childField["json"][fieldValue];
|
|
579
|
-
}
|
|
580
|
-
return options;
|
|
581
|
-
};
|
|
582
|
-
const formatSearchTextOptions = (options) => {
|
|
583
|
-
return options.map(({ title }) => title);
|
|
584
|
-
};
|
|
585
|
-
function highlightFieldError(field, error) {
|
|
223
|
+
const highlightFormFieldError = (field, error) => {
|
|
586
224
|
field.invalid = error;
|
|
587
225
|
field.focus = error;
|
|
588
|
-
// if (!error) {
|
|
589
|
-
// field["messages"] = field["messages"].filter(function (fieldMessage: {
|
|
590
|
-
// type: string;
|
|
591
|
-
// message: string;
|
|
592
|
-
// }) {
|
|
593
|
-
// return fieldMessage.type === "error";
|
|
594
|
-
// });
|
|
595
|
-
// }
|
|
596
226
|
return field;
|
|
597
|
-
}
|
|
598
|
-
const
|
|
599
|
-
const
|
|
227
|
+
};
|
|
228
|
+
const appendFormFieldMessage = (field, message) => {
|
|
229
|
+
const hasDuplicateMessage = (messages, message) => {
|
|
600
230
|
return messages.some((fieldMessage) => {
|
|
601
231
|
return (fieldMessage.type === message.type &&
|
|
602
232
|
fieldMessage.message === message.message);
|
|
@@ -604,7 +234,7 @@ const addMessage = (field, message) => {
|
|
|
604
234
|
};
|
|
605
235
|
field["messages"] = [];
|
|
606
236
|
if (checkObjectKeyExists(field, "messages")) {
|
|
607
|
-
if (!
|
|
237
|
+
if (!hasDuplicateMessage(field["messages"], message)) {
|
|
608
238
|
field["messages"].push({
|
|
609
239
|
type: message.type,
|
|
610
240
|
message: message.message
|
|
@@ -616,13 +246,13 @@ const addMessage = (field, message) => {
|
|
|
616
246
|
}
|
|
617
247
|
return field;
|
|
618
248
|
};
|
|
619
|
-
const
|
|
249
|
+
const removeFormFieldMessage = (field, message) => {
|
|
620
250
|
field["messages"] = field["messages"].filter(function (fieldMessage) {
|
|
621
251
|
return fieldMessage.type !== message.type;
|
|
622
252
|
});
|
|
623
253
|
return field;
|
|
624
254
|
};
|
|
625
|
-
function
|
|
255
|
+
function showFormFieldError(fields, errors, key, error) {
|
|
626
256
|
const fieldIndex = fields.findIndex((field) => {
|
|
627
257
|
return field.key === key;
|
|
628
258
|
});
|
|
@@ -661,7 +291,7 @@ function setFieldError(fields, errors, key, error) {
|
|
|
661
291
|
return errorMessage;
|
|
662
292
|
};
|
|
663
293
|
Object.keys(errors).forEach((error) => {
|
|
664
|
-
field =
|
|
294
|
+
field = appendFormFieldMessage(field, {
|
|
665
295
|
type: "error",
|
|
666
296
|
message: getErrorMessage(field.label, error)
|
|
667
297
|
});
|
|
@@ -674,10 +304,10 @@ function setFieldError(fields, errors, key, error) {
|
|
|
674
304
|
else {
|
|
675
305
|
fields[fieldIndex]["messages"] = [];
|
|
676
306
|
}
|
|
677
|
-
fields[fieldIndex] =
|
|
307
|
+
fields[fieldIndex] = highlightFormFieldError(fields[fieldIndex], error);
|
|
678
308
|
return fields;
|
|
679
309
|
}
|
|
680
|
-
const
|
|
310
|
+
const convertFormFieldTypeDateToKwikUIFormat = (date) => {
|
|
681
311
|
const splitDate = date.split("-");
|
|
682
312
|
const tuiDay = new TuiDay(Number(splitDate[2]), // Year
|
|
683
313
|
Number(splitDate[1]) - 1, // Month, Why '-1' => Because Taiga-UI Required It, So...
|
|
@@ -685,7 +315,7 @@ const convertDateStringToTuiDayFormat = (date) => {
|
|
|
685
315
|
);
|
|
686
316
|
return tuiDay;
|
|
687
317
|
};
|
|
688
|
-
const
|
|
318
|
+
const convertFormFieldTypeDateToStandardFormat = (date) => {
|
|
689
319
|
let formattedDate;
|
|
690
320
|
let year = date.year;
|
|
691
321
|
let month = date.month;
|
|
@@ -695,12 +325,12 @@ const convertTuiDayFormatToDateString = (date) => {
|
|
|
695
325
|
.padStart(2, "0")}-${year}`;
|
|
696
326
|
return formattedDate;
|
|
697
327
|
};
|
|
698
|
-
const
|
|
328
|
+
const convertFormFieldValueToStandardFormat = (field, value) => {
|
|
699
329
|
let convertedValue = value;
|
|
700
330
|
if (isNotEmptyValue(value)) {
|
|
701
331
|
switch (field.type) {
|
|
702
332
|
case EFieldType.DATE:
|
|
703
|
-
convertedValue =
|
|
333
|
+
convertedValue = convertFormFieldTypeDateToStandardFormat(value);
|
|
704
334
|
break;
|
|
705
335
|
case EFieldType.RADIO:
|
|
706
336
|
convertedValue = value.label;
|
|
@@ -710,21 +340,21 @@ const convertValueFromKwikUIFormatToBasicFormat = (field, value) => {
|
|
|
710
340
|
}
|
|
711
341
|
return convertedValue;
|
|
712
342
|
};
|
|
713
|
-
const
|
|
343
|
+
const convertFormFieldValueToKwikUIFormat = (field, value) => {
|
|
714
344
|
let convertedValue = value;
|
|
715
345
|
if (isNotEmptyValue(value)) {
|
|
716
346
|
switch (field.type) {
|
|
717
347
|
case EFieldType.RADIO:
|
|
718
348
|
if (!checkObjectKeyExists(value, "label")) {
|
|
719
|
-
const
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
};
|
|
349
|
+
const radioField = field;
|
|
350
|
+
const convertedLabelValue = radioField.options.find((item) => {
|
|
351
|
+
return item.label === value;
|
|
352
|
+
});
|
|
723
353
|
convertedValue = convertedLabelValue;
|
|
724
354
|
}
|
|
725
355
|
break;
|
|
726
356
|
case EFieldType.DATE:
|
|
727
|
-
convertedValue =
|
|
357
|
+
convertedValue = convertFormFieldTypeDateToKwikUIFormat(value);
|
|
728
358
|
break;
|
|
729
359
|
case EFieldType.TITLE:
|
|
730
360
|
break;
|
|
@@ -732,42 +362,124 @@ const convertValueFromBasicFormatToKwikUIFormat = (field, value) => {
|
|
|
732
362
|
break;
|
|
733
363
|
}
|
|
734
364
|
}
|
|
365
|
+
else {
|
|
366
|
+
convertedValue = convertFormFieldEmptyValueToKwikUIFormat(field);
|
|
367
|
+
}
|
|
735
368
|
return convertedValue;
|
|
736
369
|
};
|
|
370
|
+
const convertFormFieldEmptyValueToKwikUIFormat = (field) => {
|
|
371
|
+
const fieldType = field.type;
|
|
372
|
+
let value;
|
|
373
|
+
switch (fieldType) {
|
|
374
|
+
case EFieldType.CHECKBOX:
|
|
375
|
+
value = false;
|
|
376
|
+
break;
|
|
377
|
+
case EFieldType.NUMBER:
|
|
378
|
+
value = null;
|
|
379
|
+
break;
|
|
380
|
+
case EFieldType.DATE:
|
|
381
|
+
value = null;
|
|
382
|
+
break;
|
|
383
|
+
default:
|
|
384
|
+
value = "";
|
|
385
|
+
break;
|
|
386
|
+
}
|
|
387
|
+
return value;
|
|
388
|
+
};
|
|
737
389
|
|
|
738
|
-
class
|
|
739
|
-
constructor(field, formData, previousFormData,
|
|
390
|
+
class Defaults {
|
|
391
|
+
constructor(field, formFields, allFormsData, formData, previousFormData, takeAction) {
|
|
740
392
|
this._field = field;
|
|
393
|
+
this._formFields = formFields;
|
|
394
|
+
this._allFormsData = allFormsData;
|
|
741
395
|
this._formData = formData;
|
|
742
396
|
this._previousFormData = previousFormData;
|
|
743
|
-
this._allFormsData = allFormsData;
|
|
744
397
|
this._takeAction = takeAction;
|
|
745
398
|
}
|
|
746
|
-
|
|
747
|
-
return this
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
399
|
+
getFormFieldValue() {
|
|
400
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
401
|
+
let defaultValue;
|
|
402
|
+
const sources = this._field.default.value.sources;
|
|
403
|
+
let sourceIndex = 0;
|
|
404
|
+
for (let source of sources) {
|
|
405
|
+
const sources = new Source({
|
|
406
|
+
FIELD_CONFIG: this._field,
|
|
407
|
+
FORM_FIELDS: this._formFields,
|
|
408
|
+
FORM_DATA: this._formData,
|
|
409
|
+
PREVIOUS_FORM_DATA: this._previousFormData,
|
|
410
|
+
ALL_FORMS_DATA: this._allFormsData
|
|
411
|
+
});
|
|
412
|
+
const value = sources.getValueFromSource(source);
|
|
413
|
+
// Set the Value of current source.
|
|
414
|
+
this._field = setValueToObjectPath(this._field, `default.value.sources.[${sourceIndex}].value`, value);
|
|
415
|
+
const validation = source.validation;
|
|
416
|
+
const triggers = validation.triggers;
|
|
417
|
+
const rules = validation.rules;
|
|
418
|
+
const actions = validation.actions;
|
|
419
|
+
const rulesMapping = new Rule(rules, {
|
|
420
|
+
FIELD_CONFIG: this._field,
|
|
421
|
+
FORM_FIELDS: this._formFields,
|
|
422
|
+
FORM_DATA: this._formData,
|
|
423
|
+
PREVIOUS_FORM_DATA: this._previousFormData,
|
|
424
|
+
ALL_FORMS_DATA: this._allFormsData
|
|
425
|
+
}).mapping();
|
|
426
|
+
for (let action of actions) {
|
|
427
|
+
const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
|
|
428
|
+
if (conditionEvaluation) {
|
|
429
|
+
const actions = new Action(action, rulesMapping, {
|
|
430
|
+
FIELD_CONFIG: this._field,
|
|
431
|
+
FORM_FIELDS: this._formFields,
|
|
432
|
+
FORM_DATA: this._formData,
|
|
433
|
+
PREVIOUS_FORM_DATA: this._previousFormData,
|
|
434
|
+
ALL_FORMS_DATA: this._allFormsData
|
|
435
|
+
}, this._takeAction);
|
|
436
|
+
yield actions.execute();
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
sourceIndex++;
|
|
440
|
+
}
|
|
441
|
+
defaultValue = this._field.default.value.value;
|
|
442
|
+
if (isEmptyValue(defaultValue)) {
|
|
443
|
+
defaultValue = convertFormFieldEmptyValueToKwikUIFormat(this._field);
|
|
444
|
+
}
|
|
445
|
+
return defaultValue;
|
|
446
|
+
});
|
|
766
447
|
}
|
|
767
|
-
|
|
768
|
-
this
|
|
448
|
+
getFormFieldOptions() {
|
|
449
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
450
|
+
const optionsConfig = this._field.default.options;
|
|
451
|
+
const rules = optionsConfig.rules;
|
|
452
|
+
const actions = optionsConfig.actions;
|
|
453
|
+
const rulesMapping = new Rule(rules, {
|
|
454
|
+
FIELD_CONFIG: this._field,
|
|
455
|
+
FORM_FIELDS: this._formFields,
|
|
456
|
+
FORM_DATA: this._formData,
|
|
457
|
+
PREVIOUS_FORM_DATA: this._previousFormData,
|
|
458
|
+
ALL_FORMS_DATA: this._allFormsData
|
|
459
|
+
}).mapping();
|
|
460
|
+
for (let action of actions) {
|
|
461
|
+
const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
|
|
462
|
+
if (conditionEvaluation) {
|
|
463
|
+
const actions = new Action(action, rulesMapping, {
|
|
464
|
+
FIELD_CONFIG: this._field,
|
|
465
|
+
FORM_FIELDS: this._formFields,
|
|
466
|
+
FORM_DATA: this._formData,
|
|
467
|
+
PREVIOUS_FORM_DATA: this._previousFormData,
|
|
468
|
+
ALL_FORMS_DATA: this._allFormsData
|
|
469
|
+
}, this._takeAction);
|
|
470
|
+
yield actions.execute();
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
});
|
|
769
474
|
}
|
|
770
|
-
|
|
475
|
+
}
|
|
476
|
+
__decorate([
|
|
477
|
+
logMethod
|
|
478
|
+
], Defaults.prototype, "getFormFieldValue", null);
|
|
479
|
+
|
|
480
|
+
class FormValidation {
|
|
481
|
+
constructor() { }
|
|
482
|
+
getFormFieldValidators(field) {
|
|
771
483
|
let validators = [];
|
|
772
484
|
if (checkObjectKeyExists(field, "validators") &&
|
|
773
485
|
checkObjectKeyExists(field.validators, "min") &&
|
|
@@ -799,20 +511,20 @@ class Validations {
|
|
|
799
511
|
checkObjectKeyExists(field.validators, "pattern") &&
|
|
800
512
|
isNotEmptyValue(field.validators.pattern)) {
|
|
801
513
|
if (checkObjectKeyExists(field.validators.pattern, "key")) {
|
|
802
|
-
if (field.validators.pattern.key ===
|
|
514
|
+
if (field.validators.pattern.key === "CUSTOM") {
|
|
803
515
|
validators.push(Validators.pattern(field.validators.pattern.pattern));
|
|
804
516
|
}
|
|
805
517
|
else {
|
|
806
|
-
validators.push(Validators.pattern(
|
|
518
|
+
validators.push(Validators.pattern(PATTERNS[field.validators.pattern.key]));
|
|
807
519
|
}
|
|
808
520
|
}
|
|
809
521
|
}
|
|
810
522
|
return validators;
|
|
811
523
|
}
|
|
812
|
-
|
|
524
|
+
getFormFieldsValidationErrors(formGroup) {
|
|
813
525
|
let errors = [];
|
|
814
|
-
for (const key in
|
|
815
|
-
const controlErrors =
|
|
526
|
+
for (const key in formGroup.controls) {
|
|
527
|
+
const controlErrors = formGroup.controls[key].errors;
|
|
816
528
|
if (controlErrors !== null && controlErrors !== undefined) {
|
|
817
529
|
Object.keys(controlErrors).forEach((keyError) => {
|
|
818
530
|
errors.push({
|
|
@@ -824,7 +536,7 @@ class Validations {
|
|
|
824
536
|
}
|
|
825
537
|
return errors;
|
|
826
538
|
}
|
|
827
|
-
|
|
539
|
+
getFormFieldsInvalidControls(formToInvestigate) {
|
|
828
540
|
var controls = [];
|
|
829
541
|
let recursiveFunc = (form) => {
|
|
830
542
|
Object.keys(form.controls).forEach((field) => {
|
|
@@ -852,45 +564,16 @@ class Validations {
|
|
|
852
564
|
recursiveFunc(formToInvestigate);
|
|
853
565
|
return controls;
|
|
854
566
|
}
|
|
855
|
-
validateField() {
|
|
856
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
857
|
-
const validations = this._field.validation;
|
|
858
|
-
const triggers = validations.triggers;
|
|
859
|
-
const rules = validations.rules;
|
|
860
|
-
const actions = validations.actions;
|
|
861
|
-
const rulesMapping = new Rules(rules, {
|
|
862
|
-
FIELD_CONFIG: this._field,
|
|
863
|
-
FORM_DATA: this._formData,
|
|
864
|
-
PREVIOUS_FORM_DATA: this._previousFormData,
|
|
865
|
-
ALL_FORMS_DATA: this._allFormsData
|
|
866
|
-
}).mapping();
|
|
867
|
-
for (let action of actions) {
|
|
868
|
-
const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
|
|
869
|
-
if (conditionEvaluation) {
|
|
870
|
-
const actions = new Actions(action, rulesMapping, {
|
|
871
|
-
FIELD_CONFIG: this._field,
|
|
872
|
-
FORM_DATA: this._formData,
|
|
873
|
-
PREVIOUS_FORM_DATA: this._previousFormData,
|
|
874
|
-
ALL_FORMS_DATA: this._allFormsData
|
|
875
|
-
}, this._takeAction);
|
|
876
|
-
yield actions.execute();
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
});
|
|
880
|
-
}
|
|
881
567
|
}
|
|
882
568
|
__decorate([
|
|
883
569
|
logMethod
|
|
884
|
-
],
|
|
885
|
-
__decorate([
|
|
886
|
-
logMethod
|
|
887
|
-
], Validations.prototype, "getFormValidationErrors", null);
|
|
570
|
+
], FormValidation.prototype, "getFormFieldValidators", null);
|
|
888
571
|
__decorate([
|
|
889
572
|
logMethod
|
|
890
|
-
],
|
|
573
|
+
], FormValidation.prototype, "getFormFieldsValidationErrors", null);
|
|
891
574
|
__decorate([
|
|
892
575
|
logMethod
|
|
893
|
-
],
|
|
576
|
+
], FormValidation.prototype, "getFormFieldsInvalidControls", null);
|
|
894
577
|
|
|
895
578
|
class KwikIDFormViewService {
|
|
896
579
|
constructor() { }
|
|
@@ -899,11 +582,11 @@ class KwikIDFormViewService {
|
|
|
899
582
|
return __awaiter(this, void 0, void 0, function* () {
|
|
900
583
|
let formGroup = new FormGroup({});
|
|
901
584
|
for (let field of fields) {
|
|
902
|
-
if (field.
|
|
903
|
-
const defaults = new Defaults(field, allFormsData, formData, previousFormData, takeAction);
|
|
904
|
-
let value = yield defaults.
|
|
905
|
-
value =
|
|
906
|
-
const validators = new
|
|
585
|
+
if (field.isFormElement) {
|
|
586
|
+
const defaults = new Defaults(field, fields, allFormsData, formData, previousFormData, takeAction);
|
|
587
|
+
let value = yield defaults.getFormFieldValue();
|
|
588
|
+
value = convertFormFieldValueToKwikUIFormat(field, value);
|
|
589
|
+
const validators = new FormValidation().getFormFieldValidators(field);
|
|
907
590
|
formGroup.addControl(field.key, new FormControl({ value: value, disabled: field.disabled }, { validators: validators }));
|
|
908
591
|
}
|
|
909
592
|
}
|
|
@@ -916,18 +599,21 @@ __decorate([
|
|
|
916
599
|
], KwikIDFormViewService.prototype, "createFormGroup", null);
|
|
917
600
|
|
|
918
601
|
class Apis {
|
|
919
|
-
constructor(
|
|
920
|
-
this.
|
|
921
|
-
this._formData = formData;
|
|
922
|
-
this._previousFormData = previousFormData;
|
|
923
|
-
this._allFormsData = allFormsData;
|
|
602
|
+
constructor(object, takeAction) {
|
|
603
|
+
this._object = object;
|
|
924
604
|
this._takeAction = takeAction;
|
|
925
|
-
this._api =
|
|
926
|
-
this._request =
|
|
927
|
-
this._response =
|
|
928
|
-
this._status =
|
|
605
|
+
this._api = this._object.FIELD_CONFIG.api;
|
|
606
|
+
this._request = this._object.FIELD_CONFIG.api.request;
|
|
607
|
+
this._response = this._object.FIELD_CONFIG.api.response;
|
|
608
|
+
this._status = this._object.FIELD_CONFIG.api.status;
|
|
929
609
|
}
|
|
930
|
-
|
|
610
|
+
get object() {
|
|
611
|
+
return this._object;
|
|
612
|
+
}
|
|
613
|
+
set object(value) {
|
|
614
|
+
this._object = value;
|
|
615
|
+
}
|
|
616
|
+
setRequestBody() {
|
|
931
617
|
var _a, _b, _c, _d;
|
|
932
618
|
return __awaiter(this, void 0, void 0, function* () {
|
|
933
619
|
let params = this._request.body.params;
|
|
@@ -936,34 +622,19 @@ class Apis {
|
|
|
936
622
|
let sources = param.sources;
|
|
937
623
|
let sourceIndex = 0;
|
|
938
624
|
for (let source of sources) {
|
|
939
|
-
const sources = new
|
|
940
|
-
FIELD_CONFIG: this._field,
|
|
941
|
-
FORM_DATA: this._formData,
|
|
942
|
-
PREVIOUS_FORM_DATA: this._previousFormData,
|
|
943
|
-
ALL_FORMS_DATA: this._allFormsData
|
|
944
|
-
});
|
|
625
|
+
const sources = new Source(this._object);
|
|
945
626
|
const value = sources.getValueFromSource(source);
|
|
946
627
|
// Set the Value of current source.
|
|
947
|
-
this.
|
|
628
|
+
this._object.FIELD_CONFIG = setValueToObjectPath(this._object.FIELD_CONFIG, `api.request.body.params[${paramIndex}].sources[${sourceIndex}].value`, value);
|
|
948
629
|
const validation = source.validation;
|
|
949
630
|
const triggers = (_a = validation === null || validation === void 0 ? void 0 : validation.triggers) !== null && _a !== void 0 ? _a : [];
|
|
950
631
|
const rules = (_b = validation === null || validation === void 0 ? void 0 : validation.rules) !== null && _b !== void 0 ? _b : [];
|
|
951
632
|
const actions = (_d = (_c = validation) === null || _c === void 0 ? void 0 : _c.actions) !== null && _d !== void 0 ? _d : [];
|
|
952
|
-
const rulesMapping = new
|
|
953
|
-
FIELD_CONFIG: this._field,
|
|
954
|
-
FORM_DATA: this._formData,
|
|
955
|
-
PREVIOUS_FORM_DATA: this._previousFormData,
|
|
956
|
-
ALL_FORMS_DATA: this._allFormsData
|
|
957
|
-
}).mapping();
|
|
633
|
+
const rulesMapping = new Rule(rules, this._object).mapping();
|
|
958
634
|
for (let action of actions) {
|
|
959
635
|
const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
|
|
960
636
|
if (conditionEvaluation) {
|
|
961
|
-
const actions = new
|
|
962
|
-
FIELD_CONFIG: this._field,
|
|
963
|
-
FORM_DATA: this._formData,
|
|
964
|
-
PREVIOUS_FORM_DATA: this._previousFormData,
|
|
965
|
-
ALL_FORMS_DATA: this._allFormsData
|
|
966
|
-
}, this._takeAction);
|
|
637
|
+
const actions = new Action(action, rulesMapping, this._object, this._takeAction);
|
|
967
638
|
yield actions.execute();
|
|
968
639
|
}
|
|
969
640
|
}
|
|
@@ -971,7 +642,7 @@ class Apis {
|
|
|
971
642
|
}
|
|
972
643
|
paramIndex++;
|
|
973
644
|
}
|
|
974
|
-
return this.
|
|
645
|
+
return this._object.FIELD_CONFIG;
|
|
975
646
|
});
|
|
976
647
|
}
|
|
977
648
|
validateRequestBody() {
|
|
@@ -982,72 +653,66 @@ class Apis {
|
|
|
982
653
|
const triggers = validation.triggers;
|
|
983
654
|
const rules = validation.rules;
|
|
984
655
|
const actions = (_a = validation) === null || _a === void 0 ? void 0 : _a.actions;
|
|
985
|
-
const rulesMapping = new
|
|
986
|
-
FIELD_CONFIG: this._field,
|
|
987
|
-
FORM_DATA: this._formData,
|
|
988
|
-
PREVIOUS_FORM_DATA: this._previousFormData,
|
|
989
|
-
ALL_FORMS_DATA: this._allFormsData
|
|
990
|
-
}).mapping();
|
|
656
|
+
const rulesMapping = new Rule(rules, this._object).mapping();
|
|
991
657
|
for (let action of actions) {
|
|
992
658
|
const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
|
|
993
659
|
if (conditionSuccess) {
|
|
994
|
-
const actions = new
|
|
995
|
-
FIELD_CONFIG: this._field,
|
|
996
|
-
FORM_DATA: this._formData,
|
|
997
|
-
PREVIOUS_FORM_DATA: this._previousFormData,
|
|
998
|
-
ALL_FORMS_DATA: this._allFormsData
|
|
999
|
-
}, this._takeAction);
|
|
660
|
+
const actions = new Action(action, rulesMapping, this._object, this._takeAction);
|
|
1000
661
|
yield actions.execute();
|
|
1001
662
|
}
|
|
1002
663
|
}
|
|
1003
|
-
return this.
|
|
664
|
+
return this._object.FIELD_CONFIG;
|
|
1004
665
|
});
|
|
1005
666
|
}
|
|
1006
|
-
|
|
667
|
+
validateResponse() {
|
|
1007
668
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1008
669
|
const validation = this._response.validation;
|
|
1009
670
|
const triggers = validation.triggers;
|
|
1010
671
|
const rules = validation.rules;
|
|
1011
672
|
const actions = validation.actions;
|
|
1012
|
-
const rulesMapping = new
|
|
1013
|
-
FIELD_CONFIG: this._field,
|
|
1014
|
-
FORM_DATA: this._formData,
|
|
1015
|
-
PREVIOUS_FORM_DATA: this._previousFormData,
|
|
1016
|
-
ALL_FORMS_DATA: this._allFormsData
|
|
1017
|
-
}).mapping();
|
|
673
|
+
const rulesMapping = new Rule(rules, this._object).mapping();
|
|
1018
674
|
for (let action of actions) {
|
|
1019
675
|
const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
|
|
1020
676
|
if (conditionSuccess) {
|
|
1021
|
-
const actions = new
|
|
1022
|
-
FIELD_CONFIG: this._field,
|
|
1023
|
-
FORM_DATA: this._formData,
|
|
1024
|
-
PREVIOUS_FORM_DATA: this._previousFormData,
|
|
1025
|
-
ALL_FORMS_DATA: this._allFormsData
|
|
1026
|
-
}, this._takeAction);
|
|
677
|
+
const actions = new Action(action, rulesMapping, this._object, this._takeAction);
|
|
1027
678
|
yield actions.execute();
|
|
1028
679
|
}
|
|
1029
680
|
}
|
|
1030
|
-
return this.
|
|
681
|
+
return this._object.FIELD_CONFIG;
|
|
1031
682
|
});
|
|
1032
683
|
}
|
|
1033
|
-
getPropsValues() {
|
|
1034
|
-
return {
|
|
1035
|
-
field: this._field,
|
|
1036
|
-
formData: this._formData,
|
|
1037
|
-
previousFormData: this._previousFormData,
|
|
1038
|
-
allFormsData: this._allFormsData
|
|
1039
|
-
};
|
|
1040
|
-
}
|
|
1041
684
|
}
|
|
1042
685
|
__decorate([
|
|
1043
686
|
logMethod
|
|
1044
|
-
], Apis.prototype, "
|
|
687
|
+
], Apis.prototype, "setRequestBody", null);
|
|
1045
688
|
__decorate([
|
|
1046
689
|
logMethod
|
|
1047
690
|
], Apis.prototype, "validateRequestBody", null);
|
|
1048
691
|
__decorate([
|
|
1049
692
|
logMethod
|
|
1050
|
-
], Apis.prototype, "
|
|
693
|
+
], Apis.prototype, "validateResponse", null);
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* Generated class for the SafeHtmlPipe pipe.
|
|
697
|
+
*
|
|
698
|
+
* See https://angular.io/api/core/Pipe for more info on Angular Pipes.
|
|
699
|
+
*/
|
|
700
|
+
class SafeHtmlPipe {
|
|
701
|
+
constructor(sanitizer) {
|
|
702
|
+
this.sanitizer = sanitizer;
|
|
703
|
+
}
|
|
704
|
+
transform(html) {
|
|
705
|
+
return this.sanitizer.bypassSecurityTrustHtml(html);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
/** @nocollapse */ SafeHtmlPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SafeHtmlPipe, deps: [{ token: i1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
|
|
709
|
+
/** @nocollapse */ SafeHtmlPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SafeHtmlPipe, name: "safeHtml" });
|
|
710
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SafeHtmlPipe, decorators: [{
|
|
711
|
+
type: Pipe,
|
|
712
|
+
args: [{
|
|
713
|
+
name: "safeHtml"
|
|
714
|
+
}]
|
|
715
|
+
}], ctorParameters: function () { return [{ type: i1.DomSanitizer }]; } });
|
|
1051
716
|
|
|
1052
717
|
class KwikIDFormViewComponent {
|
|
1053
718
|
constructor(push, alert, formViewService) {
|
|
@@ -1095,10 +760,16 @@ class KwikIDFormViewComponent {
|
|
|
1095
760
|
this.formGroup.patchValue({
|
|
1096
761
|
[this.apiCallResponse.key]: this.apiCallResponse.response
|
|
1097
762
|
}, { emitEvent: false });
|
|
1098
|
-
let field =
|
|
1099
|
-
const apis = new Apis(
|
|
763
|
+
let field = getFormFieldByKey(this.formFields, this.apiCallResponse.key);
|
|
764
|
+
const apis = new Apis({
|
|
765
|
+
FIELD_CONFIG: field,
|
|
766
|
+
FORM_FIELDS: this.formFields,
|
|
767
|
+
FORM_DATA: this.formData,
|
|
768
|
+
PREVIOUS_FORM_DATA: this.previousFormData,
|
|
769
|
+
ALL_FORMS_DATA: this.allFormsData
|
|
770
|
+
}, this.takeAction.bind(this));
|
|
1100
771
|
(() => __awaiter(this, void 0, void 0, function* () {
|
|
1101
|
-
field = yield apis.
|
|
772
|
+
field = yield apis.validateResponse();
|
|
1102
773
|
}))();
|
|
1103
774
|
}
|
|
1104
775
|
if (verifyChange("isMobileView")) {
|
|
@@ -1124,24 +795,44 @@ class KwikIDFormViewComponent {
|
|
|
1124
795
|
this.setFormDataFromAllFormsData();
|
|
1125
796
|
this.formGroup = yield this.formViewService.createFormGroup(this.formFields, this.formData, this.previousFormData, this.allFormsData, this.takeAction.bind(this));
|
|
1126
797
|
for (let field of this.formFields) {
|
|
1127
|
-
if (field.
|
|
1128
|
-
this.previousFormData = Object.assign(Object.assign({}, this.previousFormData), { [field.key]: this.formGroup.controls[field.key].value });
|
|
798
|
+
if (field.isFormElement) {
|
|
799
|
+
this.previousFormData = Object.assign(Object.assign({}, this.previousFormData), { [field.key]: convertFormFieldValueToStandardFormat(field, this.formGroup.controls[field.key].value) });
|
|
1129
800
|
this.formGroup.controls[field.key].valueChanges
|
|
1130
801
|
.pipe(pairwise())
|
|
1131
802
|
.subscribe(([previousValue, currentValue]) => {
|
|
1132
|
-
this.previousFormData = Object.assign(Object.assign({}, this.previousFormData), { [field.key]: previousValue });
|
|
1133
|
-
this.formData = Object.assign(Object.assign({}, this.formData), { [field.key]: currentValue });
|
|
803
|
+
this.previousFormData = Object.assign(Object.assign({}, this.previousFormData), { [field.key]: convertFormFieldValueToStandardFormat(field, previousValue) });
|
|
804
|
+
this.formData = Object.assign(Object.assign({}, this.formData), { [field.key]: convertFormFieldValueToStandardFormat(field, currentValue) });
|
|
1134
805
|
});
|
|
1135
806
|
}
|
|
1136
807
|
}
|
|
1137
808
|
for (let field of this.formFields) {
|
|
1138
|
-
if (field.
|
|
1139
|
-
|
|
1140
|
-
|
|
809
|
+
if (field.isFormElement) {
|
|
810
|
+
if (field.validation.triggers.includes("ON_INIT")) {
|
|
811
|
+
const validations = new Validation({
|
|
812
|
+
FIELD_CONFIG: field,
|
|
813
|
+
FORM_FIELDS: this.formFields,
|
|
814
|
+
FORM_DATA: this.formData,
|
|
815
|
+
PREVIOUS_FORM_DATA: this.previousFormData,
|
|
816
|
+
ALL_FORMS_DATA: this.allFormsData
|
|
817
|
+
}, this.takeAction.bind(this));
|
|
818
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
|
819
|
+
yield validations.validate(field.validation);
|
|
820
|
+
}))();
|
|
821
|
+
}
|
|
822
|
+
if (checkObjectKeyExists(field, "connectedElements")) {
|
|
823
|
+
this.handleConnectedElements({
|
|
1141
824
|
key: field.key,
|
|
1142
825
|
value: this.formGroup.controls[field.key].value
|
|
1143
826
|
}, "ON_INIT");
|
|
1144
|
-
}
|
|
827
|
+
}
|
|
828
|
+
if (checkObjectKeyExists(field, "default")) {
|
|
829
|
+
if (checkObjectKeyExists(field.default, "options")) {
|
|
830
|
+
if (field.default.options.triggers.includes("ON_INIT")) {
|
|
831
|
+
const defaults = new Defaults(field, this.formFields, this.allFormsData, this.formData, this.previousFormData, this.takeAction);
|
|
832
|
+
yield defaults.getFormFieldOptions();
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
}
|
|
1145
836
|
}
|
|
1146
837
|
}
|
|
1147
838
|
});
|
|
@@ -1169,7 +860,7 @@ class KwikIDFormViewComponent {
|
|
|
1169
860
|
handleConnectedElementFieldGroupActions(childFieldGroupConfig, parentField) {
|
|
1170
861
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1171
862
|
if (checkObjectKeyExists(childFieldGroupConfig, "rules")) {
|
|
1172
|
-
const rulesMapping = new
|
|
863
|
+
const rulesMapping = new Rule(childFieldGroupConfig.rules, {
|
|
1173
864
|
FIELD_CONFIG: parentField,
|
|
1174
865
|
FORM_DATA: this.formData,
|
|
1175
866
|
PREVIOUS_FORM_DATA: this.previousFormData,
|
|
@@ -1178,8 +869,9 @@ class KwikIDFormViewComponent {
|
|
|
1178
869
|
for (let action of childFieldGroupConfig.actions) {
|
|
1179
870
|
const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
|
|
1180
871
|
if (conditionSuccess) {
|
|
1181
|
-
const actions = new
|
|
872
|
+
const actions = new Action(action, rulesMapping, {
|
|
1182
873
|
FIELD_CONFIG: parentField,
|
|
874
|
+
FORM_FIELDS: this.formFields,
|
|
1183
875
|
FORM_DATA: this.formData,
|
|
1184
876
|
PREVIOUS_FORM_DATA: this.previousFormData,
|
|
1185
877
|
ALL_FORMS_DATA: this.allFormsData
|
|
@@ -1192,36 +884,17 @@ class KwikIDFormViewComponent {
|
|
|
1192
884
|
}
|
|
1193
885
|
handleConnectedElementFieldGroup(currentField, connectedFieldGroupConfig, eventType) {
|
|
1194
886
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
yield this.handleConnectedElementFieldGroupActions(connectedFieldGroupConfig, currentField);
|
|
1200
|
-
}
|
|
1201
|
-
break;
|
|
1202
|
-
case "VALUE_CHANGE":
|
|
1203
|
-
if (checkObjectKeyExists(connectedFieldGroupConfig, "triggers") &&
|
|
1204
|
-
connectedFieldGroupConfig.triggers.includes("VALUE_CHANGE")) {
|
|
1205
|
-
yield this.handleConnectedElementFieldGroupActions(connectedFieldGroupConfig, currentField);
|
|
1206
|
-
}
|
|
1207
|
-
break;
|
|
1208
|
-
case "NESTED_LINK":
|
|
1209
|
-
if (checkObjectKeyExists(connectedFieldGroupConfig, "triggers") &&
|
|
1210
|
-
connectedFieldGroupConfig.triggers.includes("NESTED_LINK")) {
|
|
1211
|
-
yield this.handleConnectedElementFieldGroupActions(connectedFieldGroupConfig, currentField);
|
|
1212
|
-
}
|
|
1213
|
-
default:
|
|
1214
|
-
if (checkObjectKeyExists(connectedFieldGroupConfig, "triggers")) {
|
|
1215
|
-
yield this.handleConnectedElementFieldGroupActions(connectedFieldGroupConfig, currentField);
|
|
1216
|
-
}
|
|
1217
|
-
break;
|
|
887
|
+
if (checkObjectKeyExists(connectedFieldGroupConfig, "triggers")) {
|
|
888
|
+
if (connectedFieldGroupConfig.triggers.includes(eventType)) {
|
|
889
|
+
yield this.handleConnectedElementFieldGroupActions(connectedFieldGroupConfig, currentField);
|
|
890
|
+
}
|
|
1218
891
|
}
|
|
1219
892
|
});
|
|
1220
893
|
}
|
|
1221
894
|
handleConnectedElementFieldActions(connectedFieldConfig, connectedField) {
|
|
1222
895
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1223
896
|
if (checkObjectKeyExists(connectedFieldConfig, "rules")) {
|
|
1224
|
-
const rulesMapping = new
|
|
897
|
+
const rulesMapping = new Rule(connectedFieldConfig.rules, {
|
|
1225
898
|
FIELD_CONFIG: connectedField,
|
|
1226
899
|
FORM_DATA: this.formData,
|
|
1227
900
|
PREVIOUS_FORM_DATA: this.previousFormData,
|
|
@@ -1230,7 +903,8 @@ class KwikIDFormViewComponent {
|
|
|
1230
903
|
for (let action of connectedFieldConfig.actions) {
|
|
1231
904
|
const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
|
|
1232
905
|
if (conditionSuccess) {
|
|
1233
|
-
const actions = new
|
|
906
|
+
const actions = new Action(action, rulesMapping, {
|
|
907
|
+
FORM_FIELDS: this.formFields,
|
|
1234
908
|
FIELD_CONFIG: connectedField,
|
|
1235
909
|
FORM_DATA: this.formData,
|
|
1236
910
|
PREVIOUS_FORM_DATA: this.previousFormData,
|
|
@@ -1243,65 +917,23 @@ class KwikIDFormViewComponent {
|
|
|
1243
917
|
return connectedField;
|
|
1244
918
|
});
|
|
1245
919
|
}
|
|
1246
|
-
handleConnectedElementFields(currentField, connectedFieldConfig, eventType) {
|
|
920
|
+
handleConnectedElementFields(currentField, connectedFieldConfig, eventType, nested) {
|
|
1247
921
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1248
|
-
let connectedField =
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
connectedField.triggers.includes("INIT")) {
|
|
1253
|
-
if (this.isFieldEnabled(connectedField.key)) {
|
|
1254
|
-
if (checkObjectKeyExists(connectedFieldConfig, "connectedParentFields")) {
|
|
1255
|
-
switch (connectedFieldConfig.type) {
|
|
1256
|
-
case "dropdown-with-search":
|
|
1257
|
-
connectedField = yield this.handleFieldTypeSearchText(currentField, connectedField);
|
|
1258
|
-
break;
|
|
1259
|
-
default:
|
|
1260
|
-
break;
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
connectedField = yield this.handleConnectedElementFieldActions(connectedFieldConfig, connectedField);
|
|
1265
|
-
}
|
|
1266
|
-
break;
|
|
1267
|
-
case "VALUE_CHANGE":
|
|
1268
|
-
if (checkObjectKeyExists(connectedFieldConfig, "triggers") &&
|
|
1269
|
-
connectedFieldConfig.triggers.includes("VALUE_CHANGE")) {
|
|
1270
|
-
switch (connectedField.type) {
|
|
1271
|
-
case "dropdown-with-search":
|
|
1272
|
-
connectedField = yield this.handleFieldTypeSearchText(currentField, connectedField);
|
|
1273
|
-
break;
|
|
1274
|
-
default:
|
|
1275
|
-
break;
|
|
1276
|
-
}
|
|
1277
|
-
connectedField = yield this.handleConnectedElementFieldActions(connectedFieldConfig, connectedField);
|
|
1278
|
-
}
|
|
1279
|
-
break;
|
|
1280
|
-
case "NESTED_LINK":
|
|
1281
|
-
if (checkObjectKeyExists(connectedFieldConfig, "triggers") &&
|
|
1282
|
-
connectedFieldConfig.triggers.includes("NESTED_LINK")) {
|
|
1283
|
-
connectedField = yield this.handleConnectedElementFieldActions(connectedFieldConfig, connectedField);
|
|
1284
|
-
}
|
|
1285
|
-
default:
|
|
1286
|
-
if (checkObjectKeyExists(connectedFieldConfig, "triggers")) {
|
|
1287
|
-
connectedField = yield this.handleConnectedElementFieldActions(connectedFieldConfig, connectedField);
|
|
1288
|
-
}
|
|
1289
|
-
break;
|
|
1290
|
-
}
|
|
1291
|
-
if (checkObjectKeyExists(connectedField, "connectedElements")) {
|
|
1292
|
-
if (checkObjectKeyExists(connectedField.connectedElements, "connectedFields")) {
|
|
1293
|
-
for (const connectedFieldConfig of connectedField.connectedElements
|
|
1294
|
-
.connectedFields) {
|
|
1295
|
-
connectedField = this.handleConnectedElementFields(connectedField, connectedFieldConfig, "NESTED_LINK");
|
|
1296
|
-
}
|
|
922
|
+
let connectedField = getFormFieldByKey(this.formFields, connectedFieldConfig["key"]);
|
|
923
|
+
if (checkObjectKeyExists(connectedFieldConfig, "triggers")) {
|
|
924
|
+
if (connectedFieldConfig.triggers.includes(eventType)) {
|
|
925
|
+
connectedField = yield this.handleConnectedElementFieldActions(connectedFieldConfig, connectedField);
|
|
1297
926
|
}
|
|
1298
927
|
}
|
|
928
|
+
if (checkObjectKeyExists(connectedFieldConfig, "handleNestedFields")) {
|
|
929
|
+
this.handleConnectedElements({ key: connectedFieldConfig.key }, eventType);
|
|
930
|
+
}
|
|
1299
931
|
return currentField;
|
|
1300
932
|
});
|
|
1301
933
|
}
|
|
1302
934
|
handleConnectedElements(e, eventType) {
|
|
1303
935
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1304
|
-
let currentField =
|
|
936
|
+
let currentField = getFormFieldByKey(this.formFields, e.key);
|
|
1305
937
|
if (currentField !== undefined) {
|
|
1306
938
|
if (checkObjectKeyExists(currentField, "connectedElements")) {
|
|
1307
939
|
if (checkObjectKeyExists(currentField.connectedElements, "connectedFieldGroups")) {
|
|
@@ -1313,7 +945,7 @@ class KwikIDFormViewComponent {
|
|
|
1313
945
|
if (checkObjectKeyExists(currentField.connectedElements, "connectedFields")) {
|
|
1314
946
|
let connectedFields = currentField.connectedElements.connectedFields;
|
|
1315
947
|
for (let connectedFieldConfig of connectedFields) {
|
|
1316
|
-
currentField = yield this.handleConnectedElementFields(currentField, connectedFieldConfig, eventType);
|
|
948
|
+
currentField = yield this.handleConnectedElementFields(currentField, connectedFieldConfig, eventType, eventType);
|
|
1317
949
|
}
|
|
1318
950
|
}
|
|
1319
951
|
}
|
|
@@ -1328,14 +960,23 @@ class KwikIDFormViewComponent {
|
|
|
1328
960
|
this.formGroup.patchValue({
|
|
1329
961
|
[e.key]: e.value
|
|
1330
962
|
}, { emitEvent: false });
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
if (field.
|
|
963
|
+
const field = getFormFieldByKey(this.formFields, e.key);
|
|
964
|
+
this.formData[e.key] = convertFormFieldValueToStandardFormat(field, e.value);
|
|
965
|
+
if (field.isFormElement &&
|
|
1334
966
|
field.validation.triggers.includes("ON_CHANGE")) {
|
|
1335
|
-
const validations = new
|
|
967
|
+
const validations = new Validation({
|
|
968
|
+
FIELD_CONFIG: field,
|
|
969
|
+
FORM_FIELDS: this.formFields,
|
|
970
|
+
FORM_DATA: this.formData,
|
|
971
|
+
PREVIOUS_FORM_DATA: this.previousFormData,
|
|
972
|
+
ALL_FORMS_DATA: this.allFormsData
|
|
973
|
+
}, this.takeAction.bind(this));
|
|
1336
974
|
(() => __awaiter(this, void 0, void 0, function* () {
|
|
1337
|
-
yield validations.
|
|
975
|
+
yield validations.validate(field.validation);
|
|
1338
976
|
}))();
|
|
977
|
+
}
|
|
978
|
+
if (field.isFormElement &&
|
|
979
|
+
checkObjectKeyExists(field, "connectedElements")) {
|
|
1339
980
|
this.handleConnectedElements({
|
|
1340
981
|
key: field.key,
|
|
1341
982
|
value: this.formGroup.controls[field.key].value
|
|
@@ -1346,9 +987,10 @@ class KwikIDFormViewComponent {
|
|
|
1346
987
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1347
988
|
for (let f of field.reset.fields) {
|
|
1348
989
|
for (let action of f.actions) {
|
|
1349
|
-
const resetField =
|
|
1350
|
-
const actions = new
|
|
990
|
+
const resetField = getFormFieldByKey(this.formFields, action.props.fieldKey);
|
|
991
|
+
const actions = new Action(action, {}, {
|
|
1351
992
|
FIELD_CONFIG: resetField,
|
|
993
|
+
FORM_FIELDS: this.formFields,
|
|
1352
994
|
FORM_DATA: this.formData,
|
|
1353
995
|
PREVIOUS_FORM_DATA: this.previousFormData,
|
|
1354
996
|
ALL_FORMS_DATA: this.allFormsData
|
|
@@ -1360,7 +1002,7 @@ class KwikIDFormViewComponent {
|
|
|
1360
1002
|
}
|
|
1361
1003
|
handleOnClickApiCall(e) {
|
|
1362
1004
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1363
|
-
let field =
|
|
1005
|
+
let field = getFormFieldByKey(this.formFields, e.key);
|
|
1364
1006
|
if (field.type === "api-call") {
|
|
1365
1007
|
// set button status to loading
|
|
1366
1008
|
field["api"]["status"]["value"] = EApiStatusType.LOADING;
|
|
@@ -1369,8 +1011,14 @@ class KwikIDFormViewComponent {
|
|
|
1369
1011
|
this.viewFormsButton["showLoader"] = true;
|
|
1370
1012
|
this.saveFormButton["disabled"] = true;
|
|
1371
1013
|
this.saveFormButton["showLoader"] = true;
|
|
1372
|
-
const apis = new Apis(
|
|
1373
|
-
|
|
1014
|
+
const apis = new Apis({
|
|
1015
|
+
FIELD_CONFIG: field,
|
|
1016
|
+
FORM_FIELDS: this.formFields,
|
|
1017
|
+
FORM_DATA: this.formData,
|
|
1018
|
+
PREVIOUS_FORM_DATA: this.previousFormData,
|
|
1019
|
+
ALL_FORMS_DATA: this.allFormsData
|
|
1020
|
+
}, this.takeAction.bind(this));
|
|
1021
|
+
field = yield apis.setRequestBody();
|
|
1374
1022
|
field = yield apis.validateRequestBody();
|
|
1375
1023
|
if (field.api.request.body.validation.is_valid) {
|
|
1376
1024
|
// Call API Here
|
|
@@ -1387,7 +1035,7 @@ class KwikIDFormViewComponent {
|
|
|
1387
1035
|
else {
|
|
1388
1036
|
// Request Body Validation Failed
|
|
1389
1037
|
// Highlight Error in UI to User to Retry After Sometime.
|
|
1390
|
-
// Take
|
|
1038
|
+
// Take Action based on Validation
|
|
1391
1039
|
setTimeout(() => {
|
|
1392
1040
|
field["api"]["status"]["value"] = EApiStatusType.FAILED;
|
|
1393
1041
|
field["showLoader"] = false;
|
|
@@ -1408,32 +1056,38 @@ class KwikIDFormViewComponent {
|
|
|
1408
1056
|
handleOnClickSaveForm(e) {
|
|
1409
1057
|
let formData = this.formGroup.getRawValue();
|
|
1410
1058
|
for (let field of this.formFields) {
|
|
1411
|
-
if (field.
|
|
1059
|
+
if (field.isFormElement) {
|
|
1412
1060
|
if (field.hidden) {
|
|
1413
1061
|
delete formData[field.key];
|
|
1414
1062
|
}
|
|
1415
1063
|
else {
|
|
1416
|
-
formData[field.key] =
|
|
1064
|
+
formData[field.key] = convertFormFieldValueToStandardFormat(field, formData[field.key]);
|
|
1417
1065
|
}
|
|
1418
1066
|
}
|
|
1419
1067
|
}
|
|
1420
1068
|
for (let field of this.formFields) {
|
|
1421
|
-
if (field.
|
|
1069
|
+
if (field.isFormElement &&
|
|
1422
1070
|
field.validation.triggers.includes("ON_SAVE")) {
|
|
1423
|
-
const validations = new
|
|
1071
|
+
const validations = new Validation({
|
|
1072
|
+
FIELD_CONFIG: field,
|
|
1073
|
+
FORM_FIELDS: this.formFields,
|
|
1074
|
+
FORM_DATA: this.formData,
|
|
1075
|
+
PREVIOUS_FORM_DATA: this.previousFormData,
|
|
1076
|
+
ALL_FORMS_DATA: this.allFormsData
|
|
1077
|
+
}, this.takeAction.bind(this));
|
|
1424
1078
|
(() => __awaiter(this, void 0, void 0, function* () {
|
|
1425
|
-
yield validations.
|
|
1079
|
+
yield validations.validate(field.validation);
|
|
1426
1080
|
}))();
|
|
1427
1081
|
}
|
|
1428
1082
|
}
|
|
1429
1083
|
if (this.formGroup.invalid) {
|
|
1430
|
-
const controls = new
|
|
1084
|
+
const controls = new FormValidation().getFormFieldsInvalidControls(this.formGroup);
|
|
1431
1085
|
let firstFieldWithError = "";
|
|
1432
1086
|
for (let control of controls) {
|
|
1433
1087
|
if (control.invalid && isEmptyValue(firstFieldWithError)) {
|
|
1434
1088
|
firstFieldWithError = control.key;
|
|
1435
1089
|
}
|
|
1436
|
-
this.formFields =
|
|
1090
|
+
this.formFields = showFormFieldError(this.formFields, this.formGroup.controls[control.key].errors, control.key, control.invalid);
|
|
1437
1091
|
}
|
|
1438
1092
|
this.toggleErrorNotification(true);
|
|
1439
1093
|
setTimeout(() => {
|
|
@@ -1453,7 +1107,7 @@ class KwikIDFormViewComponent {
|
|
|
1453
1107
|
}
|
|
1454
1108
|
// Component Helpers
|
|
1455
1109
|
fieldHide(fieldKey) {
|
|
1456
|
-
let field =
|
|
1110
|
+
let field = getFormFieldByKey(this.formFields, fieldKey);
|
|
1457
1111
|
let fieldIndex = this.formFields.findIndex((_) => {
|
|
1458
1112
|
return field.key === _.key;
|
|
1459
1113
|
});
|
|
@@ -1466,7 +1120,7 @@ class KwikIDFormViewComponent {
|
|
|
1466
1120
|
}
|
|
1467
1121
|
}
|
|
1468
1122
|
fieldShow(fieldKey) {
|
|
1469
|
-
let field =
|
|
1123
|
+
let field = getFormFieldByKey(this.formFields, fieldKey);
|
|
1470
1124
|
let fieldIndex = this.formFields.findIndex((_) => {
|
|
1471
1125
|
return field.key === _.key;
|
|
1472
1126
|
});
|
|
@@ -1479,11 +1133,11 @@ class KwikIDFormViewComponent {
|
|
|
1479
1133
|
}
|
|
1480
1134
|
}
|
|
1481
1135
|
fieldDisable(fieldKey) {
|
|
1482
|
-
let field =
|
|
1136
|
+
let field = getFormFieldByKey(this.formFields, fieldKey);
|
|
1483
1137
|
let fieldIndex = this.formFields.findIndex((_) => {
|
|
1484
1138
|
return field.key === _.key;
|
|
1485
1139
|
});
|
|
1486
|
-
if (field.
|
|
1140
|
+
if (field.isFormElement) {
|
|
1487
1141
|
this.formFields[fieldIndex]["disabled"] = true;
|
|
1488
1142
|
if (isNotEmptyValue(this.formGroup.controls)) {
|
|
1489
1143
|
this.formGroup.controls[field.key].disable({
|
|
@@ -1499,11 +1153,11 @@ class KwikIDFormViewComponent {
|
|
|
1499
1153
|
}
|
|
1500
1154
|
}
|
|
1501
1155
|
fieldEnable(fieldKey) {
|
|
1502
|
-
let field =
|
|
1156
|
+
let field = getFormFieldByKey(this.formFields, fieldKey);
|
|
1503
1157
|
let fieldIndex = this.formFields.findIndex((_) => {
|
|
1504
1158
|
return field.key === _.key;
|
|
1505
1159
|
});
|
|
1506
|
-
if (field.
|
|
1160
|
+
if (field.isFormElement) {
|
|
1507
1161
|
this.formFields[fieldIndex]["disabled"] = false;
|
|
1508
1162
|
if (isNotEmptyValue(this.formGroup.controls)) {
|
|
1509
1163
|
this.formGroup.controls[field.key].enable({
|
|
@@ -1520,20 +1174,20 @@ class KwikIDFormViewComponent {
|
|
|
1520
1174
|
}
|
|
1521
1175
|
fieldReset(fieldKey) {
|
|
1522
1176
|
// Find the field and its index in the formFields array
|
|
1523
|
-
let field =
|
|
1524
|
-
let fieldIndex =
|
|
1177
|
+
let field = getFormFieldByKey(this.formFields, fieldKey);
|
|
1178
|
+
let fieldIndex = getFormFieldIndexByKey(this.formFields, fieldKey);
|
|
1525
1179
|
// Delete the field from the formData object
|
|
1526
1180
|
delete this.formData[fieldKey];
|
|
1527
1181
|
// Reset the value of the field in the formGroup
|
|
1528
|
-
this.formGroup.controls[field.key].reset(
|
|
1182
|
+
this.formGroup.controls[field.key].reset(convertFormFieldEmptyValueToKwikUIFormat(field), {
|
|
1529
1183
|
emitEvent: false
|
|
1530
1184
|
});
|
|
1531
1185
|
// Reset the messages and errors for the field
|
|
1532
|
-
field =
|
|
1186
|
+
field = removeFormFieldMessage(field, {
|
|
1533
1187
|
type: EMessageType.WARNING,
|
|
1534
1188
|
message: ""
|
|
1535
1189
|
});
|
|
1536
|
-
field =
|
|
1190
|
+
field = removeFormFieldMessage(field, {
|
|
1537
1191
|
type: EMessageType.SUCCESS,
|
|
1538
1192
|
message: ""
|
|
1539
1193
|
});
|
|
@@ -1556,37 +1210,37 @@ class KwikIDFormViewComponent {
|
|
|
1556
1210
|
}
|
|
1557
1211
|
}
|
|
1558
1212
|
fieldErrorShow(fieldKey, message) {
|
|
1559
|
-
let field =
|
|
1213
|
+
let field = getFormFieldByKey(this.formFields, fieldKey);
|
|
1560
1214
|
let fieldIndex = this.formFields.findIndex((_) => {
|
|
1561
1215
|
return field.key === _.key;
|
|
1562
1216
|
});
|
|
1563
|
-
field =
|
|
1564
|
-
field =
|
|
1217
|
+
field = highlightFormFieldError(field, true);
|
|
1218
|
+
field = appendFormFieldMessage(field, message);
|
|
1565
1219
|
this.formFields[fieldIndex] = field;
|
|
1566
1220
|
}
|
|
1567
1221
|
fieldErrorHide(fieldKey, message) {
|
|
1568
|
-
let field =
|
|
1222
|
+
let field = getFormFieldByKey(this.formFields, fieldKey);
|
|
1569
1223
|
let fieldIndex = this.formFields.findIndex((_) => {
|
|
1570
1224
|
return field.key === _.key;
|
|
1571
1225
|
});
|
|
1572
|
-
field =
|
|
1573
|
-
field =
|
|
1226
|
+
field = highlightFormFieldError(field, false);
|
|
1227
|
+
field = removeFormFieldMessage(field, message);
|
|
1574
1228
|
this.formFields[fieldIndex] = field;
|
|
1575
1229
|
}
|
|
1576
1230
|
fieldMessageShow(fieldKey, message) {
|
|
1577
|
-
let field =
|
|
1231
|
+
let field = getFormFieldByKey(this.formFields, fieldKey);
|
|
1578
1232
|
let fieldIndex = this.formFields.findIndex((_) => {
|
|
1579
1233
|
return field.key === _.key;
|
|
1580
1234
|
});
|
|
1581
|
-
field =
|
|
1235
|
+
field = appendFormFieldMessage(field, message);
|
|
1582
1236
|
this.formFields[fieldIndex] = field;
|
|
1583
1237
|
}
|
|
1584
1238
|
fieldMessageHide(fieldKey, message) {
|
|
1585
|
-
let field =
|
|
1239
|
+
let field = getFormFieldByKey(this.formFields, fieldKey);
|
|
1586
1240
|
let fieldIndex = this.formFields.findIndex((_) => {
|
|
1587
1241
|
return field.key === _.key;
|
|
1588
1242
|
});
|
|
1589
|
-
field =
|
|
1243
|
+
field = removeFormFieldMessage(field, message);
|
|
1590
1244
|
this.formFields[fieldIndex] = field;
|
|
1591
1245
|
}
|
|
1592
1246
|
setObjectValue(field, path, value) { }
|
|
@@ -1595,6 +1249,14 @@ class KwikIDFormViewComponent {
|
|
|
1595
1249
|
[key]: value
|
|
1596
1250
|
}, { emitEvent: false });
|
|
1597
1251
|
}
|
|
1252
|
+
patchFormGroup(formData) {
|
|
1253
|
+
if (isUndefined(this.formGroup) || isUndefined(formData)) {
|
|
1254
|
+
throw new Error(`formGroup or formData is 'undefined'.`);
|
|
1255
|
+
}
|
|
1256
|
+
else {
|
|
1257
|
+
this.formGroup.patchValue(formData, { emitEvent: false });
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1598
1260
|
isFieldValid(fieldKey) {
|
|
1599
1261
|
return this.formGroup.controls[fieldKey].valid;
|
|
1600
1262
|
}
|
|
@@ -1604,18 +1266,7 @@ class KwikIDFormViewComponent {
|
|
|
1604
1266
|
getFormGroupRawValues() {
|
|
1605
1267
|
return this.formGroup.getRawValue();
|
|
1606
1268
|
}
|
|
1607
|
-
|
|
1608
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1609
|
-
if (checkObjectKeyExists(childField, "json")) {
|
|
1610
|
-
childField.options = getSearchTextOptionsFromFieldConfig(field, childField, this.formGroup);
|
|
1611
|
-
}
|
|
1612
|
-
if (checkObjectKeyExists(childField, "fetchJsonFromRemote")) {
|
|
1613
|
-
childField.options = yield getSearchTextOptionsFromRemoteFile(field, childField, this.formGroup);
|
|
1614
|
-
}
|
|
1615
|
-
return childField;
|
|
1616
|
-
});
|
|
1617
|
-
}
|
|
1618
|
-
takeActionOnFieldGroup(action, field, allFormsData, formData, previousFormData) {
|
|
1269
|
+
takeActionOnFieldGroup(action, object) {
|
|
1619
1270
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1620
1271
|
switch (action.key) {
|
|
1621
1272
|
case EActionKey.FIELD_GROUP_HIDE:
|
|
@@ -1666,16 +1317,40 @@ class KwikIDFormViewComponent {
|
|
|
1666
1317
|
this.fieldMessageHide(action.props.fieldKey, action.props.message);
|
|
1667
1318
|
break;
|
|
1668
1319
|
case EActionKey.SET_VALUE:
|
|
1669
|
-
const
|
|
1670
|
-
const sourceValue = yield
|
|
1671
|
-
|
|
1672
|
-
object.FIELD_CONFIG =
|
|
1673
|
-
this.formData =
|
|
1674
|
-
this.
|
|
1675
|
-
this.
|
|
1320
|
+
const setValue_Sources = new Source(object);
|
|
1321
|
+
const sourceValue = yield setValue_Sources.getValueFromSource(action.props.value.source);
|
|
1322
|
+
setValue_Sources.setValueToSource(action.props.value.destination, sourceValue);
|
|
1323
|
+
object.FIELD_CONFIG = setValue_Sources.object.FIELD_CONFIG;
|
|
1324
|
+
this.formData = setValue_Sources.object.FORM_DATA;
|
|
1325
|
+
this.patchFormGroup(this.formData);
|
|
1326
|
+
this.allFormsData = setValue_Sources.object.ALL_FORMS_DATA;
|
|
1327
|
+
this.previousFormData = setValue_Sources.object.PREVIOUS_FORM_DATA;
|
|
1328
|
+
break;
|
|
1329
|
+
case EActionKey.SET_DROPDOWN_OPTIONS:
|
|
1330
|
+
const setDropdownValue_Sources = new Source(object);
|
|
1331
|
+
let dropdownValue = yield setDropdownValue_Sources.getValueFromSource(action.props.value.source);
|
|
1332
|
+
if (checkObjectKeyExists(action.props, "options")) {
|
|
1333
|
+
if (checkObjectKeyExists(action.props.options, "appendToPath")) {
|
|
1334
|
+
let appendToPath = yield setDropdownValue_Sources.getValueFromSource(action.props.options.appendToPath.source);
|
|
1335
|
+
if (isNotEmptyValue(appendToPath)) {
|
|
1336
|
+
const appendToPathStr = replaceString(appendToPath.match(`${action.props.options.appendToPath.filterSourceValue}`)[0], "[^a-zA-Z0-9_]", "_");
|
|
1337
|
+
const optionsPath = `${action.props.options.path}${appendToPathStr}`;
|
|
1338
|
+
dropdownValue = getObjectValueFromPath(dropdownValue, optionsPath);
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
else {
|
|
1342
|
+
dropdownValue = getObjectValueFromPath(dropdownValue, action.props.options.path);
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
setDropdownValue_Sources.setValueToSource(action.props.value.destination, dropdownValue);
|
|
1346
|
+
object.FIELD_CONFIG = setDropdownValue_Sources.object.FIELD_CONFIG;
|
|
1347
|
+
this.formData = setDropdownValue_Sources.object.FORM_DATA;
|
|
1348
|
+
this.allFormsData = setDropdownValue_Sources.object.ALL_FORMS_DATA;
|
|
1349
|
+
this.previousFormData =
|
|
1350
|
+
setDropdownValue_Sources.object.PREVIOUS_FORM_DATA;
|
|
1676
1351
|
break;
|
|
1677
1352
|
case EActionKey.HANDLE_CONNECTED_ELEMENTS:
|
|
1678
|
-
this.handleConnectedElements({ key: action.props.fieldKey }, "
|
|
1353
|
+
this.handleConnectedElements({ key: action.props.fieldKey }, "ON_ACTION");
|
|
1679
1354
|
break;
|
|
1680
1355
|
case EActionKey.CUSTOM:
|
|
1681
1356
|
break;
|
|
@@ -1686,7 +1361,7 @@ class KwikIDFormViewComponent {
|
|
|
1686
1361
|
}
|
|
1687
1362
|
}
|
|
1688
1363
|
/** @nocollapse */ KwikIDFormViewComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: KwikIDFormViewComponent, deps: [{ token: TuiPushService }, { token: TuiAlertService }, { token: KwikIDFormViewService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1689
|
-
/** @nocollapse */ KwikIDFormViewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: KwikIDFormViewComponent, selector: "kwikid-form-view", inputs: { formConfig: "formConfig", formData: "formData", apiCallResponse: "apiCallResponse", isMobileView: "isMobileView", allFormsData: "allFormsData", formsList: "formsList" }, outputs: { onClickViewForms: "onClickViewForms", onClickSaveForm: "onClickSaveForm", onClickApiCall: "onClickApiCall", getActiveFormData: "getActiveFormData" }, providers: [KwikIDFormViewService], usesOnChanges: true, ngImport: i0, template: "<div\n class=\"kwikid-form-container\"\n *ngIf=\"!this.loading\"\n>\n <div id=\"uf-form-fields-header-container\">\n <div id=\"uf-form-fields-title\">\n {{ this.formConfig.title }}\n </div>\n <div id=\"uf-form-fields-steps\">\n Step {{ this.formConfig.sequenceNo }} of {{ this.formsList.length }}\n </div>\n <hr />\n </div>\n <form\n class=\"kwikid-form show\"\n [formGroup]=\"this.formGroup\"\n >\n <ng-container *ngFor=\"let field of this.formFields; let i = index\">\n <ng-container [ngSwitch]=\"field.type\">\n <!-- Form Title -->\n <ng-container *ngSwitchCase=\"'title'\">\n <div\n class=\"title\"\n [class.hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <div>\n {{ field.label }}\n </div>\n <kwikui-button\n *ngIf=\"field?.reset\"\n appearance=\"whiteblock\"\n size=\"s\"\n label=\"Reset\"\n (onClick)=\"this.handleOnClickResetFormFields($event, field)\"\n ></kwikui-button>\n </div>\n </ng-container>\n <!-- Input Text -->\n <ng-container *ngSwitchCase=\"'text'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input\n [case]=\"field?.properties?.case\"\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field.label\"\n [placeholder]=\"field?.properties?.placeholder\"\n [type]=\"'text'\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Checkbox -->\n <ng-container *ngSwitchCase=\"'checkbox'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-checkbox-block\n [contentAlign]=\"field?.properties?.contentAlign ?? 'left'\"\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field?.properties?.placeholder\"\n [placeholder]=\"field?.properties?.placeholder\"\n [properties]=\"field?.properties\"\n [size]=\"field?.properties?.size ?? 'l'\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-checkbox-block\n ><kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Input Number -->\n <ng-container *ngSwitchCase=\"'number'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input-number\n [decimal]=\"field?.properties?.decimal\"\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field?.label\"\n [max]=\"field?.properties?.max\"\n [min]=\"field?.properties?.min\"\n [placeholder]=\"field?.properties?.placeholder\"\n [postfix]=\"field?.properties?.postfix ?? ''\"\n [precision]=\"field?.properties?.precision\"\n [prefix]=\"field?.properties?.prefix ?? ''\"\n [properties]=\"field?.properties\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input-number\n ><kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Input Date -->\n <ng-container *ngSwitchCase=\"'date'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input-date\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field.label\"\n [max]=\"field?.properties?.max\"\n [min]=\"field?.properties?.min\"\n [placeholder]=\"field?.properties?.placeholder\"\n [properties]=\"field?.properties\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input-date>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Input Phone -->\n <ng-container *ngSwitchCase=\"'phone'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input-phone\n [countryCode]=\"field?.properties?.countryCode\"\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field?.label\"\n [phoneMaskAfterCountryCode]=\"\n field?.properties?.phoneMaskAfterCountryCode\n \"\n [placeholder]=\"field?.properties?.placeholder\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input-phone>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Input Radio -->\n <ng-container *ngSwitchCase=\"'radio'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <label\n [tuiLabel]=\"labelTemplate\"\n style=\"min-height: auto\"\n >\n <kwikui-radio-list\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [items]=\"field?.options\"\n [label]=\"field?.label\"\n [orientation]=\"field?.properties?.orientation\"\n [placeholder]=\"field?.properties?.placeholder\"\n [properties]=\"field?.properties\"\n [size]=\"field?.properties?.size\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-radio-list>\n </label>\n <ng-template #labelTemplate>\n <p\n class=\"tui-space_bottom-2\"\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <b>\n {{ field.label }}\n <span *ngIf=\"field.validators?.required\"></span>\n </b>\n </p>\n </ng-template>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Dropdown -->\n <ng-container *ngSwitchCase=\"'dropdown-with-search'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-select-combobox\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field.label\"\n [options]=\"field.options\"\n [placeholder]=\"field?.properties?.placeholder\"\n [properties]=\"field?.properties\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-select-combobox>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- API Call -->\n <ng-container *ngSwitchCase=\"'api-call'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-button-api-call\n [apiStatus]=\"field?.api?.status?.value\"\n [class]=\"field?.class\"\n [disabled]=\"field?.disabled\"\n [id]=\"field.key\"\n [label]=\"field?.api?.status?.labels[field?.api?.status?.value]\"\n [showLoader]=\"field?.disabled === 'loading'\"\n shape=\"null\"\n size=\"m\"\n styles=\"width: fit-content\"\n (onClick)=\"this.handleOnClickApiCall($event)\"\n ></kwikui-button-api-call>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Mobile OTP -->\n <ng-container *ngSwitchCase=\"'otp'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input-otp\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field?.label\"\n [mask]=\"field?.properties?.mask\"\n [placeholder]=\"field?.properties?.placeholder\"\n [properties]=\"field?.properties\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input-otp>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Aadhaar Number -->\n <ng-container *ngSwitchCase=\"'aadhaar-number'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input-aadhaar\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field?.label\"\n [placeholder]=\"field?.placeholder\"\n [properties]=\"field?.properties\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input-aadhaar>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n </ng-container>\n </ng-container>\n </form>\n <div class=\"kwikid-form-buttons\">\n <kwikui-button\n *ngIf=\"this.isMobileView\"\n [disabled]=\"viewFormsButton.disabled\"\n id=\"\"\n label=\"View Forms\"\n [showLoader]=\"viewFormsButton.showLoader\"\n styles=\"\"\n class=\"\"\n type=\"button\"\n appearance=\"secondary\"\n icon=\"\"\n iconRight=\"\"\n [shape]=\"null\"\n size=\"m\"\n styles=\"width: 100%\"\n (onClick)=\"this.handleOnClickViewForms($event)\"\n ></kwikui-button>\n <kwikui-button\n [disabled]=\"saveFormButton.disabled\"\n id=\"\"\n label=\"Save\"\n [showLoader]=\"saveFormButton.showLoader\"\n styles=\"\"\n class=\"\"\n type=\"button\"\n appearance=\"primary\"\n icon=\"\"\n iconRight=\"\"\n [shape]=\"null\"\n size=\"m\"\n styles=\"width: 100%\"\n (onClick)=\"this.handleOnClickSaveForm($event)\"\n ></kwikui-button>\n </div>\n</div>\n<div\n class=\"kwikid-form-container-loading\"\n *ngIf=\"this.loading\"\n>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"this.loading\"\n [class.tui-skeleton_rounded]=\"this.loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"this.loading\"\n [class.tui-skeleton_rounded]=\"this.loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"this.loading\"\n [class.tui-skeleton_rounded]=\"this.loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"this.loading\"\n [class.tui-skeleton_rounded]=\"this.loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"this.loading\"\n [class.tui-skeleton_rounded]=\"this.loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"this.loading\"\n [class.tui-skeleton_rounded]=\"this.loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"this.loading\"\n [class.tui-skeleton_rounded]=\"this.loading\"\n ></div>\n</div>\n<tui-push\n id=\"field-error-notification\"\n *tuiPush=\"showErrorNotification\"\n heading=\"Missing/Incorrect Fields!\"\n type=\"Error\"\n (close)=\"toggleErrorNotification(false)\"\n>\n <tui-svg\n src=\"tuiIconCancel\"\n style=\"color: #fff !important\"\n >\n </tui-svg>\n</tui-push>\n", styles: ["::-webkit-scrollbar{width:8px}::-webkit-scrollbar-track{border-radius:10px}::-webkit-scrollbar-thumb{background:lightgray;border-radius:10px}::-webkit-scrollbar-thumb:hover{background:gray}.kwikid-form-container{width:100%;height:100%;margin:0 auto;display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;align-content:center}.kwikid-form.show{width:100%;height:100%;padding:1rem;overflow-y:auto;display:flex;flex-direction:column;align-content:center;justify-content:flex-start;align-items:stretch;grid-row-gap:1rem;row-gap:1rem}.kwikid-form-buttons{width:100%;bottom:0px;padding:1rem;display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center;grid-column-gap:10px;column-gap:10px}.kwikid-form-buttons *{flex-grow:1}#uf-form-fields-header-container{display:flex;flex-direction:column;align-content:center;justify-content:center;align-items:flex-start;grid-row-gap:.5rem;row-gap:.5rem;padding:1rem}#uf-form-fields-header-container hr{width:100%}#uf-form-fields-title{color:#000;font-size:1.75em;font-weight:bold}#uf-form-fields-steps{color:var(--color-on-secondary-container);font-size:1em}.title{border-left:.25rem solid var(--tui-primary);padding:.75rem;font-size:1.4em;font-weight:bold;background-color:var(--tui-secondary);display:flex;flex-direction:row;align-content:center;justify-content:space-between;align-items:center;grid-gap:.5rem;gap:.5rem}.title:not(:first-child){margin-top:.5rem}.title.hidden{display:none}.large-wrapper{width:100%;height:60px}.large-wrapper:first-child{margin-bottom:auto}.large-wrapper:last-child{margin-top:auto}.kwikid-form-container-loading{width:100%;height:100%;margin:0 auto;display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;align-content:center;grid-row-gap:1rem;row-gap:1rem;padding:1rem}#field-error-notification{background-color:var(--tui-error-fill);color:#fff!important}#field-error-notification .t-top{color:#fff!important}#field-error-notification .t-close{color:#fff!important}\n"], components: [{ type: i2.KwikUIButtonComponent, selector: "kwikui-button", inputs: ["disabled", "id", "label", "showLoader", "styles", "class", "type", "appearance", "icon", "iconRight", "shape", "size"], outputs: ["onClick"] }, { type: i2.KwikUIInputComponent, selector: "kwikui-input", inputs: ["label", "id", "type", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "validators", "case", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIMessagesComponent, selector: "kwikui-messages", inputs: ["messages", "id"] }, { type: i2.KwikUICheckboxBlockComponent, selector: "kwikui-checkbox-block", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "size", "contentAlign", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIInputNumberComponent, selector: "kwikui-input-number", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "min", "max", "prefix", "postfix", "precision", "decimal", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIInputDateComponent, selector: "kwikui-input-date", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "min", "max", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIInputPhoneComponent, selector: "kwikui-input-phone", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "countryCode", "phoneMaskAfterCountryCode", "removeCountryCodeFromValue", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i3.TuiLabelComponent, selector: "label[tuiLabel]", inputs: ["tuiLabel", "context"] }, { type: i2.KwikUIRadioListComponent, selector: "kwikui-radio-list", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "size", "orientation", "items", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUISelectComboboxComponent, selector: "kwikui-select-combobox", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "options", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIButtonApiCallComponent, selector: "kwikui-button-api-call", inputs: ["disabled", "id", "label", "showLoader", "styles", "class", "shape", "size", "apiStatus"], outputs: ["onClick"] }, { type: i2.KwikUIInputOtpComponent, selector: "kwikui-input-otp", inputs: ["label", "id", "formControlName", "formControl", "focus", "invalid", "disabled", "placeholder", "mask", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIInputAadhaarComponent, selector: "kwikui-input-aadhaar", inputs: ["label", "id", "formControlName", "formControl", "focus", "invalid", "disabled", "placeholder", "mask", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i4.TuiPushComponent, selector: "tui-push", inputs: ["heading", "type", "timestamp"], outputs: ["close"] }, { type: i3.TuiSvgComponent, selector: "tui-svg", inputs: ["src"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i6.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i6.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i6.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i5.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i6.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i6.FormControlDirective, selector: "[formControl]", inputs: ["disabled", "formControl", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { type: i6.FormControlName, selector: "[formControlName]", inputs: ["disabled", "formControlName", "ngModel"], outputs: ["ngModelChange"] }, { type: i4.TuiPushAlertDirective, selector: "[tuiPush]", inputs: ["tuiPush"] }, { type: i4.TuiPushDirective, selector: "tui-push" }] });
|
|
1364
|
+
/** @nocollapse */ KwikIDFormViewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: KwikIDFormViewComponent, selector: "kwikid-form-view", inputs: { formConfig: "formConfig", formData: "formData", apiCallResponse: "apiCallResponse", isMobileView: "isMobileView", allFormsData: "allFormsData", formsList: "formsList" }, outputs: { onClickViewForms: "onClickViewForms", onClickSaveForm: "onClickSaveForm", onClickApiCall: "onClickApiCall", getActiveFormData: "getActiveFormData" }, providers: [KwikIDFormViewService], usesOnChanges: true, ngImport: i0, template: "<div\n class=\"kwikid-form-container\"\n *ngIf=\"!this.loading\"\n>\n <div id=\"uf-form-fields-header-container\">\n <div id=\"uf-form-fields-title\">\n {{ this.formConfig.title }}\n </div>\n <div id=\"uf-form-fields-steps\">\n Step {{ this.formConfig.sequenceNo }} of {{ this.formsList.length }}\n </div>\n <hr />\n </div>\n <form\n class=\"kwikid-form show\"\n [formGroup]=\"this.formGroup\"\n >\n <ng-container *ngFor=\"let field of this.formFields; let i = index\">\n <ng-container [ngSwitch]=\"field.type\">\n <!-- HTML Content -->\n <ng-container *ngSwitchCase=\"'html'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <div [innerHtml]=\"field.html | safeHtml\"></div>\n </div>\n </ng-container>\n <!-- Form Title -->\n <ng-container *ngSwitchCase=\"'title'\">\n <div\n class=\"title\"\n [class.hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <div>\n {{ field.label }}\n </div>\n <kwikui-button\n *ngIf=\"field?.reset\"\n appearance=\"whiteblock\"\n size=\"s\"\n label=\"Reset\"\n (onClick)=\"this.handleOnClickResetFormFields($event, field)\"\n ></kwikui-button>\n </div>\n </ng-container>\n <!-- Input Text -->\n <ng-container *ngSwitchCase=\"'text'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input\n [case]=\"field?.properties?.case\"\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field.label\"\n [placeholder]=\"field?.properties?.placeholder\"\n [type]=\"'text'\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Checkbox -->\n <ng-container *ngSwitchCase=\"'checkbox'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-checkbox-block\n [contentAlign]=\"field?.properties?.contentAlign ?? 'left'\"\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field?.properties?.placeholder\"\n [placeholder]=\"field?.properties?.placeholder\"\n [properties]=\"field?.properties\"\n [size]=\"field?.properties?.size ?? 'l'\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-checkbox-block\n ><kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Input Number -->\n <ng-container *ngSwitchCase=\"'number'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input-number\n [decimal]=\"field?.properties?.decimal\"\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field?.label\"\n [max]=\"field?.properties?.max\"\n [min]=\"field?.properties?.min\"\n [placeholder]=\"field?.properties?.placeholder\"\n [postfix]=\"field?.properties?.postfix ?? ''\"\n [precision]=\"field?.properties?.precision\"\n [prefix]=\"field?.properties?.prefix ?? ''\"\n [properties]=\"field?.properties\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input-number\n ><kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Input Date -->\n <ng-container *ngSwitchCase=\"'date'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input-date\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field.label\"\n [max]=\"field?.properties?.max\"\n [min]=\"field?.properties?.min\"\n [placeholder]=\"field?.properties?.placeholder\"\n [properties]=\"field?.properties\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input-date>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Input Phone -->\n <ng-container *ngSwitchCase=\"'phone'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input-phone\n [countryCode]=\"field?.properties?.countryCode\"\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field?.label\"\n [phoneMaskAfterCountryCode]=\"\n field?.properties?.phoneMaskAfterCountryCode\n \"\n [placeholder]=\"field?.properties?.placeholder\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input-phone>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Input Radio -->\n <ng-container *ngSwitchCase=\"'radio'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <label\n [tuiLabel]=\"labelTemplate\"\n style=\"min-height: auto\"\n >\n <kwikui-radio-list\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [items]=\"field?.options\"\n [label]=\"field?.label\"\n [orientation]=\"field?.properties?.orientation\"\n [placeholder]=\"field?.properties?.placeholder\"\n [properties]=\"field?.properties\"\n [size]=\"field?.properties?.size\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-radio-list>\n </label>\n <ng-template #labelTemplate>\n <p\n class=\"tui-space_bottom-2\"\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <b>\n {{ field.label }}\n <span *ngIf=\"field.validators?.required\"></span>\n </b>\n </p>\n </ng-template>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Dropdown -->\n <ng-container *ngSwitchCase=\"'dropdown-with-search'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-select-combobox\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field.label\"\n [options]=\"field.options\"\n [placeholder]=\"field?.properties?.placeholder\"\n [properties]=\"field?.properties\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-select-combobox>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- API Call -->\n <ng-container *ngSwitchCase=\"'api-call'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-button-api-call\n [apiStatus]=\"field?.api?.status?.value\"\n [class]=\"field?.class\"\n [disabled]=\"field?.disabled\"\n [id]=\"field.key\"\n [label]=\"field?.api?.status?.labels[field?.api?.status?.value]\"\n [showLoader]=\"field?.disabled === 'loading'\"\n shape=\"null\"\n size=\"m\"\n styles=\"width: fit-content\"\n (onClick)=\"this.handleOnClickApiCall($event)\"\n ></kwikui-button-api-call>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Mobile OTP -->\n <ng-container *ngSwitchCase=\"'otp'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input-otp\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field?.label\"\n [mask]=\"field?.properties?.mask\"\n [placeholder]=\"field?.properties?.placeholder\"\n [properties]=\"field?.properties\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input-otp>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n <!-- Aadhaar Number -->\n <ng-container *ngSwitchCase=\"'aadhaar-number'\">\n <div\n [hidden]=\"field?.hidden\"\n id=\"field_{{ field.key }}\"\n >\n <kwikui-input-aadhaar\n [disabled]=\"field?.disabled\"\n [focus]=\"field?.focus\"\n [formControl]=\"formGroup.controls[field.key]\"\n [formControlName]=\"field.key\"\n [id]=\"field.key\"\n [invalid]=\"field?.invalid\"\n [label]=\"field?.label\"\n [placeholder]=\"field?.placeholder\"\n [properties]=\"field?.properties\"\n [validators]=\"field?.validators\"\n (getKeyValue)=\"handleGetKeyValue($event)\"\n ></kwikui-input-aadhaar>\n <kwikui-messages\n [messages]=\"field.messages\"\n [id]=\"field.key\"\n ></kwikui-messages>\n </div>\n </ng-container>\n </ng-container>\n </ng-container>\n </form>\n <div class=\"kwikid-form-buttons\">\n <kwikui-button\n *ngIf=\"this.isMobileView\"\n [disabled]=\"viewFormsButton.disabled\"\n id=\"\"\n label=\"View Forms\"\n [showLoader]=\"viewFormsButton.showLoader\"\n styles=\"\"\n class=\"\"\n type=\"button\"\n appearance=\"secondary\"\n icon=\"\"\n iconRight=\"\"\n [shape]=\"null\"\n size=\"m\"\n styles=\"width: 100%\"\n (onClick)=\"this.handleOnClickViewForms($event)\"\n ></kwikui-button>\n <kwikui-button\n [disabled]=\"saveFormButton.disabled\"\n id=\"\"\n label=\"Save\"\n [showLoader]=\"saveFormButton.showLoader\"\n styles=\"\"\n class=\"\"\n type=\"button\"\n appearance=\"primary\"\n icon=\"\"\n iconRight=\"\"\n [shape]=\"null\"\n size=\"m\"\n styles=\"width: 100%\"\n (onClick)=\"this.handleOnClickSaveForm($event)\"\n ></kwikui-button>\n </div>\n</div>\n<div\n class=\"kwikid-form-container-loading\"\n *ngIf=\"this.loading\"\n>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"this.loading\"\n [class.tui-skeleton_rounded]=\"this.loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"this.loading\"\n [class.tui-skeleton_rounded]=\"this.loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"this.loading\"\n [class.tui-skeleton_rounded]=\"this.loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"this.loading\"\n [class.tui-skeleton_rounded]=\"this.loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"this.loading\"\n [class.tui-skeleton_rounded]=\"this.loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"this.loading\"\n [class.tui-skeleton_rounded]=\"this.loading\"\n ></div>\n <div\n class=\"large-wrapper\"\n [class.tui-skeleton]=\"this.loading\"\n [class.tui-skeleton_rounded]=\"this.loading\"\n ></div>\n</div>\n<tui-push\n id=\"field-error-notification\"\n *tuiPush=\"showErrorNotification\"\n heading=\"Missing/Incorrect Fields!\"\n type=\"Error\"\n (close)=\"toggleErrorNotification(false)\"\n>\n <tui-svg\n src=\"tuiIconCancel\"\n style=\"color: #fff !important\"\n >\n </tui-svg>\n</tui-push>\n", styles: ["::-webkit-scrollbar{width:8px}::-webkit-scrollbar-track{border-radius:10px}::-webkit-scrollbar-thumb{background:lightgray;border-radius:10px}::-webkit-scrollbar-thumb:hover{background:gray}.kwikid-form-container{width:100%;height:100%;margin:0 auto;display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;align-content:center}.kwikid-form.show{width:100%;height:100%;padding:1rem;overflow-y:auto;display:flex;flex-direction:column;align-content:center;justify-content:flex-start;align-items:stretch;grid-row-gap:1rem;row-gap:1rem}.kwikid-form-buttons{width:100%;bottom:0px;padding:1rem;display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center;grid-column-gap:10px;column-gap:10px}.kwikid-form-buttons *{flex-grow:1}#uf-form-fields-header-container{display:flex;flex-direction:column;align-content:center;justify-content:center;align-items:flex-start;grid-row-gap:.5rem;row-gap:.5rem;padding:1rem}#uf-form-fields-header-container hr{width:100%}#uf-form-fields-title{color:#000;font-size:1.75em;font-weight:bold}#uf-form-fields-steps{color:var(--color-on-secondary-container);font-size:1em}.title{border-left:.25rem solid var(--tui-primary);padding:.75rem;font-size:1.4em;font-weight:bold;background-color:var(--tui-secondary);display:flex;flex-direction:row;align-content:center;justify-content:space-between;align-items:center;grid-gap:.5rem;gap:.5rem}.title:not(:first-child){margin-top:.5rem}.title.hidden{display:none}.large-wrapper{width:100%;height:60px}.large-wrapper:first-child{margin-bottom:auto}.large-wrapper:last-child{margin-top:auto}.kwikid-form-container-loading{width:100%;height:100%;margin:0 auto;display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;align-content:center;grid-row-gap:1rem;row-gap:1rem;padding:1rem}#field-error-notification{background-color:var(--tui-error-fill);color:#fff!important}#field-error-notification .t-top{color:#fff!important}#field-error-notification .t-close{color:#fff!important}\n"], components: [{ type: i2.KwikUIButtonComponent, selector: "kwikui-button", inputs: ["disabled", "id", "label", "showLoader", "styles", "class", "type", "appearance", "icon", "iconRight", "shape", "size"], outputs: ["onClick"] }, { type: i2.KwikUIInputComponent, selector: "kwikui-input", inputs: ["label", "id", "type", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "validators", "case", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIMessagesComponent, selector: "kwikui-messages", inputs: ["messages", "id"] }, { type: i2.KwikUICheckboxBlockComponent, selector: "kwikui-checkbox-block", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "size", "contentAlign", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIInputNumberComponent, selector: "kwikui-input-number", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "min", "max", "prefix", "postfix", "precision", "decimal", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIInputDateComponent, selector: "kwikui-input-date", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "min", "max", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIInputPhoneComponent, selector: "kwikui-input-phone", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "countryCode", "phoneMaskAfterCountryCode", "removeCountryCodeFromValue", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i3.TuiLabelComponent, selector: "label[tuiLabel]", inputs: ["tuiLabel", "context"] }, { type: i2.KwikUIRadioListComponent, selector: "kwikui-radio-list", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "size", "orientation", "items", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUISelectComboboxComponent, selector: "kwikui-select-combobox", inputs: ["label", "id", "formControlName", "formControl", "placeholder", "focus", "invalid", "disabled", "options", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIButtonApiCallComponent, selector: "kwikui-button-api-call", inputs: ["disabled", "id", "label", "showLoader", "styles", "class", "shape", "size", "apiStatus"], outputs: ["onClick"] }, { type: i2.KwikUIInputOtpComponent, selector: "kwikui-input-otp", inputs: ["label", "id", "formControlName", "formControl", "focus", "invalid", "disabled", "placeholder", "mask", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i2.KwikUIInputAadhaarComponent, selector: "kwikui-input-aadhaar", inputs: ["label", "id", "formControlName", "formControl", "focus", "invalid", "disabled", "placeholder", "mask", "validators", "properties"], outputs: ["getKeyValue"] }, { type: i4.TuiPushComponent, selector: "tui-push", inputs: ["heading", "type", "timestamp"], outputs: ["close"] }, { type: i3.TuiSvgComponent, selector: "tui-svg", inputs: ["src"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i6.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i6.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i6.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i5.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i6.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i6.FormControlDirective, selector: "[formControl]", inputs: ["disabled", "formControl", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { type: i6.FormControlName, selector: "[formControlName]", inputs: ["disabled", "formControlName", "ngModel"], outputs: ["ngModelChange"] }, { type: i4.TuiPushAlertDirective, selector: "[tuiPush]", inputs: ["tuiPush"] }, { type: i4.TuiPushDirective, selector: "tui-push" }], pipes: { "safeHtml": SafeHtmlPipe } });
|
|
1690
1365
|
__decorate([
|
|
1691
1366
|
logMethod
|
|
1692
1367
|
], KwikIDFormViewComponent.prototype, "ngOnInit", null);
|
|
@@ -1786,6 +1461,9 @@ __decorate([
|
|
|
1786
1461
|
__decorate([
|
|
1787
1462
|
logMethod
|
|
1788
1463
|
], KwikIDFormViewComponent.prototype, "patchFieldControlValue", null);
|
|
1464
|
+
__decorate([
|
|
1465
|
+
logMethod
|
|
1466
|
+
], KwikIDFormViewComponent.prototype, "patchFormGroup", null);
|
|
1789
1467
|
__decorate([
|
|
1790
1468
|
logMethod
|
|
1791
1469
|
], KwikIDFormViewComponent.prototype, "isFieldValid", null);
|
|
@@ -1795,9 +1473,6 @@ __decorate([
|
|
|
1795
1473
|
__decorate([
|
|
1796
1474
|
logMethod
|
|
1797
1475
|
], KwikIDFormViewComponent.prototype, "getFormGroupRawValues", null);
|
|
1798
|
-
__decorate([
|
|
1799
|
-
logMethod
|
|
1800
|
-
], KwikIDFormViewComponent.prototype, "handleFieldTypeSearchText", null);
|
|
1801
1476
|
__decorate([
|
|
1802
1477
|
logMethod
|
|
1803
1478
|
], KwikIDFormViewComponent.prototype, "takeActionOnFieldGroup", null);
|
|
@@ -1838,7 +1513,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
1838
1513
|
type: Output
|
|
1839
1514
|
}], getActiveFormData: [{
|
|
1840
1515
|
type: Output
|
|
1841
|
-
}], ngOnInit: [], ngAfterViewInit: [], ngOnChanges: [], initFormConfig: [], setFormFieldsFromFormConfig: [], setFormFieldGroupsFromFormConfig: [], setFormDataFromAllFormsData: [], handleConnectedElementFieldGroupActions: [], handleConnectedElementFieldGroup: [], handleConnectedElementFieldActions: [], handleConnectedElementFields: [], handleConnectedElements: [], handleGetKeyValue: [], handleOnClickResetFormFields: [], handleOnClickApiCall: [], handleOnClickViewForms: [], handleOnClickSaveForm: [], toggleErrorNotification: [], fieldHide: [], fieldGroupHide: [], fieldShow: [], fieldGroupShow: [], fieldDisable: [], fieldGroupDisable: [], fieldEnable: [], fieldGroupEnable: [], fieldReset: [], fieldErrorShow: [], fieldErrorHide: [], fieldMessageShow: [], fieldMessageHide: [], setObjectValue: [], patchFieldControlValue: [],
|
|
1516
|
+
}], ngOnInit: [], ngAfterViewInit: [], ngOnChanges: [], initFormConfig: [], setFormFieldsFromFormConfig: [], setFormFieldGroupsFromFormConfig: [], setFormDataFromAllFormsData: [], handleConnectedElementFieldGroupActions: [], handleConnectedElementFieldGroup: [], handleConnectedElementFieldActions: [], handleConnectedElementFields: [], handleConnectedElements: [], handleGetKeyValue: [], handleOnClickResetFormFields: [], handleOnClickApiCall: [], handleOnClickViewForms: [], handleOnClickSaveForm: [], toggleErrorNotification: [], fieldHide: [], fieldGroupHide: [], fieldShow: [], fieldGroupShow: [], fieldDisable: [], fieldGroupDisable: [], fieldEnable: [], fieldGroupEnable: [], fieldReset: [], fieldErrorShow: [], fieldErrorHide: [], fieldMessageShow: [], fieldMessageHide: [], setObjectValue: [], patchFieldControlValue: [], patchFormGroup: [], isFieldValid: [], isFieldEnabled: [], getFormGroupRawValues: [], takeActionOnFieldGroup: [], takeAction: [] } });
|
|
1842
1517
|
|
|
1843
1518
|
class KwikIDFormsListComponent {
|
|
1844
1519
|
constructor() {
|
|
@@ -1953,42 +1628,59 @@ class Converter {
|
|
|
1953
1628
|
}
|
|
1954
1629
|
convertFormConfig(formConfig) {
|
|
1955
1630
|
const updateOnFieldType = (field) => {
|
|
1631
|
+
const formatFieldTypeHtml = (field) => {
|
|
1632
|
+
field = this.setFieldKeyValue(field, "isFormElement", false);
|
|
1633
|
+
return field;
|
|
1634
|
+
};
|
|
1956
1635
|
const formatFieldTypeTitle = (field) => {
|
|
1957
1636
|
field = this.setFieldKeyValue(field, "hidden", false);
|
|
1637
|
+
field = this.setFieldKeyValue(field, "isFormElement", false);
|
|
1958
1638
|
return field;
|
|
1959
1639
|
};
|
|
1960
|
-
const
|
|
1961
|
-
field
|
|
1962
|
-
field.properties = this.setMissingFieldKeyValue(field.properties, "
|
|
1963
|
-
field = this.setFieldKeyValue(field, "hidden", false);
|
|
1964
|
-
field.options = field.options.map((x) => {
|
|
1965
|
-
if (typeof x === "string" || typeof x === "number") {
|
|
1966
|
-
return { label: x, disabled: false };
|
|
1967
|
-
}
|
|
1968
|
-
else {
|
|
1969
|
-
if (checkObjectKeyExists(x, "label") &&
|
|
1970
|
-
checkObjectKeyExists(x, "disabled")) {
|
|
1971
|
-
return x;
|
|
1972
|
-
}
|
|
1973
|
-
}
|
|
1974
|
-
});
|
|
1640
|
+
const formatFieldTypeText = (field) => {
|
|
1641
|
+
field = this.setFieldKeyValue(field, "isFormElement", true);
|
|
1642
|
+
field.properties = this.setMissingFieldKeyValue(field.properties, "case", "default");
|
|
1975
1643
|
return field;
|
|
1976
1644
|
};
|
|
1977
|
-
const
|
|
1978
|
-
field
|
|
1645
|
+
const formatFieldTypeCheckbox = (field) => {
|
|
1646
|
+
field = this.setFieldKeyValue(field, "isFormElement", true);
|
|
1647
|
+
return field;
|
|
1648
|
+
};
|
|
1649
|
+
const formatFieldTypeNumber = (field) => {
|
|
1650
|
+
field = this.setFieldKeyValue(field, "isFormElement", true);
|
|
1651
|
+
if (checkObjectKeyExists(field, "key")) {
|
|
1652
|
+
if (field.key === "aadhaar_number") {
|
|
1653
|
+
field = this.setFieldKeyValue(field, "type", "aadhaar_number");
|
|
1654
|
+
}
|
|
1655
|
+
if (field.key === "contact_number") {
|
|
1656
|
+
field = this.setFieldKeyValue(field, "type", "phone");
|
|
1657
|
+
}
|
|
1658
|
+
if (field.type === "phone" || field.type === "number") {
|
|
1659
|
+
field.properties = this.setMissingFieldKeyValue(field.properties, "countryCode", "+91");
|
|
1660
|
+
field.properties = this.setMissingFieldKeyValue(field.properties, "phoneMaskAfterCountryCode", "####-######");
|
|
1661
|
+
field.properties = this.setMissingFieldKeyValue(field.properties, "removeCountryCodeFromValue", true);
|
|
1662
|
+
field.properties = this.setMissingFieldKeyValue(field.properties, "decimal", "never");
|
|
1663
|
+
field.properties = this.setMissingFieldKeyValue(field.properties, "prefix", "");
|
|
1664
|
+
field.properties = this.setMissingFieldKeyValue(field.properties, "postfix", "");
|
|
1665
|
+
field.properties = this.setMissingFieldKeyValue(field.properties, "min", -Infinity);
|
|
1666
|
+
field.properties = this.setMissingFieldKeyValue(field.properties, "max", Infinity);
|
|
1667
|
+
field.properties = this.setMissingFieldKeyValue(field.properties, "precision", 2);
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1979
1670
|
field = this.setFieldKeyValue(field, "hidden", false);
|
|
1980
1671
|
return field;
|
|
1981
1672
|
};
|
|
1982
1673
|
const formatFieldTypeDate = (field) => {
|
|
1674
|
+
field = this.setFieldKeyValue(field, "isFormElement", true);
|
|
1983
1675
|
if (checkObjectKeyExists(field, "min")) {
|
|
1984
|
-
const tuiDay =
|
|
1676
|
+
const tuiDay = convertFormFieldTypeDateToKwikUIFormat(field["min"]);
|
|
1985
1677
|
field.properties = this.setFieldKeyValue(field.properties, "min", tuiDay);
|
|
1986
1678
|
}
|
|
1987
1679
|
else {
|
|
1988
1680
|
field.properties = this.setMissingFieldKeyValue(field.properties, "min", new TuiDay(0, 0, 1)); // Year - 0000, Month - 0 (0 Indexing), Day - 1
|
|
1989
1681
|
}
|
|
1990
1682
|
if (checkObjectKeyExists(field, "max")) {
|
|
1991
|
-
const tuiDay =
|
|
1683
|
+
const tuiDay = convertFormFieldTypeDateToKwikUIFormat(field["max"]);
|
|
1992
1684
|
field.properties = this.setFieldKeyValue(field.properties, "max", tuiDay);
|
|
1993
1685
|
}
|
|
1994
1686
|
else {
|
|
@@ -2001,30 +1693,51 @@ class Converter {
|
|
|
2001
1693
|
field = this.setFieldKeyValue(field, "hidden", false);
|
|
2002
1694
|
return field;
|
|
2003
1695
|
};
|
|
2004
|
-
const
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
1696
|
+
const formatFieldTypePhone = (field) => {
|
|
1697
|
+
field = this.setFieldKeyValue(field, "isFormElement", true);
|
|
1698
|
+
return field;
|
|
1699
|
+
};
|
|
1700
|
+
const formatFieldTypeRadio = (field) => {
|
|
1701
|
+
field = this.setFieldKeyValue(field, "isFormElement", true);
|
|
1702
|
+
field.properties = this.setMissingFieldKeyValue(field.properties, "size", "m");
|
|
1703
|
+
field.properties = this.setMissingFieldKeyValue(field.properties, "orientation", "vertical");
|
|
1704
|
+
field = this.setFieldKeyValue(field, "hidden", false);
|
|
1705
|
+
field.options = field.options.map((x) => {
|
|
1706
|
+
if (typeof x === "string" || typeof x === "number") {
|
|
1707
|
+
return { label: x, disabled: false, description: "" };
|
|
2008
1708
|
}
|
|
2009
|
-
|
|
2010
|
-
|
|
1709
|
+
else {
|
|
1710
|
+
if (checkObjectKeyExists(x, "label") &&
|
|
1711
|
+
checkObjectKeyExists(x, "disabled") &&
|
|
1712
|
+
checkObjectKeyExists(x, "description")) {
|
|
1713
|
+
return x;
|
|
1714
|
+
}
|
|
1715
|
+
if (!checkObjectKeyExists(x, "disabled")) {
|
|
1716
|
+
x = Object.assign(Object.assign({}, x), { disabled: false });
|
|
1717
|
+
}
|
|
1718
|
+
if (!checkObjectKeyExists(x, "description")) {
|
|
1719
|
+
x = Object.assign(Object.assign({}, x), { description: false });
|
|
1720
|
+
}
|
|
1721
|
+
return x;
|
|
2011
1722
|
}
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
field
|
|
2020
|
-
field.properties = this.setMissingFieldKeyValue(field.properties, "max", Infinity);
|
|
2021
|
-
field.properties = this.setMissingFieldKeyValue(field.properties, "precision", 2);
|
|
1723
|
+
});
|
|
1724
|
+
return field;
|
|
1725
|
+
};
|
|
1726
|
+
const formatFieldTypeSearchText = (field) => {
|
|
1727
|
+
field = this.setFieldKeyValue(field, "isFormElement", true);
|
|
1728
|
+
if (checkObjectKeyExists(field, "type")) {
|
|
1729
|
+
if (field.type === "search-text") {
|
|
1730
|
+
field = this.setFieldKeyValue(field, "type", "dropdown-with-search");
|
|
2022
1731
|
}
|
|
2023
1732
|
}
|
|
2024
|
-
|
|
1733
|
+
return field;
|
|
1734
|
+
};
|
|
1735
|
+
const formatFieldTypeDropdownWithSearch = (field) => {
|
|
1736
|
+
field = this.setFieldKeyValue(field, "isFormElement", true);
|
|
2025
1737
|
return field;
|
|
2026
1738
|
};
|
|
2027
1739
|
const formatFieldTypeApiCall = (field) => {
|
|
1740
|
+
field = this.setFieldKeyValue(field, "isFormElement", true);
|
|
2028
1741
|
if (!checkObjectKeyExists(field.properties, "shape")) {
|
|
2029
1742
|
field.properties = this.setFieldKeyValue(field.properties, "shape", null);
|
|
2030
1743
|
}
|
|
@@ -2050,39 +1763,56 @@ class Converter {
|
|
|
2050
1763
|
}
|
|
2051
1764
|
return field;
|
|
2052
1765
|
};
|
|
2053
|
-
const
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
}
|
|
2058
|
-
}
|
|
1766
|
+
const formatFieldTypeOtp = (field) => {
|
|
1767
|
+
field = this.setFieldKeyValue(field, "isFormElement", true);
|
|
1768
|
+
field.properties = this.setMissingFieldKeyValue(field.properties, "mask", new Array(field.properties.otpLength).fill("#").join(" "));
|
|
1769
|
+
field = this.setFieldKeyValue(field, "hidden", false);
|
|
2059
1770
|
return field;
|
|
2060
1771
|
};
|
|
2061
|
-
const
|
|
1772
|
+
const formatFieldTypeAadhaarNumber = (field) => {
|
|
1773
|
+
field = this.setFieldKeyValue(field, "isFormElement", true);
|
|
2062
1774
|
return field;
|
|
2063
1775
|
};
|
|
2064
1776
|
switch (field.type) {
|
|
1777
|
+
case "html":
|
|
1778
|
+
field = formatFieldTypeHtml(field);
|
|
1779
|
+
break;
|
|
2065
1780
|
case "title":
|
|
2066
1781
|
field = formatFieldTypeTitle(field);
|
|
2067
1782
|
break;
|
|
2068
|
-
case "
|
|
2069
|
-
field =
|
|
1783
|
+
case "text":
|
|
1784
|
+
field = formatFieldTypeText(field);
|
|
2070
1785
|
break;
|
|
2071
|
-
case "
|
|
2072
|
-
field =
|
|
1786
|
+
case "checkbox":
|
|
1787
|
+
field = formatFieldTypeCheckbox(field);
|
|
1788
|
+
break;
|
|
1789
|
+
case "number":
|
|
1790
|
+
field = formatFieldTypeNumber(field);
|
|
2073
1791
|
break;
|
|
2074
1792
|
case "date":
|
|
2075
1793
|
field = formatFieldTypeDate(field);
|
|
2076
1794
|
break;
|
|
2077
|
-
case "
|
|
2078
|
-
field =
|
|
1795
|
+
case "phone":
|
|
1796
|
+
field = formatFieldTypePhone(field);
|
|
2079
1797
|
break;
|
|
2080
|
-
case "
|
|
2081
|
-
field =
|
|
1798
|
+
case "radio":
|
|
1799
|
+
field = formatFieldTypeRadio(field);
|
|
2082
1800
|
break;
|
|
2083
1801
|
case "search-text":
|
|
2084
1802
|
field = formatFieldTypeSearchText(field);
|
|
2085
1803
|
break;
|
|
1804
|
+
case "dropdown-with-search":
|
|
1805
|
+
field = formatFieldTypeDropdownWithSearch(field);
|
|
1806
|
+
break;
|
|
1807
|
+
case "api-call":
|
|
1808
|
+
field = formatFieldTypeApiCall(field);
|
|
1809
|
+
break;
|
|
1810
|
+
case "otp":
|
|
1811
|
+
field = formatFieldTypeOtp(field);
|
|
1812
|
+
break;
|
|
1813
|
+
case "aadhaar-number":
|
|
1814
|
+
field = formatFieldTypeAadhaarNumber(field);
|
|
1815
|
+
break;
|
|
2086
1816
|
default:
|
|
2087
1817
|
break;
|
|
2088
1818
|
}
|
|
@@ -2173,7 +1903,7 @@ class Converter {
|
|
|
2173
1903
|
};
|
|
2174
1904
|
const updateFieldValidatorConfig = (field) => {
|
|
2175
1905
|
var _a, _b, _c, _d, _e;
|
|
2176
|
-
if (field.
|
|
1906
|
+
if (field.isFormElement) {
|
|
2177
1907
|
const validators = checkObjectKeyExists(field, "validators")
|
|
2178
1908
|
? field.validators
|
|
2179
1909
|
: {};
|
|
@@ -2254,7 +1984,7 @@ class Converter {
|
|
|
2254
1984
|
return field;
|
|
2255
1985
|
};
|
|
2256
1986
|
const updateFieldDefaultValueConfig = (field) => {
|
|
2257
|
-
if (field.
|
|
1987
|
+
if (field.isFormElement) {
|
|
2258
1988
|
if (checkObjectKeyExists(field, "defaultValue")) {
|
|
2259
1989
|
return field;
|
|
2260
1990
|
}
|
|
@@ -2434,13 +2164,13 @@ class Converter {
|
|
|
2434
2164
|
return field;
|
|
2435
2165
|
};
|
|
2436
2166
|
const updateFieldMessages = (field) => {
|
|
2437
|
-
if (field.
|
|
2167
|
+
if (field.isFormElement) {
|
|
2438
2168
|
field = this.setMissingFieldKeyValue(field, "messages", []);
|
|
2439
2169
|
}
|
|
2440
2170
|
return field;
|
|
2441
2171
|
};
|
|
2442
2172
|
const updateFieldResetButton = (field) => {
|
|
2443
|
-
if (field.
|
|
2173
|
+
if (field.isFormElement) {
|
|
2444
2174
|
if (checkObjectKeyExists(field, "action") &&
|
|
2445
2175
|
field.action === "reset" &&
|
|
2446
2176
|
checkObjectKeyExists(field, "fields")) {
|
|
@@ -2553,9 +2283,8 @@ class KwikIDRendererService {
|
|
|
2553
2283
|
markFormInFormsListAsCompleted(formsList, formsListCompleted) {
|
|
2554
2284
|
for (let form of formsList) {
|
|
2555
2285
|
if (formsListCompleted.includes(form.key)) {
|
|
2556
|
-
|
|
2557
|
-
form =
|
|
2558
|
-
form = setValueToObject(form, "disabled", false);
|
|
2286
|
+
form = setValueToObjectPath(form, "status", "completed");
|
|
2287
|
+
form = setValueToObjectPath(form, "disabled", false);
|
|
2559
2288
|
}
|
|
2560
2289
|
}
|
|
2561
2290
|
return formsList;
|
|
@@ -2566,18 +2295,18 @@ class KwikIDRendererService {
|
|
|
2566
2295
|
if (checkObjectKeyExists(form, "dependentOn")) {
|
|
2567
2296
|
const isDependent = form.dependentOn.every((r) => formsListCompleted.includes(r));
|
|
2568
2297
|
if (isDependent) {
|
|
2569
|
-
form =
|
|
2570
|
-
form =
|
|
2298
|
+
form = setValueToObjectPath(form, "status", "editable");
|
|
2299
|
+
form = setValueToObjectPath(form, "disabled", false);
|
|
2571
2300
|
}
|
|
2572
2301
|
else {
|
|
2573
|
-
form =
|
|
2574
|
-
form =
|
|
2302
|
+
form = setValueToObjectPath(form, "status", "locked");
|
|
2303
|
+
form = setValueToObjectPath(form, "disabled", true);
|
|
2575
2304
|
}
|
|
2576
2305
|
}
|
|
2577
2306
|
else {
|
|
2578
|
-
form =
|
|
2579
|
-
form =
|
|
2580
|
-
form =
|
|
2307
|
+
form = setValueToObjectPath(form, "dependentOn", []);
|
|
2308
|
+
form = setValueToObjectPath(form, "status", "editable");
|
|
2309
|
+
form = setValueToObjectPath(form, "disabled", false);
|
|
2581
2310
|
}
|
|
2582
2311
|
}
|
|
2583
2312
|
}
|
|
@@ -2611,7 +2340,6 @@ class KwikIDRendererService {
|
|
|
2611
2340
|
* this particular User Form only has to LOCAL METHOD Variable.
|
|
2612
2341
|
*/
|
|
2613
2342
|
const currentUserFormAllFormsData = this.filterAllFormsData(this.allFormsData, formsList);
|
|
2614
|
-
console.log(JSON.parse(JSON.stringify(formsList)));
|
|
2615
2343
|
formsListCompleted = this.findCompletedFormsList(currentUserFormAllFormsData);
|
|
2616
2344
|
formsList = this.markFormInFormsListAsCompleted(formsList, formsListCompleted);
|
|
2617
2345
|
formsList = this.markFormInFormsListAsDisabled(formsList, formsListCompleted);
|
|
@@ -2768,6 +2496,9 @@ class KwikIDFormsRendererComponent {
|
|
|
2768
2496
|
}
|
|
2769
2497
|
handleResize(formsList) {
|
|
2770
2498
|
if (this.hostElement.nativeElement.offsetWidth < 600) {
|
|
2499
|
+
const isSingleForm = (formsList) => {
|
|
2500
|
+
return formsList.length === 1;
|
|
2501
|
+
};
|
|
2771
2502
|
if (!isSingleForm(formsList)) {
|
|
2772
2503
|
this.showFormSections = true;
|
|
2773
2504
|
this.showFormFields = false;
|
|
@@ -2814,9 +2545,8 @@ class KwikIDFormsRendererComponent {
|
|
|
2814
2545
|
}
|
|
2815
2546
|
// forms-list listener
|
|
2816
2547
|
handleOnClickSubmitForms(e) {
|
|
2817
|
-
console.log(e);
|
|
2818
2548
|
if (this.userConfig.userFormFieldsConfig.validation) {
|
|
2819
|
-
const validations = new
|
|
2549
|
+
const validations = new Validation({
|
|
2820
2550
|
USER_CONFIG: this.userConfig,
|
|
2821
2551
|
ALL_FORMS_DATA: this.formsData
|
|
2822
2552
|
}, this.takeAction.bind(this));
|
|
@@ -2867,7 +2597,7 @@ class KwikIDFormsRendererComponent {
|
|
|
2867
2597
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2868
2598
|
switch (action.key) {
|
|
2869
2599
|
case EActionKey.SET_VALUE:
|
|
2870
|
-
const sources = new
|
|
2600
|
+
const sources = new Source({
|
|
2871
2601
|
USER_CONFIG: this.userConfig,
|
|
2872
2602
|
ALL_FORMS_DATA: this.formsData
|
|
2873
2603
|
});
|
|
@@ -2956,7 +2686,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
2956
2686
|
class KwikIDFormViewModule {
|
|
2957
2687
|
}
|
|
2958
2688
|
/** @nocollapse */ KwikIDFormViewModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: KwikIDFormViewModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2959
|
-
/** @nocollapse */ KwikIDFormViewModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: KwikIDFormViewModule, declarations: [KwikIDFormViewComponent], imports: [CommonModule,
|
|
2689
|
+
/** @nocollapse */ KwikIDFormViewModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: KwikIDFormViewModule, declarations: [KwikIDFormViewComponent, SafeHtmlPipe], imports: [CommonModule,
|
|
2960
2690
|
FormsModule,
|
|
2961
2691
|
ReactiveFormsModule,
|
|
2962
2692
|
TuiLabelModule,
|
|
@@ -2975,7 +2705,7 @@ class KwikIDFormViewModule {
|
|
|
2975
2705
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: KwikIDFormViewModule, decorators: [{
|
|
2976
2706
|
type: NgModule,
|
|
2977
2707
|
args: [{
|
|
2978
|
-
declarations: [KwikIDFormViewComponent],
|
|
2708
|
+
declarations: [KwikIDFormViewComponent, SafeHtmlPipe],
|
|
2979
2709
|
imports: [
|
|
2980
2710
|
CommonModule,
|
|
2981
2711
|
FormsModule,
|