kwikid-forms 0.1.3 → 0.1.5
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 +322 -936
- package/bundles/kwikid-forms.umd.js.map +1 -1
- package/esm2015/lib/renderer/form-view/definitions/apis/form-view.apis.type.definitions.js +1 -1
- package/esm2015/lib/renderer/form-view/definitions/fields/form-view.fields.type.definitions.js +1 -1
- package/esm2015/lib/renderer/form-view/definitions/sources/form-view.sources.type.definitions.js +1 -1
- package/esm2015/lib/renderer/form-view/definitions/validations/form-view.validations.type.definitions.js +1 -1
- package/esm2015/lib/renderer/form-view/form-view.component.js +81 -55
- package/esm2015/lib/renderer/form-view/helpers/form-view.apis.helper.js +48 -16
- package/esm2015/lib/renderer/form-view/helpers/form-view.defaults.helper.js +20 -9
- package/esm2015/lib/renderer/form-view/helpers/form-view.fields.helper.js +7 -7
- package/esm2015/lib/renderer/form-view/helpers/form-view.validations.helper.js +33 -27
- package/esm2015/lib/renderer/forms-list/forms-list.component.js +4 -5
- package/esm2015/lib/renderer/renderer.component.js +27 -12
- package/esm2015/lib/renderer/renderer.config-converter.helper.js +60 -58
- package/esm2015/lib/renderer/renderer.service.js +4 -5
- package/fesm2015/kwikid-forms.js +285 -770
- package/fesm2015/kwikid-forms.js.map +1 -1
- package/lib/renderer/form-view/definitions/apis/form-view.apis.type.definitions.d.ts +1 -1
- package/lib/renderer/form-view/definitions/fields/form-view.fields.type.definitions.d.ts +1 -2
- package/lib/renderer/form-view/definitions/sources/form-view.sources.type.definitions.d.ts +2 -2
- package/lib/renderer/form-view/definitions/validations/form-view.validations.type.definitions.d.ts +1 -2
- package/lib/renderer/form-view/form-view.component.d.ts +2 -2
- package/lib/renderer/renderer.component.d.ts +2 -1
- package/package.json +3 -3
- package/esm2015/lib/renderer/form-view/definitions/rules/form-view.rules.enum.definitions.js +0 -7
- package/esm2015/lib/renderer/form-view/definitions/rules/form-view.rules.type.definitions.js +0 -2
- package/esm2015/lib/renderer/form-view/definitions/sources/form-view.sources.enum.definitions.js +0 -17
- package/esm2015/lib/renderer/form-view/helpers/form-view.actions.helper.js +0 -27
- package/esm2015/lib/renderer/form-view/helpers/form-view.condition.helper.js +0 -46
- package/esm2015/lib/renderer/form-view/helpers/form-view.rules.helper.js +0 -83
- package/esm2015/lib/renderer/form-view/helpers/form-view.sources.helper.js +0 -161
- package/esm2015/lib/renderer/forms-list/forms-list.helper.js +0 -4
- package/esm2015/lib/renderer/helpers/renderer.actions.helper.js +0 -21
- package/esm2015/lib/renderer/helpers/renderer.condition.helper.js +0 -41
- package/esm2015/lib/renderer/helpers/renderer.rules.helper.js +0 -64
- package/esm2015/lib/renderer/helpers/renderer.sources.helper.js +0 -117
- package/esm2015/lib/renderer/helpers/renderer.validations.helper.js +0 -40
- package/lib/renderer/form-view/definitions/rules/form-view.rules.enum.definitions.d.ts +0 -5
- package/lib/renderer/form-view/definitions/rules/form-view.rules.type.definitions.d.ts +0 -41
- package/lib/renderer/form-view/definitions/sources/form-view.sources.enum.definitions.d.ts +0 -14
- package/lib/renderer/form-view/helpers/form-view.actions.helper.d.ts +0 -13
- package/lib/renderer/form-view/helpers/form-view.condition.helper.d.ts +0 -8
- package/lib/renderer/form-view/helpers/form-view.rules.helper.d.ts +0 -12
- package/lib/renderer/form-view/helpers/form-view.sources.helper.d.ts +0 -29
- package/lib/renderer/forms-list/forms-list.helper.d.ts +0 -1
- package/lib/renderer/helpers/renderer.actions.helper.d.ts +0 -9
- package/lib/renderer/helpers/renderer.condition.helper.d.ts +0 -8
- package/lib/renderer/helpers/renderer.rules.helper.d.ts +0 -9
- package/lib/renderer/helpers/renderer.sources.helper.d.ts +0 -18
- package/lib/renderer/helpers/renderer.validations.helper.d.ts +0 -11
package/fesm2015/kwikid-forms.js
CHANGED
|
@@ -6,12 +6,12 @@ import { FormGroup, FormControl, Validators, FormArray, FormsModule, ReactiveFor
|
|
|
6
6
|
import * as i2 from 'kwikui';
|
|
7
7
|
import { KwikUIButtonComponent, KwikUIProgressSegmentedComponent, KwikUIInputComponent, KwikUIModule } from 'kwikui';
|
|
8
8
|
import _, { cloneDeep } from 'lodash';
|
|
9
|
-
import {
|
|
10
|
-
import { logMethod } from 'kwikid-toolkit';
|
|
9
|
+
import { __awaiter, __decorate } from 'tslib';
|
|
11
10
|
import * as i3 from '@taiga-ui/core';
|
|
12
11
|
import { TuiAlertService, TuiLabelModule, TuiSvgModule, TuiLoaderModule } from '@taiga-ui/core';
|
|
13
12
|
import * as i4 from '@taiga-ui/kit';
|
|
14
13
|
import { TuiPushService, TuiPushModule } from '@taiga-ui/kit';
|
|
14
|
+
import { Sources, Rules, Condition, Actions, logMethod, isNotEmptyValue, checkObjectKeyExists, isEmptyValue, Validations as Validations$1 } from 'kwikid-toolkit';
|
|
15
15
|
import { pairwise } from 'rxjs/operators';
|
|
16
16
|
import jp from 'jsonpath';
|
|
17
17
|
import { TuiDay } from '@taiga-ui/cdk';
|
|
@@ -296,7 +296,7 @@ var EFieldType;
|
|
|
296
296
|
EFieldType["AADHAAR_NUMBER"] = "aadhaar-number";
|
|
297
297
|
})(EFieldType || (EFieldType = {}));
|
|
298
298
|
|
|
299
|
-
const hasKey$
|
|
299
|
+
const hasKey$1 = (object, key) => {
|
|
300
300
|
return object.hasOwnProperty(key);
|
|
301
301
|
};
|
|
302
302
|
const isEmpty$1 = (value) => {
|
|
@@ -345,7 +345,7 @@ const isSingleForm = (formsList) => {
|
|
|
345
345
|
return formsList.length === 1;
|
|
346
346
|
};
|
|
347
347
|
|
|
348
|
-
const hasKey
|
|
348
|
+
const hasKey = (object, key) => {
|
|
349
349
|
return object.hasOwnProperty(key);
|
|
350
350
|
};
|
|
351
351
|
const hasPath = (object, path) => {
|
|
@@ -477,330 +477,6 @@ const setEmptyValue = (field) => {
|
|
|
477
477
|
return value;
|
|
478
478
|
};
|
|
479
479
|
|
|
480
|
-
class Condition$1 {
|
|
481
|
-
constructor(condition, rulesMapping) {
|
|
482
|
-
this._condition = condition;
|
|
483
|
-
this._rulesMapping = rulesMapping;
|
|
484
|
-
}
|
|
485
|
-
parseKeys(condition, rulesEvaluationMapping) {
|
|
486
|
-
Object.keys(rulesEvaluationMapping).forEach((key) => {
|
|
487
|
-
condition = replaceString(condition, key, rulesEvaluationMapping[key]);
|
|
488
|
-
});
|
|
489
|
-
return condition;
|
|
490
|
-
}
|
|
491
|
-
parseOperators(condition) {
|
|
492
|
-
return condition.replace(/AND|OR|NOT|XOR|NAND|NOR|XNOR/g, (match) => {
|
|
493
|
-
switch (match) {
|
|
494
|
-
case "AND":
|
|
495
|
-
return "&&";
|
|
496
|
-
case "OR":
|
|
497
|
-
return "||";
|
|
498
|
-
case "NOT":
|
|
499
|
-
return "!";
|
|
500
|
-
case "XOR":
|
|
501
|
-
return "^";
|
|
502
|
-
case "NAND":
|
|
503
|
-
return "!&";
|
|
504
|
-
case "NOR":
|
|
505
|
-
return "!|";
|
|
506
|
-
case "XNOR":
|
|
507
|
-
return "!^";
|
|
508
|
-
default:
|
|
509
|
-
return match;
|
|
510
|
-
}
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
evaluate() {
|
|
514
|
-
this._condition = this.parseKeys(this._condition, this._rulesMapping);
|
|
515
|
-
this._condition = this.parseOperators(this._condition);
|
|
516
|
-
return eval(this._condition);
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
__decorate([
|
|
520
|
-
logMethod
|
|
521
|
-
], Condition$1.prototype, "evaluate", null);
|
|
522
|
-
|
|
523
|
-
class Actions$1 {
|
|
524
|
-
constructor(action, field, ruleMapping, allFormsData, formData, previousFormData, takeAction) {
|
|
525
|
-
this._action = action;
|
|
526
|
-
this._field = field;
|
|
527
|
-
this._ruleMapping = ruleMapping;
|
|
528
|
-
this._allFormsData = allFormsData;
|
|
529
|
-
this._formData = formData;
|
|
530
|
-
this._previousFormData = previousFormData;
|
|
531
|
-
this._takeAction = takeAction;
|
|
532
|
-
}
|
|
533
|
-
execute() {
|
|
534
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
535
|
-
const condition = new Condition$1(this._action.condition, this._ruleMapping);
|
|
536
|
-
const actionSuccess = condition.evaluate();
|
|
537
|
-
if (actionSuccess) {
|
|
538
|
-
return this._takeAction(this._action, this._field, this._allFormsData, this._formData, this._previousFormData);
|
|
539
|
-
}
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
__decorate([
|
|
544
|
-
logMethod
|
|
545
|
-
], Actions$1.prototype, "execute", null);
|
|
546
|
-
|
|
547
|
-
var ERuleKey;
|
|
548
|
-
(function (ERuleKey) {
|
|
549
|
-
ERuleKey["OBJECT_PATH_EXISTS"] = "OBJECT_PATH_EXISTS";
|
|
550
|
-
ERuleKey["VALUE_CHECK"] = "VALUE_CHECK";
|
|
551
|
-
ERuleKey["VALUE_CHANGE"] = "VALUE_CHANGE";
|
|
552
|
-
})(ERuleKey || (ERuleKey = {}));
|
|
553
|
-
|
|
554
|
-
var ESourceKey;
|
|
555
|
-
(function (ESourceKey) {
|
|
556
|
-
ESourceKey["FIELD_CONFIG"] = "FIELD_CONFIG";
|
|
557
|
-
ESourceKey["FORM_DATA"] = "FORM_DATA";
|
|
558
|
-
ESourceKey["PREVIOUS_FORM_DATA"] = "PREVIOUS_FORM_DATA";
|
|
559
|
-
ESourceKey["ALL_FORMS_DATA"] = "ALL_FORMS_DATA";
|
|
560
|
-
ESourceKey["BROWSER_STORAGE"] = "BROWSER_STORAGE";
|
|
561
|
-
ESourceKey["PREDEFINED"] = "PREDEFINED";
|
|
562
|
-
ESourceKey["USER_CONFIG"] = "USER_CONFIG";
|
|
563
|
-
ESourceKey["CUSTOM"] = "CUSTOM";
|
|
564
|
-
})(ESourceKey || (ESourceKey = {}));
|
|
565
|
-
var EBrowserStorageType;
|
|
566
|
-
(function (EBrowserStorageType) {
|
|
567
|
-
EBrowserStorageType["LOCAL_STORAGE"] = "LOCAL_STORAGE";
|
|
568
|
-
EBrowserStorageType["SESSION_STORAGE"] = "SESSION_STORAGE";
|
|
569
|
-
})(EBrowserStorageType || (EBrowserStorageType = {}));
|
|
570
|
-
|
|
571
|
-
class Sources$1 {
|
|
572
|
-
constructor(field, formData, previousFormData, allFormsData) {
|
|
573
|
-
this._field = field;
|
|
574
|
-
this._formData = formData;
|
|
575
|
-
this._previousFormData = previousFormData;
|
|
576
|
-
this._allFormsData = allFormsData;
|
|
577
|
-
}
|
|
578
|
-
get formData() {
|
|
579
|
-
return this._formData;
|
|
580
|
-
}
|
|
581
|
-
set formData(value) {
|
|
582
|
-
this._formData = value;
|
|
583
|
-
}
|
|
584
|
-
get previousFormData() {
|
|
585
|
-
return this._previousFormData;
|
|
586
|
-
}
|
|
587
|
-
set previousFormData(value) {
|
|
588
|
-
this._previousFormData = value;
|
|
589
|
-
}
|
|
590
|
-
get allFormsData() {
|
|
591
|
-
return this._allFormsData;
|
|
592
|
-
}
|
|
593
|
-
set allFormsData(value) {
|
|
594
|
-
this._allFormsData = value;
|
|
595
|
-
}
|
|
596
|
-
get field() {
|
|
597
|
-
return this._field;
|
|
598
|
-
}
|
|
599
|
-
set field(value) {
|
|
600
|
-
this._field = value;
|
|
601
|
-
}
|
|
602
|
-
getValueFromFieldConfig(path) {
|
|
603
|
-
let value = "";
|
|
604
|
-
if (isNotEmpty(path)) {
|
|
605
|
-
value = jpQueryWrapper(this._field, path);
|
|
606
|
-
}
|
|
607
|
-
else {
|
|
608
|
-
value = setEmptyValue(this._field);
|
|
609
|
-
}
|
|
610
|
-
return value;
|
|
611
|
-
}
|
|
612
|
-
getValueFromFormData(path) {
|
|
613
|
-
let value;
|
|
614
|
-
value = jpQueryWrapper(this._formData, path);
|
|
615
|
-
return value;
|
|
616
|
-
}
|
|
617
|
-
getValueFromPreviousFormData(path) {
|
|
618
|
-
let value;
|
|
619
|
-
value = jpQueryWrapper(this._previousFormData, path);
|
|
620
|
-
return value;
|
|
621
|
-
}
|
|
622
|
-
getValueFromAllFormsData(path) {
|
|
623
|
-
let value;
|
|
624
|
-
value = jpQueryWrapper(this._allFormsData, path);
|
|
625
|
-
return value;
|
|
626
|
-
}
|
|
627
|
-
getValueFromBrowserStorage(type, key) {
|
|
628
|
-
let value = "";
|
|
629
|
-
switch (type) {
|
|
630
|
-
case EBrowserStorageType.LOCAL_STORAGE:
|
|
631
|
-
value = isNotEmptyBrowserStorageValue(localStorage.getItem(key))
|
|
632
|
-
? localStorage.getItem(key)
|
|
633
|
-
: "";
|
|
634
|
-
break;
|
|
635
|
-
case EBrowserStorageType.SESSION_STORAGE:
|
|
636
|
-
value = isNotEmptyBrowserStorageValue(sessionStorage.getItem(key))
|
|
637
|
-
? sessionStorage.getItem(key)
|
|
638
|
-
: "";
|
|
639
|
-
break;
|
|
640
|
-
default:
|
|
641
|
-
value = "";
|
|
642
|
-
break;
|
|
643
|
-
}
|
|
644
|
-
return value;
|
|
645
|
-
}
|
|
646
|
-
getValueFromSource(source) {
|
|
647
|
-
let value = "";
|
|
648
|
-
switch (source.key) {
|
|
649
|
-
case ESourceKey.FIELD_CONFIG:
|
|
650
|
-
value = this.getValueFromFieldConfig(source.props.path);
|
|
651
|
-
break;
|
|
652
|
-
case ESourceKey.FORM_DATA:
|
|
653
|
-
value = this.getValueFromFormData(source.props.path);
|
|
654
|
-
break;
|
|
655
|
-
case ESourceKey.ALL_FORMS_DATA:
|
|
656
|
-
value = this.getValueFromAllFormsData(source.props.path);
|
|
657
|
-
break;
|
|
658
|
-
case ESourceKey.PREVIOUS_FORM_DATA:
|
|
659
|
-
value = this.getValueFromPreviousFormData(source.props.path);
|
|
660
|
-
break;
|
|
661
|
-
case ESourceKey.BROWSER_STORAGE:
|
|
662
|
-
value = this.getValueFromBrowserStorage(source.props.browserStorage.type, source.props.browserStorage.key);
|
|
663
|
-
break;
|
|
664
|
-
case ESourceKey.PREDEFINED:
|
|
665
|
-
value = source.value;
|
|
666
|
-
break;
|
|
667
|
-
default:
|
|
668
|
-
value = "";
|
|
669
|
-
break;
|
|
670
|
-
}
|
|
671
|
-
return value;
|
|
672
|
-
}
|
|
673
|
-
setValueToFieldConfig(path, value) {
|
|
674
|
-
this._field = setValueToObject(this._field, path, value);
|
|
675
|
-
}
|
|
676
|
-
setValueToFormData(path, value) {
|
|
677
|
-
this._formData = setValueToObject(this._formData, path, value);
|
|
678
|
-
}
|
|
679
|
-
setValueToAllFormsData(path, value) {
|
|
680
|
-
this._allFormsData = setValueToObject(this._allFormsData, path, value);
|
|
681
|
-
}
|
|
682
|
-
setValueToPreviousFromData(path, value) {
|
|
683
|
-
this._previousFormData = setValueToObject(this._previousFormData, path, value);
|
|
684
|
-
}
|
|
685
|
-
setValueToBrowserStorage(type, key, value) {
|
|
686
|
-
switch (type) {
|
|
687
|
-
case EBrowserStorageType.LOCAL_STORAGE:
|
|
688
|
-
localStorage.setItem(key, value);
|
|
689
|
-
break;
|
|
690
|
-
case EBrowserStorageType.SESSION_STORAGE:
|
|
691
|
-
sessionStorage.setItem(key, value);
|
|
692
|
-
break;
|
|
693
|
-
default:
|
|
694
|
-
break;
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
setValueToSource(source, value) {
|
|
698
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
699
|
-
switch (source.key) {
|
|
700
|
-
case ESourceKey.FIELD_CONFIG:
|
|
701
|
-
this._field = this.setValueToFieldConfig(source.props.path, value);
|
|
702
|
-
break;
|
|
703
|
-
case ESourceKey.FORM_DATA:
|
|
704
|
-
this._formData = this.setValueToFormData(source.props.path, value);
|
|
705
|
-
break;
|
|
706
|
-
case ESourceKey.ALL_FORMS_DATA:
|
|
707
|
-
this._allFormsData = this.setValueToAllFormsData(source.props.path, value);
|
|
708
|
-
break;
|
|
709
|
-
case ESourceKey.PREVIOUS_FORM_DATA:
|
|
710
|
-
this._previousFormData = this.setValueToPreviousFromData(source.props.path, value);
|
|
711
|
-
break;
|
|
712
|
-
case ESourceKey.BROWSER_STORAGE:
|
|
713
|
-
yield this.setValueToBrowserStorage(source.props.browserStorage.type, source.props.browserStorage.key, value);
|
|
714
|
-
break;
|
|
715
|
-
default:
|
|
716
|
-
break;
|
|
717
|
-
}
|
|
718
|
-
});
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
__decorate([
|
|
722
|
-
logMethod
|
|
723
|
-
], Sources$1.prototype, "getValueFromSource", null);
|
|
724
|
-
__decorate([
|
|
725
|
-
logMethod
|
|
726
|
-
], Sources$1.prototype, "setValueToSource", null);
|
|
727
|
-
|
|
728
|
-
class Rules$1 {
|
|
729
|
-
constructor(rules, field, formData, previousFormData, allFormsData) {
|
|
730
|
-
this._field = field;
|
|
731
|
-
this._formData = formData;
|
|
732
|
-
this._previousFormData = previousFormData;
|
|
733
|
-
this._allFormsData = allFormsData;
|
|
734
|
-
this._rules = rules;
|
|
735
|
-
}
|
|
736
|
-
evaluate(rule) {
|
|
737
|
-
let ruleType = rule.key;
|
|
738
|
-
let ruleEvaluationStatus = false;
|
|
739
|
-
const source = new Sources$1(this._field, this._formData, this._previousFormData, this._allFormsData);
|
|
740
|
-
switch (ruleType) {
|
|
741
|
-
case ERuleKey.OBJECT_PATH_EXISTS:
|
|
742
|
-
const ruleObjectPathExists = rule;
|
|
743
|
-
const ruleObjectPathExistsObject = ruleObjectPathExists.props.object;
|
|
744
|
-
const ruleObjectPathExistsPath = ruleObjectPathExists.props.path;
|
|
745
|
-
switch (ruleObjectPathExistsObject) {
|
|
746
|
-
case ESourceKey.ALL_FORMS_DATA:
|
|
747
|
-
ruleEvaluationStatus = hasPath(this._allFormsData, ruleObjectPathExistsPath);
|
|
748
|
-
break;
|
|
749
|
-
case ESourceKey.FORM_DATA:
|
|
750
|
-
ruleEvaluationStatus = hasPath(this._formData, ruleObjectPathExistsPath);
|
|
751
|
-
break;
|
|
752
|
-
case ESourceKey.PREVIOUS_FORM_DATA:
|
|
753
|
-
ruleEvaluationStatus = hasPath(this._previousFormData, ruleObjectPathExistsPath);
|
|
754
|
-
break;
|
|
755
|
-
case ESourceKey.FIELD_CONFIG:
|
|
756
|
-
ruleEvaluationStatus = hasPath(this._field, ruleObjectPathExistsPath);
|
|
757
|
-
break;
|
|
758
|
-
default:
|
|
759
|
-
ruleEvaluationStatus = false;
|
|
760
|
-
break;
|
|
761
|
-
}
|
|
762
|
-
break;
|
|
763
|
-
case ERuleKey.VALUE_CHECK:
|
|
764
|
-
const ruleValueCheck = rule;
|
|
765
|
-
const ruleValueCheckSource = ruleValueCheck.props.value.source;
|
|
766
|
-
const ruleValueCheckValue = source.getValueFromSource(ruleValueCheckSource);
|
|
767
|
-
if (ruleValueCheck.props.pattern.key === EPatternKey.CUSTOM) {
|
|
768
|
-
var re = new RegExp(ruleValueCheck.props.pattern.pattern);
|
|
769
|
-
}
|
|
770
|
-
else {
|
|
771
|
-
var re = new RegExp(EPattern[ruleValueCheck.props.pattern.key]);
|
|
772
|
-
}
|
|
773
|
-
ruleEvaluationStatus = re.test(ruleValueCheckValue);
|
|
774
|
-
break;
|
|
775
|
-
case ERuleKey.VALUE_CHANGE:
|
|
776
|
-
const ruleValueChange = rule;
|
|
777
|
-
const ruleValueChangeCurrentSource = ruleValueChange.props.value.current.source;
|
|
778
|
-
const ruleValueChangePreviousSource = ruleValueChange.props.value.previous.source;
|
|
779
|
-
const previousValue = source.getValueFromSource(ruleValueChangePreviousSource);
|
|
780
|
-
const currentValue = source.getValueFromSource(ruleValueChangeCurrentSource);
|
|
781
|
-
ruleEvaluationStatus = previousValue === currentValue;
|
|
782
|
-
break;
|
|
783
|
-
default:
|
|
784
|
-
break;
|
|
785
|
-
}
|
|
786
|
-
return ruleEvaluationStatus;
|
|
787
|
-
}
|
|
788
|
-
mapping() {
|
|
789
|
-
let rulesEvaluationMapping = {};
|
|
790
|
-
for (const rule of this._rules) {
|
|
791
|
-
const ruleEvaluationStatus = this.evaluate(rule);
|
|
792
|
-
rulesEvaluationMapping = Object.assign(Object.assign({}, rulesEvaluationMapping), { [rule.id]: ruleEvaluationStatus });
|
|
793
|
-
}
|
|
794
|
-
return rulesEvaluationMapping;
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
__decorate([
|
|
798
|
-
logMethod
|
|
799
|
-
], Rules$1.prototype, "evaluate", null);
|
|
800
|
-
__decorate([
|
|
801
|
-
logMethod
|
|
802
|
-
], Rules$1.prototype, "mapping", null);
|
|
803
|
-
|
|
804
480
|
class Defaults {
|
|
805
481
|
constructor(field, allFormsData, formData, previousFormData, takeAction) {
|
|
806
482
|
this._field = field;
|
|
@@ -815,7 +491,12 @@ class Defaults {
|
|
|
815
491
|
const sources = this._field.default.value.sources;
|
|
816
492
|
let sourceIndex = 0;
|
|
817
493
|
for (let source of sources) {
|
|
818
|
-
const sources = new 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
|
+
});
|
|
819
500
|
const value = sources.getValueFromSource(source);
|
|
820
501
|
// Set the Value of current source.
|
|
821
502
|
this._field = setValueToObject(this._field, `default.value.sources.[${sourceIndex}].value`, value);
|
|
@@ -823,11 +504,21 @@ class Defaults {
|
|
|
823
504
|
const triggers = validation.triggers;
|
|
824
505
|
const rules = validation.rules;
|
|
825
506
|
const actions = validation.actions;
|
|
826
|
-
const rulesMapping = new Rules
|
|
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();
|
|
827
513
|
for (let action of actions) {
|
|
828
|
-
const conditionEvaluation = new Condition
|
|
514
|
+
const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
|
|
829
515
|
if (conditionEvaluation) {
|
|
830
|
-
const actions = new Actions
|
|
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);
|
|
831
522
|
yield actions.execute();
|
|
832
523
|
}
|
|
833
524
|
}
|
|
@@ -883,7 +574,7 @@ const getSearchTextOptionsFromRemoteFile = (field, childField, formGroup) => __a
|
|
|
883
574
|
const getSearchTextOptionsFromFieldConfig = (field, childField, formGroup) => {
|
|
884
575
|
let options;
|
|
885
576
|
const fieldValue = formGroup.controls[field.key].value;
|
|
886
|
-
if (
|
|
577
|
+
if (isNotEmptyValue(childField["json"])) {
|
|
887
578
|
options = childField["json"][fieldValue];
|
|
888
579
|
}
|
|
889
580
|
return options;
|
|
@@ -912,7 +603,7 @@ const addMessage = (field, message) => {
|
|
|
912
603
|
});
|
|
913
604
|
};
|
|
914
605
|
field["messages"] = [];
|
|
915
|
-
if (
|
|
606
|
+
if (checkObjectKeyExists(field, "messages")) {
|
|
916
607
|
if (!isDuplicateMessage(field["messages"], message)) {
|
|
917
608
|
field["messages"].push({
|
|
918
609
|
type: message.type,
|
|
@@ -1006,7 +697,7 @@ const convertTuiDayFormatToDateString = (date) => {
|
|
|
1006
697
|
};
|
|
1007
698
|
const convertValueFromKwikUIFormatToBasicFormat = (field, value) => {
|
|
1008
699
|
let convertedValue = value;
|
|
1009
|
-
if (
|
|
700
|
+
if (isNotEmptyValue(value)) {
|
|
1010
701
|
switch (field.type) {
|
|
1011
702
|
case EFieldType.DATE:
|
|
1012
703
|
convertedValue = convertTuiDayFormatToDateString(value);
|
|
@@ -1021,10 +712,10 @@ const convertValueFromKwikUIFormatToBasicFormat = (field, value) => {
|
|
|
1021
712
|
};
|
|
1022
713
|
const convertValueFromBasicFormatToKwikUIFormat = (field, value) => {
|
|
1023
714
|
let convertedValue = value;
|
|
1024
|
-
if (
|
|
715
|
+
if (isNotEmptyValue(value)) {
|
|
1025
716
|
switch (field.type) {
|
|
1026
717
|
case EFieldType.RADIO:
|
|
1027
|
-
if (!
|
|
718
|
+
if (!checkObjectKeyExists(value, "label")) {
|
|
1028
719
|
const convertedLabelValue = {
|
|
1029
720
|
label: value,
|
|
1030
721
|
disabled: false
|
|
@@ -1044,7 +735,7 @@ const convertValueFromBasicFormatToKwikUIFormat = (field, value) => {
|
|
|
1044
735
|
return convertedValue;
|
|
1045
736
|
};
|
|
1046
737
|
|
|
1047
|
-
class Validations
|
|
738
|
+
class Validations {
|
|
1048
739
|
constructor(field, formData, previousFormData, allFormsData, takeAction) {
|
|
1049
740
|
this._field = field;
|
|
1050
741
|
this._formData = formData;
|
|
@@ -1078,36 +769,36 @@ class Validations$1 {
|
|
|
1078
769
|
}
|
|
1079
770
|
getFieldValidators(field) {
|
|
1080
771
|
let validators = [];
|
|
1081
|
-
if (
|
|
1082
|
-
|
|
1083
|
-
|
|
772
|
+
if (checkObjectKeyExists(field, "validators") &&
|
|
773
|
+
checkObjectKeyExists(field.validators, "min") &&
|
|
774
|
+
isNotEmptyValue(field.validators.min)) {
|
|
1084
775
|
validators.push(Validators.min(field.validators.min));
|
|
1085
776
|
}
|
|
1086
|
-
if (
|
|
1087
|
-
|
|
1088
|
-
|
|
777
|
+
if (checkObjectKeyExists(field, "validators") &&
|
|
778
|
+
checkObjectKeyExists(field.validators, "max") &&
|
|
779
|
+
isNotEmptyValue(field.validators.max)) {
|
|
1089
780
|
validators.push(Validators.max(field.validators.max));
|
|
1090
781
|
}
|
|
1091
|
-
if ((
|
|
1092
|
-
(
|
|
1093
|
-
|
|
782
|
+
if ((checkObjectKeyExists(field, "required") && field.required) ||
|
|
783
|
+
(checkObjectKeyExists(field, "validators") &&
|
|
784
|
+
checkObjectKeyExists(field.validators, "required") &&
|
|
1094
785
|
field.validators.required)) {
|
|
1095
786
|
validators.push(Validators.required);
|
|
1096
787
|
}
|
|
1097
|
-
if (
|
|
1098
|
-
|
|
1099
|
-
|
|
788
|
+
if (checkObjectKeyExists(field, "validators") &&
|
|
789
|
+
checkObjectKeyExists(field.validators, "minLength") &&
|
|
790
|
+
isNotEmptyValue(field.validators.minLength)) {
|
|
1100
791
|
validators.push(Validators.minLength(field.validators.minLength));
|
|
1101
792
|
}
|
|
1102
|
-
if (
|
|
1103
|
-
|
|
1104
|
-
|
|
793
|
+
if (checkObjectKeyExists(field, "validators") &&
|
|
794
|
+
checkObjectKeyExists(field.validators, "maxLength") &&
|
|
795
|
+
isNotEmptyValue(field.validators.maxLength)) {
|
|
1105
796
|
validators.push(Validators.maxLength(field.validators.maxLength));
|
|
1106
797
|
}
|
|
1107
|
-
if (
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
if (
|
|
798
|
+
if (checkObjectKeyExists(field, "validators") &&
|
|
799
|
+
checkObjectKeyExists(field.validators, "pattern") &&
|
|
800
|
+
isNotEmptyValue(field.validators.pattern)) {
|
|
801
|
+
if (checkObjectKeyExists(field.validators.pattern, "key")) {
|
|
1111
802
|
if (field.validators.pattern.key === EPatternKey.CUSTOM) {
|
|
1112
803
|
validators.push(Validators.pattern(field.validators.pattern.pattern));
|
|
1113
804
|
}
|
|
@@ -1167,11 +858,21 @@ class Validations$1 {
|
|
|
1167
858
|
const triggers = validations.triggers;
|
|
1168
859
|
const rules = validations.rules;
|
|
1169
860
|
const actions = validations.actions;
|
|
1170
|
-
const rulesMapping = new Rules
|
|
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();
|
|
1171
867
|
for (let action of actions) {
|
|
1172
|
-
const conditionEvaluation = new Condition
|
|
868
|
+
const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
|
|
1173
869
|
if (conditionEvaluation) {
|
|
1174
|
-
const actions = new Actions
|
|
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);
|
|
1175
876
|
yield actions.execute();
|
|
1176
877
|
}
|
|
1177
878
|
}
|
|
@@ -1180,16 +881,16 @@ class Validations$1 {
|
|
|
1180
881
|
}
|
|
1181
882
|
__decorate([
|
|
1182
883
|
logMethod
|
|
1183
|
-
], Validations
|
|
884
|
+
], Validations.prototype, "getFieldValidators", null);
|
|
1184
885
|
__decorate([
|
|
1185
886
|
logMethod
|
|
1186
|
-
], Validations
|
|
887
|
+
], Validations.prototype, "getFormValidationErrors", null);
|
|
1187
888
|
__decorate([
|
|
1188
889
|
logMethod
|
|
1189
|
-
], Validations
|
|
890
|
+
], Validations.prototype, "findInvalidControlsRecursive", null);
|
|
1190
891
|
__decorate([
|
|
1191
892
|
logMethod
|
|
1192
|
-
], Validations
|
|
893
|
+
], Validations.prototype, "validateField", null);
|
|
1193
894
|
|
|
1194
895
|
class KwikIDFormViewService {
|
|
1195
896
|
constructor() { }
|
|
@@ -1202,7 +903,7 @@ class KwikIDFormViewService {
|
|
|
1202
903
|
const defaults = new Defaults(field, allFormsData, formData, previousFormData, takeAction);
|
|
1203
904
|
let value = yield defaults.getDefaultValue();
|
|
1204
905
|
value = convertValueFromBasicFormatToKwikUIFormat(field, value);
|
|
1205
|
-
const validators = new Validations
|
|
906
|
+
const validators = new Validations(field, formData, previousFormData, allFormsData, takeAction).getFieldValidators(field);
|
|
1206
907
|
formGroup.addControl(field.key, new FormControl({ value: value, disabled: field.disabled }, { validators: validators }));
|
|
1207
908
|
}
|
|
1208
909
|
}
|
|
@@ -1227,7 +928,7 @@ class Apis {
|
|
|
1227
928
|
this._status = field.api.status;
|
|
1228
929
|
}
|
|
1229
930
|
setRequestBodyParams() {
|
|
1230
|
-
var _a, _b, _c;
|
|
931
|
+
var _a, _b, _c, _d;
|
|
1231
932
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1232
933
|
let params = this._request.body.params;
|
|
1233
934
|
let paramIndex = 0;
|
|
@@ -1235,19 +936,34 @@ class Apis {
|
|
|
1235
936
|
let sources = param.sources;
|
|
1236
937
|
let sourceIndex = 0;
|
|
1237
938
|
for (let source of sources) {
|
|
1238
|
-
const sources = new Sources
|
|
939
|
+
const sources = new Sources({
|
|
940
|
+
FIELD_CONFIG: this._field,
|
|
941
|
+
FORM_DATA: this._formData,
|
|
942
|
+
PREVIOUS_FORM_DATA: this._previousFormData,
|
|
943
|
+
ALL_FORMS_DATA: this._allFormsData
|
|
944
|
+
});
|
|
1239
945
|
const value = sources.getValueFromSource(source);
|
|
1240
946
|
// Set the Value of current source.
|
|
1241
947
|
this._field = setValueToObject(this._field, `api.request.body.params[${paramIndex}].sources[${sourceIndex}].value`, value);
|
|
1242
948
|
const validation = source.validation;
|
|
1243
949
|
const triggers = (_a = validation === null || validation === void 0 ? void 0 : validation.triggers) !== null && _a !== void 0 ? _a : [];
|
|
1244
950
|
const rules = (_b = validation === null || validation === void 0 ? void 0 : validation.rules) !== null && _b !== void 0 ? _b : [];
|
|
1245
|
-
const actions = (_c = validation === null ||
|
|
1246
|
-
const rulesMapping = new Rules
|
|
951
|
+
const actions = (_d = (_c = validation) === null || _c === void 0 ? void 0 : _c.actions) !== null && _d !== void 0 ? _d : [];
|
|
952
|
+
const rulesMapping = new Rules(rules, {
|
|
953
|
+
FIELD_CONFIG: this._field,
|
|
954
|
+
FORM_DATA: this._formData,
|
|
955
|
+
PREVIOUS_FORM_DATA: this._previousFormData,
|
|
956
|
+
ALL_FORMS_DATA: this._allFormsData
|
|
957
|
+
}).mapping();
|
|
1247
958
|
for (let action of actions) {
|
|
1248
|
-
const conditionEvaluation = new Condition
|
|
959
|
+
const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
|
|
1249
960
|
if (conditionEvaluation) {
|
|
1250
|
-
const actions = new Actions
|
|
961
|
+
const actions = new Actions(action, rulesMapping, {
|
|
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);
|
|
1251
967
|
yield actions.execute();
|
|
1252
968
|
}
|
|
1253
969
|
}
|
|
@@ -1259,17 +975,28 @@ class Apis {
|
|
|
1259
975
|
});
|
|
1260
976
|
}
|
|
1261
977
|
validateRequestBody() {
|
|
978
|
+
var _a;
|
|
1262
979
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1263
980
|
const body = this._request.body;
|
|
1264
981
|
const validation = body.validation;
|
|
1265
982
|
const triggers = validation.triggers;
|
|
1266
983
|
const rules = validation.rules;
|
|
1267
|
-
const actions = validation.actions;
|
|
1268
|
-
const rulesMapping = new Rules
|
|
984
|
+
const actions = (_a = validation) === null || _a === void 0 ? void 0 : _a.actions;
|
|
985
|
+
const rulesMapping = new Rules(rules, {
|
|
986
|
+
FIELD_CONFIG: this._field,
|
|
987
|
+
FORM_DATA: this._formData,
|
|
988
|
+
PREVIOUS_FORM_DATA: this._previousFormData,
|
|
989
|
+
ALL_FORMS_DATA: this._allFormsData
|
|
990
|
+
}).mapping();
|
|
1269
991
|
for (let action of actions) {
|
|
1270
|
-
const conditionSuccess = new Condition
|
|
992
|
+
const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
|
|
1271
993
|
if (conditionSuccess) {
|
|
1272
|
-
const actions = new Actions
|
|
994
|
+
const actions = new Actions(action, rulesMapping, {
|
|
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);
|
|
1273
1000
|
yield actions.execute();
|
|
1274
1001
|
}
|
|
1275
1002
|
}
|
|
@@ -1282,11 +1009,21 @@ class Apis {
|
|
|
1282
1009
|
const triggers = validation.triggers;
|
|
1283
1010
|
const rules = validation.rules;
|
|
1284
1011
|
const actions = validation.actions;
|
|
1285
|
-
const rulesMapping = new Rules
|
|
1012
|
+
const rulesMapping = new Rules(rules, {
|
|
1013
|
+
FIELD_CONFIG: this._field,
|
|
1014
|
+
FORM_DATA: this._formData,
|
|
1015
|
+
PREVIOUS_FORM_DATA: this._previousFormData,
|
|
1016
|
+
ALL_FORMS_DATA: this._allFormsData
|
|
1017
|
+
}).mapping();
|
|
1286
1018
|
for (let action of actions) {
|
|
1287
|
-
const conditionSuccess = new Condition
|
|
1019
|
+
const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
|
|
1288
1020
|
if (conditionSuccess) {
|
|
1289
|
-
const actions = new Actions
|
|
1021
|
+
const actions = new Actions(action, rulesMapping, {
|
|
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);
|
|
1290
1027
|
yield actions.execute();
|
|
1291
1028
|
}
|
|
1292
1029
|
}
|
|
@@ -1347,7 +1084,7 @@ class KwikIDFormViewComponent {
|
|
|
1347
1084
|
ngAfterViewInit() { }
|
|
1348
1085
|
ngOnChanges(changes) {
|
|
1349
1086
|
const verifyChange = (key) => {
|
|
1350
|
-
return
|
|
1087
|
+
return checkObjectKeyExists(changes, key) && !changes[key].firstChange;
|
|
1351
1088
|
};
|
|
1352
1089
|
if (verifyChange("formData")) {
|
|
1353
1090
|
this.formData = Object.assign(Object.assign({}, this.formData), changes.formData.currentValue);
|
|
@@ -1410,11 +1147,11 @@ class KwikIDFormViewComponent {
|
|
|
1410
1147
|
});
|
|
1411
1148
|
}
|
|
1412
1149
|
setFormFieldsFromFormConfig(formConfig) {
|
|
1413
|
-
if (
|
|
1150
|
+
if (checkObjectKeyExists(formConfig, "fields")) {
|
|
1414
1151
|
this.formFields = formConfig.fields;
|
|
1415
1152
|
}
|
|
1416
|
-
else if (
|
|
1417
|
-
|
|
1153
|
+
else if (checkObjectKeyExists(formConfig, "multiForm") &&
|
|
1154
|
+
checkObjectKeyExists(formConfig.multiForm, "fields")) {
|
|
1418
1155
|
this.formFields = formConfig.multiForm.fields;
|
|
1419
1156
|
}
|
|
1420
1157
|
}
|
|
@@ -1422,7 +1159,7 @@ class KwikIDFormViewComponent {
|
|
|
1422
1159
|
this.fieldGroups = formConfig.fieldGroups;
|
|
1423
1160
|
}
|
|
1424
1161
|
setFormDataFromAllFormsData() {
|
|
1425
|
-
if (
|
|
1162
|
+
if (checkObjectKeyExists(this.allFormsData, this.formConfig.key)) {
|
|
1426
1163
|
this.formData = this.allFormsData[this.formConfig.key];
|
|
1427
1164
|
}
|
|
1428
1165
|
else {
|
|
@@ -1431,12 +1168,22 @@ class KwikIDFormViewComponent {
|
|
|
1431
1168
|
}
|
|
1432
1169
|
handleConnectedElementFieldGroupActions(childFieldGroupConfig, parentField) {
|
|
1433
1170
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1434
|
-
if (
|
|
1435
|
-
const rulesMapping = new Rules
|
|
1171
|
+
if (checkObjectKeyExists(childFieldGroupConfig, "rules")) {
|
|
1172
|
+
const rulesMapping = new Rules(childFieldGroupConfig.rules, {
|
|
1173
|
+
FIELD_CONFIG: parentField,
|
|
1174
|
+
FORM_DATA: this.formData,
|
|
1175
|
+
PREVIOUS_FORM_DATA: this.previousFormData,
|
|
1176
|
+
ALL_FORMS_DATA: this.allFormsData
|
|
1177
|
+
}).mapping();
|
|
1436
1178
|
for (let action of childFieldGroupConfig.actions) {
|
|
1437
|
-
const conditionSuccess = new Condition
|
|
1179
|
+
const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
|
|
1438
1180
|
if (conditionSuccess) {
|
|
1439
|
-
const actions = new Actions
|
|
1181
|
+
const actions = new Actions(action, rulesMapping, {
|
|
1182
|
+
FIELD_CONFIG: parentField,
|
|
1183
|
+
FORM_DATA: this.formData,
|
|
1184
|
+
PREVIOUS_FORM_DATA: this.previousFormData,
|
|
1185
|
+
ALL_FORMS_DATA: this.allFormsData
|
|
1186
|
+
}, this.takeActionOnFieldGroup.bind(this));
|
|
1440
1187
|
yield actions.execute();
|
|
1441
1188
|
}
|
|
1442
1189
|
}
|
|
@@ -1447,24 +1194,24 @@ class KwikIDFormViewComponent {
|
|
|
1447
1194
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1448
1195
|
switch (eventType) {
|
|
1449
1196
|
case "INIT":
|
|
1450
|
-
if (
|
|
1197
|
+
if (checkObjectKeyExists(connectedFieldGroupConfig, "triggers") &&
|
|
1451
1198
|
connectedFieldGroupConfig.triggers.includes("INIT")) {
|
|
1452
1199
|
yield this.handleConnectedElementFieldGroupActions(connectedFieldGroupConfig, currentField);
|
|
1453
1200
|
}
|
|
1454
1201
|
break;
|
|
1455
1202
|
case "VALUE_CHANGE":
|
|
1456
|
-
if (
|
|
1203
|
+
if (checkObjectKeyExists(connectedFieldGroupConfig, "triggers") &&
|
|
1457
1204
|
connectedFieldGroupConfig.triggers.includes("VALUE_CHANGE")) {
|
|
1458
1205
|
yield this.handleConnectedElementFieldGroupActions(connectedFieldGroupConfig, currentField);
|
|
1459
1206
|
}
|
|
1460
1207
|
break;
|
|
1461
1208
|
case "NESTED_LINK":
|
|
1462
|
-
if (
|
|
1209
|
+
if (checkObjectKeyExists(connectedFieldGroupConfig, "triggers") &&
|
|
1463
1210
|
connectedFieldGroupConfig.triggers.includes("NESTED_LINK")) {
|
|
1464
1211
|
yield this.handleConnectedElementFieldGroupActions(connectedFieldGroupConfig, currentField);
|
|
1465
1212
|
}
|
|
1466
1213
|
default:
|
|
1467
|
-
if (
|
|
1214
|
+
if (checkObjectKeyExists(connectedFieldGroupConfig, "triggers")) {
|
|
1468
1215
|
yield this.handleConnectedElementFieldGroupActions(connectedFieldGroupConfig, currentField);
|
|
1469
1216
|
}
|
|
1470
1217
|
break;
|
|
@@ -1473,12 +1220,22 @@ class KwikIDFormViewComponent {
|
|
|
1473
1220
|
}
|
|
1474
1221
|
handleConnectedElementFieldActions(connectedFieldConfig, connectedField) {
|
|
1475
1222
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1476
|
-
if (
|
|
1477
|
-
const rulesMapping = new Rules
|
|
1223
|
+
if (checkObjectKeyExists(connectedFieldConfig, "rules")) {
|
|
1224
|
+
const rulesMapping = new Rules(connectedFieldConfig.rules, {
|
|
1225
|
+
FIELD_CONFIG: connectedField,
|
|
1226
|
+
FORM_DATA: this.formData,
|
|
1227
|
+
PREVIOUS_FORM_DATA: this.previousFormData,
|
|
1228
|
+
ALL_FORMS_DATA: this.allFormsData
|
|
1229
|
+
}).mapping();
|
|
1478
1230
|
for (let action of connectedFieldConfig.actions) {
|
|
1479
|
-
const conditionSuccess = new Condition
|
|
1231
|
+
const conditionSuccess = new Condition(action.condition, rulesMapping).evaluate();
|
|
1480
1232
|
if (conditionSuccess) {
|
|
1481
|
-
const actions = new Actions
|
|
1233
|
+
const actions = new Actions(action, rulesMapping, {
|
|
1234
|
+
FIELD_CONFIG: connectedField,
|
|
1235
|
+
FORM_DATA: this.formData,
|
|
1236
|
+
PREVIOUS_FORM_DATA: this.previousFormData,
|
|
1237
|
+
ALL_FORMS_DATA: this.allFormsData
|
|
1238
|
+
}, this.takeAction.bind(this));
|
|
1482
1239
|
yield actions.execute();
|
|
1483
1240
|
}
|
|
1484
1241
|
}
|
|
@@ -1491,10 +1248,10 @@ class KwikIDFormViewComponent {
|
|
|
1491
1248
|
let connectedField = findFieldFromKey(this.formFields, connectedFieldConfig["key"]);
|
|
1492
1249
|
switch (eventType) {
|
|
1493
1250
|
case "INIT":
|
|
1494
|
-
if (
|
|
1251
|
+
if (checkObjectKeyExists(connectedField, "triggers") &&
|
|
1495
1252
|
connectedField.triggers.includes("INIT")) {
|
|
1496
1253
|
if (this.isFieldEnabled(connectedField.key)) {
|
|
1497
|
-
if (
|
|
1254
|
+
if (checkObjectKeyExists(connectedFieldConfig, "connectedParentFields")) {
|
|
1498
1255
|
switch (connectedFieldConfig.type) {
|
|
1499
1256
|
case "dropdown-with-search":
|
|
1500
1257
|
connectedField = yield this.handleFieldTypeSearchText(currentField, connectedField);
|
|
@@ -1508,7 +1265,7 @@ class KwikIDFormViewComponent {
|
|
|
1508
1265
|
}
|
|
1509
1266
|
break;
|
|
1510
1267
|
case "VALUE_CHANGE":
|
|
1511
|
-
if (
|
|
1268
|
+
if (checkObjectKeyExists(connectedFieldConfig, "triggers") &&
|
|
1512
1269
|
connectedFieldConfig.triggers.includes("VALUE_CHANGE")) {
|
|
1513
1270
|
switch (connectedField.type) {
|
|
1514
1271
|
case "dropdown-with-search":
|
|
@@ -1521,18 +1278,18 @@ class KwikIDFormViewComponent {
|
|
|
1521
1278
|
}
|
|
1522
1279
|
break;
|
|
1523
1280
|
case "NESTED_LINK":
|
|
1524
|
-
if (
|
|
1281
|
+
if (checkObjectKeyExists(connectedFieldConfig, "triggers") &&
|
|
1525
1282
|
connectedFieldConfig.triggers.includes("NESTED_LINK")) {
|
|
1526
1283
|
connectedField = yield this.handleConnectedElementFieldActions(connectedFieldConfig, connectedField);
|
|
1527
1284
|
}
|
|
1528
1285
|
default:
|
|
1529
|
-
if (
|
|
1286
|
+
if (checkObjectKeyExists(connectedFieldConfig, "triggers")) {
|
|
1530
1287
|
connectedField = yield this.handleConnectedElementFieldActions(connectedFieldConfig, connectedField);
|
|
1531
1288
|
}
|
|
1532
1289
|
break;
|
|
1533
1290
|
}
|
|
1534
|
-
if (
|
|
1535
|
-
if (
|
|
1291
|
+
if (checkObjectKeyExists(connectedField, "connectedElements")) {
|
|
1292
|
+
if (checkObjectKeyExists(connectedField.connectedElements, "connectedFields")) {
|
|
1536
1293
|
for (const connectedFieldConfig of connectedField.connectedElements
|
|
1537
1294
|
.connectedFields) {
|
|
1538
1295
|
connectedField = this.handleConnectedElementFields(connectedField, connectedFieldConfig, "NESTED_LINK");
|
|
@@ -1545,20 +1302,25 @@ class KwikIDFormViewComponent {
|
|
|
1545
1302
|
handleConnectedElements(e, eventType) {
|
|
1546
1303
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1547
1304
|
let currentField = findFieldFromKey(this.formFields, e.key);
|
|
1548
|
-
if (
|
|
1549
|
-
if (
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1305
|
+
if (currentField !== undefined) {
|
|
1306
|
+
if (checkObjectKeyExists(currentField, "connectedElements")) {
|
|
1307
|
+
if (checkObjectKeyExists(currentField.connectedElements, "connectedFieldGroups")) {
|
|
1308
|
+
let connectedFieldGroups = currentField.connectedElements.connectedFieldGroups;
|
|
1309
|
+
for (let connectedFieldGroupConfig of connectedFieldGroups) {
|
|
1310
|
+
yield this.handleConnectedElementFieldGroup(currentField, connectedFieldGroupConfig, eventType);
|
|
1311
|
+
}
|
|
1553
1312
|
}
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1313
|
+
if (checkObjectKeyExists(currentField.connectedElements, "connectedFields")) {
|
|
1314
|
+
let connectedFields = currentField.connectedElements.connectedFields;
|
|
1315
|
+
for (let connectedFieldConfig of connectedFields) {
|
|
1316
|
+
currentField = yield this.handleConnectedElementFields(currentField, connectedFieldConfig, eventType);
|
|
1317
|
+
}
|
|
1559
1318
|
}
|
|
1560
1319
|
}
|
|
1561
1320
|
}
|
|
1321
|
+
else {
|
|
1322
|
+
throw new Error(`Field for the given key ['${e.key}'] is not found with eventType: '${eventType}'.`);
|
|
1323
|
+
}
|
|
1562
1324
|
});
|
|
1563
1325
|
}
|
|
1564
1326
|
// DOM Event Handlers
|
|
@@ -1570,7 +1332,7 @@ class KwikIDFormViewComponent {
|
|
|
1570
1332
|
let field = findFieldFromKey(this.formFields, e.key);
|
|
1571
1333
|
if (field.type !== "title" &&
|
|
1572
1334
|
field.validation.triggers.includes("ON_CHANGE")) {
|
|
1573
|
-
const validations = new Validations
|
|
1335
|
+
const validations = new Validations(field, this.formData, this.previousFormData, this.allFormsData, this.takeAction.bind(this));
|
|
1574
1336
|
(() => __awaiter(this, void 0, void 0, function* () {
|
|
1575
1337
|
yield validations.validateField();
|
|
1576
1338
|
}))();
|
|
@@ -1583,9 +1345,14 @@ class KwikIDFormViewComponent {
|
|
|
1583
1345
|
handleOnClickResetFormFields(e, field) {
|
|
1584
1346
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1585
1347
|
for (let f of field.reset.fields) {
|
|
1586
|
-
for (let
|
|
1587
|
-
const resetField = findFieldFromKey(this.formFields,
|
|
1588
|
-
const actions = new Actions
|
|
1348
|
+
for (let action of f.actions) {
|
|
1349
|
+
const resetField = findFieldFromKey(this.formFields, action.props.fieldKey);
|
|
1350
|
+
const actions = new Actions(action, {}, {
|
|
1351
|
+
FIELD_CONFIG: resetField,
|
|
1352
|
+
FORM_DATA: this.formData,
|
|
1353
|
+
PREVIOUS_FORM_DATA: this.previousFormData,
|
|
1354
|
+
ALL_FORMS_DATA: this.allFormsData
|
|
1355
|
+
}, this.takeAction.bind(this));
|
|
1589
1356
|
yield actions.execute();
|
|
1590
1357
|
}
|
|
1591
1358
|
}
|
|
@@ -1653,17 +1420,17 @@ class KwikIDFormViewComponent {
|
|
|
1653
1420
|
for (let field of this.formFields) {
|
|
1654
1421
|
if (field.type !== EFieldType.TITLE &&
|
|
1655
1422
|
field.validation.triggers.includes("ON_SAVE")) {
|
|
1656
|
-
const validations = new Validations
|
|
1423
|
+
const validations = new Validations(field, formData, this.previousFormData, this.allFormsData, this.takeAction.bind(this));
|
|
1657
1424
|
(() => __awaiter(this, void 0, void 0, function* () {
|
|
1658
1425
|
yield validations.validateField();
|
|
1659
1426
|
}))();
|
|
1660
1427
|
}
|
|
1661
1428
|
}
|
|
1662
1429
|
if (this.formGroup.invalid) {
|
|
1663
|
-
const controls = new Validations
|
|
1430
|
+
const controls = new Validations(undefined, formData, this.previousFormData, this.allFormsData, this.takeAction.bind(this)).findInvalidControlsRecursive(this.formGroup);
|
|
1664
1431
|
let firstFieldWithError = "";
|
|
1665
1432
|
for (let control of controls) {
|
|
1666
|
-
if (control.invalid &&
|
|
1433
|
+
if (control.invalid && isEmptyValue(firstFieldWithError)) {
|
|
1667
1434
|
firstFieldWithError = control.key;
|
|
1668
1435
|
}
|
|
1669
1436
|
this.formFields = setFieldError(this.formFields, this.formGroup.controls[control.key].errors, control.key, control.invalid);
|
|
@@ -1675,7 +1442,7 @@ class KwikIDFormViewComponent {
|
|
|
1675
1442
|
return;
|
|
1676
1443
|
}
|
|
1677
1444
|
Object.keys(formData).map((key) => {
|
|
1678
|
-
if (
|
|
1445
|
+
if (isEmptyValue(formData[key])) {
|
|
1679
1446
|
formData[key] = "";
|
|
1680
1447
|
}
|
|
1681
1448
|
});
|
|
@@ -1718,7 +1485,7 @@ class KwikIDFormViewComponent {
|
|
|
1718
1485
|
});
|
|
1719
1486
|
if (field.type !== EFieldType.TITLE) {
|
|
1720
1487
|
this.formFields[fieldIndex]["disabled"] = true;
|
|
1721
|
-
if (
|
|
1488
|
+
if (isNotEmptyValue(this.formGroup.controls)) {
|
|
1722
1489
|
this.formGroup.controls[field.key].disable({
|
|
1723
1490
|
emitEvent: false
|
|
1724
1491
|
});
|
|
@@ -1738,7 +1505,7 @@ class KwikIDFormViewComponent {
|
|
|
1738
1505
|
});
|
|
1739
1506
|
if (field.type !== EFieldType.TITLE) {
|
|
1740
1507
|
this.formFields[fieldIndex]["disabled"] = false;
|
|
1741
|
-
if (
|
|
1508
|
+
if (isNotEmptyValue(this.formGroup.controls)) {
|
|
1742
1509
|
this.formGroup.controls[field.key].enable({
|
|
1743
1510
|
emitEvent: false
|
|
1744
1511
|
});
|
|
@@ -1839,10 +1606,10 @@ class KwikIDFormViewComponent {
|
|
|
1839
1606
|
}
|
|
1840
1607
|
handleFieldTypeSearchText(field, childField) {
|
|
1841
1608
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1842
|
-
if (
|
|
1609
|
+
if (checkObjectKeyExists(childField, "json")) {
|
|
1843
1610
|
childField.options = getSearchTextOptionsFromFieldConfig(field, childField, this.formGroup);
|
|
1844
1611
|
}
|
|
1845
|
-
if (
|
|
1612
|
+
if (checkObjectKeyExists(childField, "fetchJsonFromRemote")) {
|
|
1846
1613
|
childField.options = yield getSearchTextOptionsFromRemoteFile(field, childField, this.formGroup);
|
|
1847
1614
|
}
|
|
1848
1615
|
return childField;
|
|
@@ -1868,7 +1635,7 @@ class KwikIDFormViewComponent {
|
|
|
1868
1635
|
}
|
|
1869
1636
|
});
|
|
1870
1637
|
}
|
|
1871
|
-
takeAction(action,
|
|
1638
|
+
takeAction(action, object) {
|
|
1872
1639
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1873
1640
|
switch (action.key) {
|
|
1874
1641
|
case EActionKey.FIELD_HIDE:
|
|
@@ -1899,16 +1666,16 @@ class KwikIDFormViewComponent {
|
|
|
1899
1666
|
this.fieldMessageHide(action.props.fieldKey, action.props.message);
|
|
1900
1667
|
break;
|
|
1901
1668
|
case EActionKey.SET_VALUE:
|
|
1902
|
-
const sources = new Sources
|
|
1669
|
+
const sources = new Sources(object);
|
|
1903
1670
|
const sourceValue = yield sources.getValueFromSource(action.props.value.source);
|
|
1904
1671
|
sources.setValueToSource(action.props.value.destination, sourceValue);
|
|
1905
|
-
|
|
1906
|
-
this.formData = sources.
|
|
1907
|
-
this.allFormsData = sources.
|
|
1908
|
-
this.previousFormData = sources.
|
|
1672
|
+
object.FIELD_CONFIG = sources.object.FIELD_CONFIG;
|
|
1673
|
+
this.formData = sources.object.FORM_DATA;
|
|
1674
|
+
this.allFormsData = sources.object.ALL_FORMS_DATA;
|
|
1675
|
+
this.previousFormData = sources.object.PREVIOUS_FORM_DATA;
|
|
1909
1676
|
break;
|
|
1910
1677
|
case EActionKey.HANDLE_CONNECTED_ELEMENTS:
|
|
1911
|
-
this.handleConnectedElements({ key:
|
|
1678
|
+
this.handleConnectedElements({ key: action.props.fieldKey }, "ACTION");
|
|
1912
1679
|
break;
|
|
1913
1680
|
case EActionKey.CUSTOM:
|
|
1914
1681
|
break;
|
|
@@ -2073,10 +1840,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
|
|
|
2073
1840
|
type: Output
|
|
2074
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: [], isFieldValid: [], isFieldEnabled: [], getFormGroupRawValues: [], handleFieldTypeSearchText: [], takeActionOnFieldGroup: [], takeAction: [] } });
|
|
2075
1842
|
|
|
2076
|
-
const hasKey = (object, key) => {
|
|
2077
|
-
return object.hasOwnProperty(key);
|
|
2078
|
-
};
|
|
2079
|
-
|
|
2080
1843
|
class KwikIDFormsListComponent {
|
|
2081
1844
|
constructor() {
|
|
2082
1845
|
this.showFormFields = {};
|
|
@@ -2095,7 +1858,7 @@ class KwikIDFormsListComponent {
|
|
|
2095
1858
|
}
|
|
2096
1859
|
ngOnChanges(changes) {
|
|
2097
1860
|
const verifyChange = (key) => {
|
|
2098
|
-
return
|
|
1861
|
+
return checkObjectKeyExists(changes, key) && !changes[key].firstChange;
|
|
2099
1862
|
};
|
|
2100
1863
|
if (verifyChange("showFormFields")) {
|
|
2101
1864
|
this.showFormFields = changes.showFormFields.currentValue;
|
|
@@ -2130,7 +1893,7 @@ class KwikIDFormsListComponent {
|
|
|
2130
1893
|
}
|
|
2131
1894
|
}
|
|
2132
1895
|
/** @nocollapse */ KwikIDFormsListComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: KwikIDFormsListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2133
|
-
/** @nocollapse */ KwikIDFormsListComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: KwikIDFormsListComponent, selector: "kwikid-forms-list", inputs: { showFormFields: "showFormFields", userConfig: "userConfig", formsList: "formsList", formsListCompleted: "formsListCompleted", isMobileView: "isMobileView" }, outputs: { onClickSetActiveForm: "onClickSetActiveForm", onClickHideFormsList: "onClickHideFormsList", onClickSubmitForms: "onClickSubmitForms" }, usesOnChanges: true, ngImport: i0, template: "<div id=\"sidebar-container\">\r\n <div id=\"sidebar\">\r\n <div ngClass=\"kwikid-form-header\">\r\n <div id=\"uf-header\">\r\n <div id=\"uf-header-logo-container\">\r\n <img\r\n id=\"uf-header-logo\"\r\n src=\"{{ this.userConfig.theme.clientLogo }}\"\r\n [ngClass]=\"'large-icon'\"\r\n />\r\n </div>\r\n </div>\r\n <hr />\r\n </div>\r\n <div id=\"uf-progress\">\r\n <div id=\"uf-progress-steps\">\r\n {{ this.formsListCompleted.length }} / {{ this.formsList.length }} Steps\r\n Completed\r\n </div>\r\n <kwikui-progress-segmented\r\n [max]=\"this.formsList.length\"\r\n size=\"m\"\r\n [value]=\"this.formsListCompleted.length\"\r\n ></kwikui-progress-segmented>\r\n </div>\r\n <div id=\"uf-sections-container\">\r\n <div\r\n *ngFor=\"let form of formsList; let i = index\"\r\n [class]=\"'uf-section-item'\"\r\n [class.completed]=\"form.status === 'completed' && !form.disabled\"\r\n [class.edit]=\"form.status === 'editable' && !form.disabled\"\r\n [class.locked]=\"form.status === 'locked' && form.disabled\"\r\n (click)=\"\r\n form.status === 'locked' && form.disabled\r\n ? undefined\r\n : handleOnClickSetActiveForm(form.key)\r\n \"\r\n >\r\n <div class=\"uf-form-section-card-title\">\r\n {{ form.title }}\r\n </div>\r\n <div class=\"uf-form-section-card-action\">\r\n <div\r\n *ngIf=\"form.status === 'completed' && !form.disabled\"\r\n class=\"uf-form-section-card-action-img completed\"\r\n >\r\n <tui-svg src=\"tuiIconCheckLarge\"></tui-svg>\r\n </div>\r\n <div\r\n *ngIf=\"form.status !== 'completed' && !form.disabled\"\r\n class=\"uf-form-section-card-action-img edit\"\r\n >\r\n <tui-svg src=\"tuiIconEdit\"></tui-svg>\r\n </div>\r\n <div\r\n *ngIf=\"form.status !== 'completed' && form.disabled\"\r\n class=\"uf-form-section-card-action-img locked\"\r\n >\r\n <tui-svg src=\"tuiIconLock\"></tui-svg>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n <div id=\"submit-sidebar-btn-container\">\r\n <kwikui-button\r\n [disabled]=\"false\"\r\n id=\"\"\r\n label=\"Submit\"\r\n [showLoader]=\"false\"\r\n styles=\"\"\r\n class=\"\"\r\n type=\"button\"\r\n appearance=\"primary\"\r\n icon=\"\"\r\n iconRight=\"\"\r\n [shape]=\"null\"\r\n size=\"m\"\r\n styles=\"width: 100%\"\r\n (onClick)=\"handleOnSubmitForms($event)\"\r\n ></kwikui-button>\r\n </div>\r\n </div>\r\n</div>\r\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}#sidebar-container{width:100%;height:100%;margin:0 auto;display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;align-content:center}#sidebar{width:100%;height:100%;display:flex;flex-direction:column;align-content:center;justify-content:flex-start;align-items:stretch}.uf-section-item{width:100%;display:flex;flex-direction:row;align-items:center;justify-content:space-between;align-content:center;padding:1rem;grid-gap:1rem;gap:1rem;cursor:pointer;box-shadow:0 .1rem .5rem -.25rem gray;border-radius:.5rem;background-color:var(--tui-base-02)}.uf-section-item:hover{box-shadow:0 .2rem .75rem -.5rem #656565}#submit-sidebar-btn-container{width:100%;bottom:0px;z-index:1;padding:1rem;display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center;grid-gap:1rem;gap:1rem}#submit-sidebar-btn-container *{flex-grow:1}#uf-sections-container{display:flex;flex-direction:column;height:100%;grid-row-gap:20px;row-gap:20px;padding:1rem;overflow-y:auto}.uf-form-section-card{display:flex;flex-direction:row;align-content:center;justify-content:space-between;align-items:center;grid-column-gap:10px;column-gap:10px;border:none;border-radius:8px;background-color:#e9e9e9;height:-moz-fit-content;height:fit-content;min-height:60px;padding:10px 15px;width:100%;max-width:350px;margin:0 auto}.uf-section-item.locked{-webkit-user-select:none;user-select:none;cursor:not-allowed}.uf-form-section-card .uf-form-section-card-title{font-size:1.2em;text-align:left;line-height:1.25em}.uf-form-section-card .uf-form-section-card-action{width:30px;height:30px;display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center}.uf-form-section-card .uf-form-section-card-action .uf-form-section-card-action-img{width:30px;height:30px;display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center;border-radius:100%;color:#fff;font-weight:bold}.uf-form-section-card-action-img.completed{background-color:#228b22;padding:.25rem;border-radius:50%;color:#fff}.uf-form-section-card-action-img.edit{background-color:#dc143c;padding:.25rem;border-radius:50%;color:#fff}.uf-form-section-card-action-img.locked{background-color:gray;padding:.25rem;border-radius:50%;color:#fff}#uf-progress{display:flex;padding:1rem;flex-direction:column;align-content:center;justify-content:center;align-items:stretch;grid-gap:.5rem;gap:.5rem}#uf-progress-steps{font-size:1em;text-align:right;color:#3d3d3d}.uf-form-section-card-title{font-size:1em;font-weight:bold;color:#121212}@media screen and (max-width: 600px){#sidebar-container{max-width:unset}}.kwikid-form-header{height:70px;z-index:6}.kwikid-form-header hr{width:calc(100% - 1rem);margin-left:auto;margin-right:auto}#uf-header{display:flex;flex-direction:row;align-content:center;align-items:center;justify-content:flex-start;grid-column-gap:10px;column-gap:10px;padding:10px 20px;width:100%;max-width:calc(400px + 50vw + 2rem);margin:0 auto;height:70px;z-index:1}#uf-header #uf-header-goback-container{display:none}#uf-header #uf-header-goback-container:hover{border-radius:50%;background-color:#d3d3d3}#uf-header #uf-header-goback-container #uf-header-goback{width:100%;height:auto}#uf-header #uf-header-logo-container{display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center}#uf-header #uf-header-logo-container #uf-header-logo.small-icon{width:100%;height:50px}#uf-header #uf-header-logo-container #uf-header-logo.large-icon{width:100%;height:50px}#uf-header #uf-header-title-container{display:flex;flex-direction:column;justify-content:center;align-items:flex-start;grid-row-gap:4px;row-gap:4px}#uf-header #uf-header-title-container #uf-header-title{font-size:1.4em;color:#121212}#uf-header #uf-header-title-container #uf-header-subtitle{font-size:1.2em;color:#121212}\n"], components: [{ type: i2.KwikUIProgressSegmentedComponent, selector: "kwikui-progress-segmented", inputs: ["value", "max", "size", "colors"] }, { type: i3.TuiSvgComponent, selector: "tui-svg", inputs: ["src"] }, { type: i2.KwikUIButtonComponent, selector: "kwikui-button", inputs: ["disabled", "id", "label", "showLoader", "styles", "class", "type", "appearance", "icon", "iconRight", "shape", "size"], outputs: ["onClick"] }], directives: [{ type: i5.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
1896
|
+
/** @nocollapse */ KwikIDFormsListComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: KwikIDFormsListComponent, selector: "kwikid-forms-list", inputs: { showFormFields: "showFormFields", userConfig: "userConfig", formsList: "formsList", formsListCompleted: "formsListCompleted", isMobileView: "isMobileView" }, outputs: { onClickSetActiveForm: "onClickSetActiveForm", onClickHideFormsList: "onClickHideFormsList", onClickSubmitForms: "onClickSubmitForms" }, usesOnChanges: true, ngImport: i0, template: "<div id=\"sidebar-container\">\r\n <div id=\"sidebar\">\r\n <div ngClass=\"kwikid-form-header\">\r\n <div id=\"uf-header\">\r\n <div id=\"uf-header-logo-container\">\r\n <img\r\n id=\"uf-header-logo\"\r\n src=\"{{ this.userConfig.theme.clientLogo }}\"\r\n [ngClass]=\"'large-icon'\"\r\n />\r\n </div>\r\n </div>\r\n <hr />\r\n </div>\r\n <div id=\"uf-progress\">\r\n <div id=\"uf-progress-steps\">\r\n {{ this.formsListCompleted.length }} / {{ this.formsList.length }} Steps\r\n Completed\r\n </div>\r\n <kwikui-progress-segmented\r\n [max]=\"this.formsList.length\"\r\n size=\"m\"\r\n [value]=\"this.formsListCompleted.length\"\r\n ></kwikui-progress-segmented>\r\n </div>\r\n <div id=\"uf-sections-container\">\r\n <div\r\n *ngFor=\"let form of formsList; let i = index\"\r\n [class]=\"'uf-section-item'\"\r\n [class.completed]=\"form.status === 'completed' && !form.disabled\"\r\n [class.edit]=\"form.status === 'editable' && !form.disabled\"\r\n [class.locked]=\"form.status === 'locked' && form.disabled\"\r\n (click)=\"\r\n form.status === 'locked' && form.disabled\r\n ? undefined\r\n : handleOnClickSetActiveForm(form.key)\r\n \"\r\n >\r\n <div class=\"uf-form-section-card-title\">\r\n {{ form.title }}\r\n </div>\r\n <div class=\"uf-form-section-card-action\">\r\n <div\r\n *ngIf=\"form.status === 'completed' && !form.disabled\"\r\n class=\"uf-form-section-card-action-img completed\"\r\n >\r\n <tui-svg src=\"tuiIconCheckLarge\"></tui-svg>\r\n </div>\r\n <div\r\n *ngIf=\"form.status !== 'completed' && !form.disabled\"\r\n class=\"uf-form-section-card-action-img edit\"\r\n >\r\n <tui-svg src=\"tuiIconEdit\"></tui-svg>\r\n </div>\r\n <div\r\n *ngIf=\"form.status !== 'completed' && form.disabled\"\r\n class=\"uf-form-section-card-action-img locked\"\r\n >\r\n <tui-svg src=\"tuiIconLock\"></tui-svg>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n <div id=\"submit-sidebar-btn-container\">\r\n <kwikui-button\r\n [disabled]=\"false\"\r\n id=\"\"\r\n label=\"Submit\"\r\n [showLoader]=\"false\"\r\n styles=\"\"\r\n class=\"\"\r\n type=\"button\"\r\n appearance=\"primary\"\r\n icon=\"\"\r\n iconRight=\"\"\r\n [shape]=\"null\"\r\n size=\"m\"\r\n styles=\"width: 100%\"\r\n (onClick)=\"handleOnSubmitForms($event)\"\r\n ></kwikui-button>\r\n </div>\r\n </div>\r\n</div>\r\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}#sidebar-container{width:100%;height:100%;margin:0 auto;display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;align-content:center}#sidebar{width:100%;height:100%;display:flex;flex-direction:column;align-content:center;justify-content:flex-start;align-items:stretch}.uf-section-item{width:100%;display:flex;flex-direction:row;align-items:center;justify-content:space-between;align-content:center;padding:1rem;grid-gap:1rem;gap:1rem;cursor:pointer;box-shadow:0 .1rem .5rem -.25rem gray;border-radius:.5rem;background-color:var(--tui-base-02)}.uf-section-item:hover{box-shadow:0 .2rem .75rem -.5rem #656565}#submit-sidebar-btn-container{width:100%;bottom:0px;z-index:1;padding:1rem;display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center;grid-gap:1rem;gap:1rem}#submit-sidebar-btn-container *{flex-grow:1}#uf-sections-container{display:flex;flex-direction:column;height:100%;grid-row-gap:20px;row-gap:20px;padding:1rem;overflow-y:auto}.uf-form-section-card{display:flex;flex-direction:row;align-content:center;justify-content:space-between;align-items:center;grid-column-gap:10px;column-gap:10px;border:none;border-radius:8px;background-color:#e9e9e9;height:-moz-fit-content;height:fit-content;min-height:60px;padding:10px 15px;width:100%;max-width:350px;margin:0 auto}.uf-section-item.locked{-webkit-user-select:none;user-select:none;cursor:not-allowed}.uf-form-section-card .uf-form-section-card-title{font-size:1.2em;text-align:left;line-height:1.25em}.uf-form-section-card .uf-form-section-card-action{width:30px;height:30px;display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center}.uf-form-section-card .uf-form-section-card-action .uf-form-section-card-action-img{width:30px;height:30px;display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center;border-radius:100%;color:#fff;font-weight:bold}.uf-form-section-card-action-img.completed{background-color:#228b22;padding:.25rem;border-radius:50%;color:#fff}.uf-form-section-card-action-img.edit{background-color:#dc143c;padding:.25rem;border-radius:50%;color:#fff}.uf-form-section-card-action-img.locked{background-color:gray;padding:.25rem;border-radius:50%;color:#fff}#uf-progress{display:flex;padding:1rem;flex-direction:column;align-content:center;justify-content:center;align-items:stretch;grid-gap:.5rem;gap:.5rem}#uf-progress-steps{font-size:1em;text-align:right;color:#3d3d3d}.uf-form-section-card-title{font-size:1em;font-weight:bold;color:#121212}@media screen and (max-width: 600px){#sidebar-container{max-width:unset}}.kwikid-form-header{height:70px;z-index:6}.kwikid-form-header hr{width:calc(100% - 1rem);margin-left:auto;margin-right:auto}#uf-header{display:flex;flex-direction:row;align-content:center;align-items:center;justify-content:flex-start;grid-column-gap:10px;column-gap:10px;padding:10px 20px;width:100%;max-width:calc(400px + 50vw + 2rem);margin:0 auto;height:70px;z-index:1}#uf-header #uf-header-goback-container{display:none}#uf-header #uf-header-goback-container:hover{border-radius:50%;background-color:#d3d3d3}#uf-header #uf-header-goback-container #uf-header-goback{width:100%;height:auto}#uf-header #uf-header-logo-container{display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center}#uf-header #uf-header-logo-container #uf-header-logo.small-icon{width:100%;height:50px}#uf-header #uf-header-logo-container #uf-header-logo.large-icon{width:100%;height:50px}#uf-header #uf-header-title-container{display:flex;flex-direction:column;justify-content:center;align-items:flex-start;grid-row-gap:4px;row-gap:4px}#uf-header #uf-header-title-container #uf-header-title{font-size:1.4em;color:#121212}#uf-header #uf-header-title-container #uf-header-subtitle{font-size:1.2em;color:#121212}\n"], components: [{ type: i2.KwikUIProgressSegmentedComponent, selector: "kwikui-progress-segmented", inputs: ["id", "value", "max", "size", "colors"] }, { type: i3.TuiSvgComponent, selector: "tui-svg", inputs: ["src"] }, { type: i2.KwikUIButtonComponent, selector: "kwikui-button", inputs: ["disabled", "id", "label", "showLoader", "styles", "class", "type", "appearance", "icon", "iconRight", "shape", "size"], outputs: ["onClick"] }], directives: [{ type: i5.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
2134
1897
|
__decorate([
|
|
2135
1898
|
logMethod
|
|
2136
1899
|
], KwikIDFormsListComponent.prototype, "ngOnChanges", null);
|
|
@@ -2159,279 +1922,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
|
|
|
2159
1922
|
type: Output
|
|
2160
1923
|
}], ngOnChanges: [] } });
|
|
2161
1924
|
|
|
2162
|
-
class Sources {
|
|
2163
|
-
constructor(userConfig, formsData) {
|
|
2164
|
-
this._userConfig = userConfig;
|
|
2165
|
-
this._formsData = formsData;
|
|
2166
|
-
}
|
|
2167
|
-
get userConfig() {
|
|
2168
|
-
return this._userConfig;
|
|
2169
|
-
}
|
|
2170
|
-
set userConfig(value) {
|
|
2171
|
-
this._userConfig = value;
|
|
2172
|
-
}
|
|
2173
|
-
get formsData() {
|
|
2174
|
-
return this._formsData;
|
|
2175
|
-
}
|
|
2176
|
-
set formsData(value) {
|
|
2177
|
-
this._formsData = value;
|
|
2178
|
-
}
|
|
2179
|
-
getValueFromUserConfig(path) {
|
|
2180
|
-
let value = "";
|
|
2181
|
-
if (isNotEmpty(path)) {
|
|
2182
|
-
value = jpQueryWrapper(this._userConfig, path);
|
|
2183
|
-
}
|
|
2184
|
-
else {
|
|
2185
|
-
value = setEmptyValue(this._userConfig);
|
|
2186
|
-
}
|
|
2187
|
-
return value;
|
|
2188
|
-
}
|
|
2189
|
-
getValueFromFormsData(path) {
|
|
2190
|
-
let value = "";
|
|
2191
|
-
if (isNotEmpty(path)) {
|
|
2192
|
-
value = jpQueryWrapper(this._formsData, path);
|
|
2193
|
-
}
|
|
2194
|
-
else {
|
|
2195
|
-
value = setEmptyValue(this._formsData);
|
|
2196
|
-
}
|
|
2197
|
-
return value;
|
|
2198
|
-
}
|
|
2199
|
-
getValueFromBrowserStorage(type, key) {
|
|
2200
|
-
let value = "";
|
|
2201
|
-
switch (type) {
|
|
2202
|
-
case EBrowserStorageType.LOCAL_STORAGE:
|
|
2203
|
-
value = isNotEmptyBrowserStorageValue(localStorage.getItem(key))
|
|
2204
|
-
? localStorage.getItem(key)
|
|
2205
|
-
: "";
|
|
2206
|
-
break;
|
|
2207
|
-
case EBrowserStorageType.SESSION_STORAGE:
|
|
2208
|
-
value = isNotEmptyBrowserStorageValue(sessionStorage.getItem(key))
|
|
2209
|
-
? sessionStorage.getItem(key)
|
|
2210
|
-
: "";
|
|
2211
|
-
break;
|
|
2212
|
-
default:
|
|
2213
|
-
value = "";
|
|
2214
|
-
break;
|
|
2215
|
-
}
|
|
2216
|
-
return value;
|
|
2217
|
-
}
|
|
2218
|
-
getValueFromSource(source) {
|
|
2219
|
-
let value = "";
|
|
2220
|
-
switch (source.key) {
|
|
2221
|
-
case ESourceKey.USER_CONFIG:
|
|
2222
|
-
value = this.getValueFromUserConfig(source.props.path);
|
|
2223
|
-
break;
|
|
2224
|
-
case ESourceKey.ALL_FORMS_DATA:
|
|
2225
|
-
value = this.getValueFromFormsData(source.props.path);
|
|
2226
|
-
break;
|
|
2227
|
-
case ESourceKey.BROWSER_STORAGE:
|
|
2228
|
-
value = this.getValueFromBrowserStorage(source.props.browserStorage.type, source.props.browserStorage.key);
|
|
2229
|
-
break;
|
|
2230
|
-
case ESourceKey.PREDEFINED:
|
|
2231
|
-
value = source.value;
|
|
2232
|
-
break;
|
|
2233
|
-
default:
|
|
2234
|
-
value = "";
|
|
2235
|
-
break;
|
|
2236
|
-
}
|
|
2237
|
-
return value;
|
|
2238
|
-
}
|
|
2239
|
-
setValueToUserConfig(path, value) {
|
|
2240
|
-
this._userConfig = setValueToObject(this._userConfig, path, value);
|
|
2241
|
-
}
|
|
2242
|
-
setValueToAllFormsData(path, value) {
|
|
2243
|
-
this._formsData = setValueToObject(this._formsData, path, value);
|
|
2244
|
-
}
|
|
2245
|
-
setValueToBrowserStorage(type, key, value) {
|
|
2246
|
-
switch (type) {
|
|
2247
|
-
case EBrowserStorageType.LOCAL_STORAGE:
|
|
2248
|
-
localStorage.setItem(key, value);
|
|
2249
|
-
break;
|
|
2250
|
-
case EBrowserStorageType.SESSION_STORAGE:
|
|
2251
|
-
sessionStorage.setItem(key, value);
|
|
2252
|
-
break;
|
|
2253
|
-
default:
|
|
2254
|
-
break;
|
|
2255
|
-
}
|
|
2256
|
-
}
|
|
2257
|
-
setValueToSource(source, value) {
|
|
2258
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2259
|
-
switch (source.key) {
|
|
2260
|
-
case ESourceKey.USER_CONFIG:
|
|
2261
|
-
this.setValueToUserConfig(source.props.path, value);
|
|
2262
|
-
break;
|
|
2263
|
-
case ESourceKey.ALL_FORMS_DATA:
|
|
2264
|
-
this.setValueToAllFormsData(source.props.path, value);
|
|
2265
|
-
break;
|
|
2266
|
-
case ESourceKey.BROWSER_STORAGE:
|
|
2267
|
-
yield this.setValueToBrowserStorage(source.props.browserStorage.type, source.props.browserStorage.key, value);
|
|
2268
|
-
break;
|
|
2269
|
-
default:
|
|
2270
|
-
break;
|
|
2271
|
-
}
|
|
2272
|
-
});
|
|
2273
|
-
}
|
|
2274
|
-
}
|
|
2275
|
-
|
|
2276
|
-
class Condition {
|
|
2277
|
-
constructor(condition, rulesMapping) {
|
|
2278
|
-
this._condition = condition;
|
|
2279
|
-
this._rulesMapping = rulesMapping;
|
|
2280
|
-
}
|
|
2281
|
-
parseKeys(condition, rulesEvaluationMapping) {
|
|
2282
|
-
Object.keys(rulesEvaluationMapping).forEach((key) => {
|
|
2283
|
-
condition = replaceString(condition, key, rulesEvaluationMapping[key]);
|
|
2284
|
-
});
|
|
2285
|
-
return condition;
|
|
2286
|
-
}
|
|
2287
|
-
parseOperators(condition) {
|
|
2288
|
-
return condition.replace(/AND|OR|NOT|XOR|NAND|NOR|XNOR/g, (match) => {
|
|
2289
|
-
switch (match) {
|
|
2290
|
-
case "AND":
|
|
2291
|
-
return "&&";
|
|
2292
|
-
case "OR":
|
|
2293
|
-
return "||";
|
|
2294
|
-
case "NOT":
|
|
2295
|
-
return "!";
|
|
2296
|
-
case "XOR":
|
|
2297
|
-
return "^";
|
|
2298
|
-
case "NAND":
|
|
2299
|
-
return "!&";
|
|
2300
|
-
case "NOR":
|
|
2301
|
-
return "!|";
|
|
2302
|
-
case "XNOR":
|
|
2303
|
-
return "!^";
|
|
2304
|
-
default:
|
|
2305
|
-
return match;
|
|
2306
|
-
}
|
|
2307
|
-
});
|
|
2308
|
-
}
|
|
2309
|
-
evaluate() {
|
|
2310
|
-
this._condition = this.parseKeys(this._condition, this._rulesMapping);
|
|
2311
|
-
this._condition = this.parseOperators(this._condition);
|
|
2312
|
-
return eval(this._condition);
|
|
2313
|
-
}
|
|
2314
|
-
}
|
|
2315
|
-
|
|
2316
|
-
class Actions {
|
|
2317
|
-
constructor(action, ruleMapping, userConfig, formsData, takeAction) {
|
|
2318
|
-
this._action = action;
|
|
2319
|
-
this._userConfig = userConfig;
|
|
2320
|
-
this._formsData = formsData;
|
|
2321
|
-
this._ruleMapping = ruleMapping;
|
|
2322
|
-
this._takeAction = takeAction;
|
|
2323
|
-
}
|
|
2324
|
-
execute() {
|
|
2325
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2326
|
-
const condition = new Condition(this._action.condition, this._ruleMapping);
|
|
2327
|
-
const actionSuccess = condition.evaluate();
|
|
2328
|
-
if (actionSuccess) {
|
|
2329
|
-
return this._takeAction(this._action, this._userConfig, this._formsData);
|
|
2330
|
-
}
|
|
2331
|
-
});
|
|
2332
|
-
}
|
|
2333
|
-
}
|
|
2334
|
-
|
|
2335
|
-
class Rules {
|
|
2336
|
-
constructor(userConfig, formsData, rules) {
|
|
2337
|
-
this._userConfig = userConfig;
|
|
2338
|
-
this._formsData = formsData;
|
|
2339
|
-
this._rules = rules;
|
|
2340
|
-
}
|
|
2341
|
-
evaluate(rule) {
|
|
2342
|
-
let ruleType = rule.key;
|
|
2343
|
-
let ruleEvaluationStatus = false;
|
|
2344
|
-
const source = new Sources(this._userConfig, this._formsData);
|
|
2345
|
-
switch (ruleType) {
|
|
2346
|
-
case ERuleKey.OBJECT_PATH_EXISTS:
|
|
2347
|
-
const ruleObjectPathExists = rule;
|
|
2348
|
-
const ruleObjectPathExistsObject = ruleObjectPathExists.props.object;
|
|
2349
|
-
const ruleObjectPathExistsPath = ruleObjectPathExists.props.path;
|
|
2350
|
-
switch (ruleObjectPathExistsObject) {
|
|
2351
|
-
case ESourceKey.USER_CONFIG:
|
|
2352
|
-
ruleEvaluationStatus = hasPath(this._userConfig, ruleObjectPathExistsPath);
|
|
2353
|
-
break;
|
|
2354
|
-
default:
|
|
2355
|
-
ruleEvaluationStatus = false;
|
|
2356
|
-
break;
|
|
2357
|
-
}
|
|
2358
|
-
break;
|
|
2359
|
-
case ERuleKey.VALUE_CHECK:
|
|
2360
|
-
const ruleValueCheck = rule;
|
|
2361
|
-
const ruleValueCheckSource = ruleValueCheck.props.value.source;
|
|
2362
|
-
const ruleValueCheckValue = source.getValueFromSource(ruleValueCheckSource);
|
|
2363
|
-
if (ruleValueCheck.props.pattern.key === EPatternKey.CUSTOM) {
|
|
2364
|
-
var re = new RegExp(ruleValueCheck.props.pattern.pattern);
|
|
2365
|
-
}
|
|
2366
|
-
else {
|
|
2367
|
-
var re = new RegExp(EPattern[ruleValueCheck.props.pattern.key]);
|
|
2368
|
-
}
|
|
2369
|
-
ruleEvaluationStatus = re.test(ruleValueCheckValue);
|
|
2370
|
-
break;
|
|
2371
|
-
case ERuleKey.VALUE_CHANGE:
|
|
2372
|
-
const ruleValueChange = rule;
|
|
2373
|
-
const ruleValueChangeCurrentSource = ruleValueChange.props.value.current.source;
|
|
2374
|
-
const ruleValueChangePreviousSource = ruleValueChange.props.value.previous.source;
|
|
2375
|
-
const previousValue = source.getValueFromSource(ruleValueChangePreviousSource);
|
|
2376
|
-
const currentValue = source.getValueFromSource(ruleValueChangeCurrentSource);
|
|
2377
|
-
ruleEvaluationStatus = previousValue === currentValue;
|
|
2378
|
-
break;
|
|
2379
|
-
default:
|
|
2380
|
-
break;
|
|
2381
|
-
}
|
|
2382
|
-
return ruleEvaluationStatus;
|
|
2383
|
-
}
|
|
2384
|
-
mapping() {
|
|
2385
|
-
let rulesEvaluationMapping = {};
|
|
2386
|
-
for (const rule of this._rules) {
|
|
2387
|
-
const ruleEvaluationStatus = this.evaluate(rule);
|
|
2388
|
-
rulesEvaluationMapping = Object.assign(Object.assign({}, rulesEvaluationMapping), { [rule.id]: ruleEvaluationStatus });
|
|
2389
|
-
}
|
|
2390
|
-
return rulesEvaluationMapping;
|
|
2391
|
-
}
|
|
2392
|
-
}
|
|
2393
|
-
|
|
2394
|
-
class Validations {
|
|
2395
|
-
constructor(userConfig, formsData, takeAction) {
|
|
2396
|
-
this._userConfig = userConfig;
|
|
2397
|
-
this._formsData = formsData;
|
|
2398
|
-
this._takeAction = takeAction;
|
|
2399
|
-
}
|
|
2400
|
-
get userConfig() {
|
|
2401
|
-
return this._userConfig;
|
|
2402
|
-
}
|
|
2403
|
-
set userConfig(value) {
|
|
2404
|
-
this._userConfig = value;
|
|
2405
|
-
}
|
|
2406
|
-
get formsData() {
|
|
2407
|
-
return this._formsData;
|
|
2408
|
-
}
|
|
2409
|
-
set formsData(value) {
|
|
2410
|
-
this._formsData = value;
|
|
2411
|
-
}
|
|
2412
|
-
validateField() {
|
|
2413
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2414
|
-
const validations = this._userConfig.userFormFieldsConfig.validation;
|
|
2415
|
-
const triggers = validations === null || validations === void 0 ? void 0 : validations.triggers;
|
|
2416
|
-
const rules = validations.rules;
|
|
2417
|
-
const actions = validations.actions;
|
|
2418
|
-
const rulesMapping = new Rules(this._userConfig, this._formsData, rules).mapping();
|
|
2419
|
-
for (let action of actions) {
|
|
2420
|
-
const conditionEvaluation = new Condition(action.condition, rulesMapping).evaluate();
|
|
2421
|
-
if (conditionEvaluation) {
|
|
2422
|
-
const actions = new Actions(action, rulesMapping, this._userConfig, this._formsData, this._takeAction);
|
|
2423
|
-
yield actions.execute();
|
|
2424
|
-
}
|
|
2425
|
-
}
|
|
2426
|
-
});
|
|
2427
|
-
}
|
|
2428
|
-
}
|
|
2429
|
-
|
|
2430
1925
|
class Converter {
|
|
2431
1926
|
constructor() {
|
|
2432
1927
|
this.getFormFields = (formConfig) => {
|
|
2433
1928
|
let fields;
|
|
2434
|
-
if (
|
|
1929
|
+
if (checkObjectKeyExists(formConfig, "multiForm")) {
|
|
2435
1930
|
fields = formConfig.multiForm.fields;
|
|
2436
1931
|
}
|
|
2437
1932
|
else {
|
|
@@ -2440,7 +1935,7 @@ class Converter {
|
|
|
2440
1935
|
return fields;
|
|
2441
1936
|
};
|
|
2442
1937
|
this.setMissingFieldKeyValue = (field, key, value) => {
|
|
2443
|
-
if (!
|
|
1938
|
+
if (!checkObjectKeyExists(field, key)) {
|
|
2444
1939
|
field[key] = value;
|
|
2445
1940
|
}
|
|
2446
1941
|
return field;
|
|
@@ -2450,7 +1945,7 @@ class Converter {
|
|
|
2450
1945
|
return field;
|
|
2451
1946
|
};
|
|
2452
1947
|
this.removeFieldKey = (field, key) => {
|
|
2453
|
-
if (
|
|
1948
|
+
if (checkObjectKeyExists(field, key)) {
|
|
2454
1949
|
delete field[key];
|
|
2455
1950
|
}
|
|
2456
1951
|
return field;
|
|
@@ -2471,7 +1966,8 @@ class Converter {
|
|
|
2471
1966
|
return { label: x, disabled: false };
|
|
2472
1967
|
}
|
|
2473
1968
|
else {
|
|
2474
|
-
if (
|
|
1969
|
+
if (checkObjectKeyExists(x, "label") &&
|
|
1970
|
+
checkObjectKeyExists(x, "disabled")) {
|
|
2475
1971
|
return x;
|
|
2476
1972
|
}
|
|
2477
1973
|
}
|
|
@@ -2484,14 +1980,14 @@ class Converter {
|
|
|
2484
1980
|
return field;
|
|
2485
1981
|
};
|
|
2486
1982
|
const formatFieldTypeDate = (field) => {
|
|
2487
|
-
if (
|
|
1983
|
+
if (checkObjectKeyExists(field, "min")) {
|
|
2488
1984
|
const tuiDay = convertDateStringToTuiDayFormat(field["min"]);
|
|
2489
1985
|
field.properties = this.setFieldKeyValue(field.properties, "min", tuiDay);
|
|
2490
1986
|
}
|
|
2491
1987
|
else {
|
|
2492
1988
|
field.properties = this.setMissingFieldKeyValue(field.properties, "min", new TuiDay(0, 0, 1)); // Year - 0000, Month - 0 (0 Indexing), Day - 1
|
|
2493
1989
|
}
|
|
2494
|
-
if (
|
|
1990
|
+
if (checkObjectKeyExists(field, "max")) {
|
|
2495
1991
|
const tuiDay = convertDateStringToTuiDayFormat(field["max"]);
|
|
2496
1992
|
field.properties = this.setFieldKeyValue(field.properties, "max", tuiDay);
|
|
2497
1993
|
}
|
|
@@ -2506,7 +2002,7 @@ class Converter {
|
|
|
2506
2002
|
return field;
|
|
2507
2003
|
};
|
|
2508
2004
|
const formatFieldTypeNumber = (field) => {
|
|
2509
|
-
if (
|
|
2005
|
+
if (checkObjectKeyExists(field, "key")) {
|
|
2510
2006
|
if (field.key === "aadhaar_number") {
|
|
2511
2007
|
field = this.setFieldKeyValue(field, "type", "aadhaar_number");
|
|
2512
2008
|
}
|
|
@@ -2529,16 +2025,16 @@ class Converter {
|
|
|
2529
2025
|
return field;
|
|
2530
2026
|
};
|
|
2531
2027
|
const formatFieldTypeApiCall = (field) => {
|
|
2532
|
-
if (!
|
|
2028
|
+
if (!checkObjectKeyExists(field.properties, "shape")) {
|
|
2533
2029
|
field.properties = this.setFieldKeyValue(field.properties, "shape", null);
|
|
2534
2030
|
}
|
|
2535
|
-
if (!
|
|
2031
|
+
if (!checkObjectKeyExists(field, "showLoader")) {
|
|
2536
2032
|
field = this.setFieldKeyValue(field, "showLoader", false);
|
|
2537
2033
|
}
|
|
2538
|
-
if (!
|
|
2034
|
+
if (!checkObjectKeyExists(field.properties, "size")) {
|
|
2539
2035
|
field.properties = this.setFieldKeyValue(field.properties, "size", "m");
|
|
2540
2036
|
}
|
|
2541
|
-
if (!
|
|
2037
|
+
if (!checkObjectKeyExists(field, "api")) {
|
|
2542
2038
|
field = this.setFieldKeyValue(field, "api", {});
|
|
2543
2039
|
field.api = this.setMissingFieldKeyValue(field.api, "url", "");
|
|
2544
2040
|
field.api = this.setMissingFieldKeyValue(field.api, "request", "");
|
|
@@ -2555,7 +2051,7 @@ class Converter {
|
|
|
2555
2051
|
return field;
|
|
2556
2052
|
};
|
|
2557
2053
|
const formatFieldTypeSearchText = (field) => {
|
|
2558
|
-
if (
|
|
2054
|
+
if (checkObjectKeyExists(field, "type")) {
|
|
2559
2055
|
if (field.type === "search-text") {
|
|
2560
2056
|
field = this.setFieldKeyValue(field, "type", "dropdown-with-search");
|
|
2561
2057
|
}
|
|
@@ -2601,7 +2097,7 @@ class Converter {
|
|
|
2601
2097
|
return object;
|
|
2602
2098
|
};
|
|
2603
2099
|
const formatFieldKeys = (field) => {
|
|
2604
|
-
if (
|
|
2100
|
+
if (checkObjectKeyExists(field, "connectedTo")) {
|
|
2605
2101
|
if (typeof field["connectedTo"] === "string") {
|
|
2606
2102
|
field["connectedElements"] = [
|
|
2607
2103
|
getConnectedElementKeyValueObject(field["connectedTo"])
|
|
@@ -2615,7 +2111,7 @@ class Converter {
|
|
|
2615
2111
|
}
|
|
2616
2112
|
}
|
|
2617
2113
|
this.removeFieldKey(field, "connectedTo");
|
|
2618
|
-
if (
|
|
2114
|
+
if (checkObjectKeyExists(field, "connectedToParent")) {
|
|
2619
2115
|
if (typeof field["connectedToParent"] === "string") {
|
|
2620
2116
|
field["connectedParentFields"] = [
|
|
2621
2117
|
getConnectedElementKeyValueObject(field["connectedToParent"])
|
|
@@ -2631,19 +2127,19 @@ class Converter {
|
|
|
2631
2127
|
};
|
|
2632
2128
|
const getConnectedElementFieldMapping = (field, connectedFieldMapping) => {
|
|
2633
2129
|
const getConnectedElementChildFieldMapping = (field, connectedFieldMapping) => {
|
|
2634
|
-
if (
|
|
2130
|
+
if (checkObjectKeyExists(field, "connectedElements")) {
|
|
2635
2131
|
connectedFieldMapping["child"][field.key] = field.connectedElements;
|
|
2636
2132
|
}
|
|
2637
|
-
else if (
|
|
2133
|
+
else if (checkObjectKeyExists(connectedFieldMapping["child"], field.key)) {
|
|
2638
2134
|
field["connectedElements"] =
|
|
2639
2135
|
connectedFieldMapping["child"][field.key];
|
|
2640
2136
|
}
|
|
2641
2137
|
return { field: field, connectedFieldMapping: connectedFieldMapping };
|
|
2642
2138
|
};
|
|
2643
2139
|
const getConnectedElementParentFieldMapping = (field, connectedFieldMapping) => {
|
|
2644
|
-
if (
|
|
2140
|
+
if (checkObjectKeyExists(connectedFieldMapping["child"], field.key)) {
|
|
2645
2141
|
for (let connectedParentKey of connectedFieldMapping["child"][field.key]) {
|
|
2646
|
-
if (
|
|
2142
|
+
if (checkObjectKeyExists(connectedFieldMapping["parent"], connectedParentKey["key"])) {
|
|
2647
2143
|
connectedFieldMapping["parent"][connectedParentKey["key"]].push(field.key);
|
|
2648
2144
|
}
|
|
2649
2145
|
else {
|
|
@@ -2666,10 +2162,10 @@ class Converter {
|
|
|
2666
2162
|
return connectedFieldMapping;
|
|
2667
2163
|
};
|
|
2668
2164
|
const updateConnectedElementsKeyValue = (field, connectedFieldMapping) => {
|
|
2669
|
-
if (
|
|
2165
|
+
if (checkObjectKeyExists(connectedFieldMapping["child"], field.key)) {
|
|
2670
2166
|
field["connectedElements"] = connectedFieldMapping["child"][field.key];
|
|
2671
2167
|
}
|
|
2672
|
-
if (
|
|
2168
|
+
if (checkObjectKeyExists(connectedFieldMapping["parent"], field.key)) {
|
|
2673
2169
|
field["connectedParentFields"] =
|
|
2674
2170
|
connectedFieldMapping["parent"][field.key];
|
|
2675
2171
|
}
|
|
@@ -2678,45 +2174,47 @@ class Converter {
|
|
|
2678
2174
|
const updateFieldValidatorConfig = (field) => {
|
|
2679
2175
|
var _a, _b, _c, _d, _e;
|
|
2680
2176
|
if (field.type !== "title") {
|
|
2681
|
-
const validators =
|
|
2177
|
+
const validators = checkObjectKeyExists(field, "validators")
|
|
2178
|
+
? field.validators
|
|
2179
|
+
: {};
|
|
2682
2180
|
field = this.setMissingFieldKeyValue(field, "validators", {});
|
|
2683
|
-
field = this.setFieldKeyValue(field, "validators", Object.assign(Object.assign({}, field["validators"]), { min:
|
|
2684
|
-
?
|
|
2181
|
+
field = this.setFieldKeyValue(field, "validators", Object.assign(Object.assign({}, field["validators"]), { min: checkObjectKeyExists(validators, "min")
|
|
2182
|
+
? isNotEmptyValue(validators.min)
|
|
2685
2183
|
? Number(validators.min)
|
|
2686
2184
|
: null
|
|
2687
|
-
:
|
|
2185
|
+
: checkObjectKeyExists(field, "min")
|
|
2688
2186
|
? Number(field.min)
|
|
2689
|
-
: null, max:
|
|
2690
|
-
?
|
|
2187
|
+
: null, max: checkObjectKeyExists(validators, "max")
|
|
2188
|
+
? isNotEmptyValue(validators.max)
|
|
2691
2189
|
? Number(validators.max)
|
|
2692
2190
|
: null
|
|
2693
|
-
:
|
|
2191
|
+
: checkObjectKeyExists(field, "max")
|
|
2694
2192
|
? Number(field.max)
|
|
2695
|
-
: null, required:
|
|
2193
|
+
: null, required: checkObjectKeyExists(validators, "required")
|
|
2696
2194
|
? Boolean(validators.required)
|
|
2697
|
-
:
|
|
2195
|
+
: checkObjectKeyExists(field, "required")
|
|
2698
2196
|
? Boolean(field.required)
|
|
2699
|
-
: false, minLength:
|
|
2700
|
-
?
|
|
2197
|
+
: false, minLength: checkObjectKeyExists(validators, "minLength")
|
|
2198
|
+
? isNotEmptyValue(validators.minLength)
|
|
2701
2199
|
? Number(validators.minLength)
|
|
2702
2200
|
: null
|
|
2703
|
-
:
|
|
2201
|
+
: checkObjectKeyExists(field, "minLength")
|
|
2704
2202
|
? Number(field.minLength)
|
|
2705
|
-
: null, maxLength:
|
|
2706
|
-
?
|
|
2203
|
+
: null, maxLength: checkObjectKeyExists(validators, "maxLength")
|
|
2204
|
+
? isNotEmptyValue(validators.maxLength)
|
|
2707
2205
|
? Number(validators.maxLength)
|
|
2708
2206
|
: null
|
|
2709
|
-
:
|
|
2207
|
+
: checkObjectKeyExists(field, "length")
|
|
2710
2208
|
? Number(field.length)
|
|
2711
|
-
:
|
|
2209
|
+
: checkObjectKeyExists(field, "maxLength")
|
|
2712
2210
|
? Number(field.maxLength)
|
|
2713
|
-
: null, pattern:
|
|
2714
|
-
?
|
|
2211
|
+
: null, pattern: checkObjectKeyExists(validators, "pattern")
|
|
2212
|
+
? isNotEmptyValue(validators.pattern)
|
|
2715
2213
|
? validators.pattern
|
|
2716
2214
|
: undefined
|
|
2717
|
-
:
|
|
2215
|
+
: checkObjectKeyExists(field, "pattern")
|
|
2718
2216
|
? { key: "CUSTOM", pattern: String(field.pattern) }
|
|
2719
|
-
:
|
|
2217
|
+
: checkObjectKeyExists(field, "regex")
|
|
2720
2218
|
? { key: "CUSTOM", pattern: String(field.regex) }
|
|
2721
2219
|
: undefined }));
|
|
2722
2220
|
delete field.min;
|
|
@@ -2735,19 +2233,19 @@ class Converter {
|
|
|
2735
2233
|
default:
|
|
2736
2234
|
break;
|
|
2737
2235
|
}
|
|
2738
|
-
if (
|
|
2236
|
+
if (isEmptyValue((_a = field.validators) === null || _a === void 0 ? void 0 : _a.min)) {
|
|
2739
2237
|
delete field.validators.min;
|
|
2740
2238
|
}
|
|
2741
|
-
if (
|
|
2239
|
+
if (isEmptyValue((_b = field.validators) === null || _b === void 0 ? void 0 : _b.max)) {
|
|
2742
2240
|
delete field.validators.min;
|
|
2743
2241
|
}
|
|
2744
|
-
if (
|
|
2242
|
+
if (isEmptyValue((_c = field.validators) === null || _c === void 0 ? void 0 : _c.minLength)) {
|
|
2745
2243
|
delete field.validators.minLength;
|
|
2746
2244
|
}
|
|
2747
|
-
if (
|
|
2245
|
+
if (isEmptyValue((_d = field.validators) === null || _d === void 0 ? void 0 : _d.maxLength)) {
|
|
2748
2246
|
delete field.validators.maxLength;
|
|
2749
2247
|
}
|
|
2750
|
-
if (
|
|
2248
|
+
if (isEmptyValue((_e = field.validators) === null || _e === void 0 ? void 0 : _e.pattern)) {
|
|
2751
2249
|
delete field.validators.pattern;
|
|
2752
2250
|
}
|
|
2753
2251
|
field.focus = false;
|
|
@@ -2757,14 +2255,14 @@ class Converter {
|
|
|
2757
2255
|
};
|
|
2758
2256
|
const updateFieldDefaultValueConfig = (field) => {
|
|
2759
2257
|
if (field.type !== "title") {
|
|
2760
|
-
if (
|
|
2258
|
+
if (checkObjectKeyExists(field, "defaultValue")) {
|
|
2761
2259
|
return field;
|
|
2762
2260
|
}
|
|
2763
|
-
else if (
|
|
2261
|
+
else if (checkObjectKeyExists(field, "default")) {
|
|
2764
2262
|
return field;
|
|
2765
2263
|
}
|
|
2766
2264
|
else {
|
|
2767
|
-
if (
|
|
2265
|
+
if (checkObjectKeyExists(field, "defaultVal")) {
|
|
2768
2266
|
// Currently below line is commented because it caused issues in setting Default Value.
|
|
2769
2267
|
// field["defaultValue"] = field["defaultVal"];
|
|
2770
2268
|
// delete field["defaultVal"];
|
|
@@ -2809,8 +2307,8 @@ class Converter {
|
|
|
2809
2307
|
]
|
|
2810
2308
|
};
|
|
2811
2309
|
}
|
|
2812
|
-
else if (
|
|
2813
|
-
if (
|
|
2310
|
+
else if (checkObjectKeyExists(field, "autofill")) {
|
|
2311
|
+
if (checkObjectKeyExists(field.autofill, "type")) {
|
|
2814
2312
|
if (field.autofill.type === "storage") {
|
|
2815
2313
|
field["defaultValue"] = {
|
|
2816
2314
|
is_found: false,
|
|
@@ -2943,9 +2441,9 @@ class Converter {
|
|
|
2943
2441
|
};
|
|
2944
2442
|
const updateFieldResetButton = (field) => {
|
|
2945
2443
|
if (field.type === "title") {
|
|
2946
|
-
if (
|
|
2444
|
+
if (checkObjectKeyExists(field, "action") &&
|
|
2947
2445
|
field.action === "reset" &&
|
|
2948
|
-
|
|
2446
|
+
checkObjectKeyExists(field, "fields")) {
|
|
2949
2447
|
field = this.setFieldKeyValue(field, "reset", {
|
|
2950
2448
|
fields: field.fields
|
|
2951
2449
|
});
|
|
@@ -2954,7 +2452,7 @@ class Converter {
|
|
|
2954
2452
|
return field;
|
|
2955
2453
|
};
|
|
2956
2454
|
const setFormFields = (formConfig, fields) => {
|
|
2957
|
-
if (
|
|
2455
|
+
if (checkObjectKeyExists(formConfig, "multiForm")) {
|
|
2958
2456
|
formConfig.multiForm["fields"] = fields;
|
|
2959
2457
|
}
|
|
2960
2458
|
else {
|
|
@@ -2967,8 +2465,8 @@ class Converter {
|
|
|
2967
2465
|
return formConfig;
|
|
2968
2466
|
};
|
|
2969
2467
|
const updateFormFieldGroups = (fieldGroups, field) => {
|
|
2970
|
-
if (
|
|
2971
|
-
if (
|
|
2468
|
+
if (checkObjectKeyExists(field, "groupKey")) {
|
|
2469
|
+
if (checkObjectKeyExists(fieldGroups, field.groupKey)) {
|
|
2972
2470
|
fieldGroups[field.groupKey].push(field.key);
|
|
2973
2471
|
}
|
|
2974
2472
|
else {
|
|
@@ -3065,7 +2563,7 @@ class KwikIDRendererService {
|
|
|
3065
2563
|
markFormInFormsListAsDisabled(formsList, formsListCompleted) {
|
|
3066
2564
|
for (let form of formsList) {
|
|
3067
2565
|
if (form.status !== "completed") {
|
|
3068
|
-
if (
|
|
2566
|
+
if (checkObjectKeyExists(form, "dependentOn")) {
|
|
3069
2567
|
const isDependent = form.dependentOn.every((r) => formsListCompleted.includes(r));
|
|
3070
2568
|
if (isDependent) {
|
|
3071
2569
|
form = setValueToObject(form, "status", "editable");
|
|
@@ -3095,7 +2593,7 @@ class KwikIDRendererService {
|
|
|
3095
2593
|
filterAllFormsData(allFormsData, formsList) {
|
|
3096
2594
|
let currentUserFormAllFormsData = {};
|
|
3097
2595
|
for (let form of formsList) {
|
|
3098
|
-
if (
|
|
2596
|
+
if (checkObjectKeyExists(allFormsData, form.key)) {
|
|
3099
2597
|
currentUserFormAllFormsData = Object.assign(Object.assign({}, currentUserFormAllFormsData), { [form.key]: allFormsData[form.key] });
|
|
3100
2598
|
}
|
|
3101
2599
|
}
|
|
@@ -3218,7 +2716,17 @@ class KwikIDFormsRendererComponent {
|
|
|
3218
2716
|
ngOnInit() {
|
|
3219
2717
|
this.loader = true;
|
|
3220
2718
|
this.loading = true;
|
|
3221
|
-
this.
|
|
2719
|
+
const formStepKey = this.stepConfig.form.key;
|
|
2720
|
+
if (formStepKey !== undefined &&
|
|
2721
|
+
checkObjectKeyExists(this.userConfig.userFormFields, formStepKey)) {
|
|
2722
|
+
this.rendererService.setFormsList(this.userConfig.userFormFields[formStepKey]);
|
|
2723
|
+
}
|
|
2724
|
+
else if (Array.isArray(this.userConfig.userFormFields)) {
|
|
2725
|
+
this.rendererService.setFormsList(this.userConfig.userFormFields);
|
|
2726
|
+
}
|
|
2727
|
+
else {
|
|
2728
|
+
throw new Error(`userFormFields doesn't have a form defined with key: ${formStepKey}`);
|
|
2729
|
+
}
|
|
3222
2730
|
this.initializeForms();
|
|
3223
2731
|
this.loader = false;
|
|
3224
2732
|
}
|
|
@@ -3243,7 +2751,6 @@ class KwikIDFormsRendererComponent {
|
|
|
3243
2751
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3244
2752
|
this.loader = true;
|
|
3245
2753
|
this.rendererService.setAllFormsData(this.formsData);
|
|
3246
|
-
console.log(JSON.parse(JSON.stringify(this.rendererService.formsList)));
|
|
3247
2754
|
this.rendererService.updateFormsList();
|
|
3248
2755
|
this.handleResize(this.rendererService.formsList);
|
|
3249
2756
|
if (this.rendererService.formsList.length !==
|
|
@@ -3308,9 +2815,12 @@ class KwikIDFormsRendererComponent {
|
|
|
3308
2815
|
handleOnClickSubmitForms(e) {
|
|
3309
2816
|
console.log(e);
|
|
3310
2817
|
if (this.userConfig.userFormFieldsConfig.validation) {
|
|
3311
|
-
const validations = new Validations(
|
|
2818
|
+
const validations = new Validations$1({
|
|
2819
|
+
USER_CONFIG: this.userConfig,
|
|
2820
|
+
ALL_FORMS_DATA: this.formsData
|
|
2821
|
+
}, this.takeAction.bind(this));
|
|
3312
2822
|
(() => __awaiter(this, void 0, void 0, function* () {
|
|
3313
|
-
yield validations.
|
|
2823
|
+
yield validations.validate(this.userConfig.userFormFieldsConfig.validation);
|
|
3314
2824
|
if (this.userConfig.userFormFieldsConfig.status === "completed") {
|
|
3315
2825
|
this.onClickSubmit.emit(e);
|
|
3316
2826
|
}
|
|
@@ -3356,11 +2866,14 @@ class KwikIDFormsRendererComponent {
|
|
|
3356
2866
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3357
2867
|
switch (action.key) {
|
|
3358
2868
|
case EActionKey.SET_VALUE:
|
|
3359
|
-
const sources = new Sources(
|
|
2869
|
+
const sources = new Sources({
|
|
2870
|
+
USER_CONFIG: this.userConfig,
|
|
2871
|
+
ALL_FORMS_DATA: this.formsData
|
|
2872
|
+
});
|
|
3360
2873
|
const sourceValue = yield sources.getValueFromSource(action.props.value.source);
|
|
3361
2874
|
sources.setValueToSource(action.props.value.destination, sourceValue);
|
|
3362
|
-
this.userConfig = sources.
|
|
3363
|
-
this.formsData = sources.
|
|
2875
|
+
this.userConfig = sources.object.USER_CONFIG;
|
|
2876
|
+
this.formsData = sources.object.ALL_FORMS_DATA;
|
|
3364
2877
|
break;
|
|
3365
2878
|
default:
|
|
3366
2879
|
break;
|
|
@@ -3369,7 +2882,7 @@ class KwikIDFormsRendererComponent {
|
|
|
3369
2882
|
}
|
|
3370
2883
|
}
|
|
3371
2884
|
/** @nocollapse */ KwikIDFormsRendererComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: KwikIDFormsRendererComponent, deps: [{ token: KwikIDRendererService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
3372
|
-
/** @nocollapse */ KwikIDFormsRendererComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: KwikIDFormsRendererComponent, selector: "kwikid-forms-renderer", inputs: { userConfig: "userConfig", formsData: "formsData", apiCallResponse: "apiCallResponse" }, outputs: { onClickSubmit: "onClickSubmit", getFormData: "getFormData", onClickApiCall: "onClickApiCall" }, host: { listeners: { "window:resize": "windowResizeWatcher($event)" } }, providers: [KwikIDRendererService], usesOnChanges: true, ngImport: i0, template: "<div ngClass=\"kwikid-renderer\">\r\n <div\r\n ngClass=\"kwikid-layout-container\"\r\n *ngIf=\"!loading\"\r\n >\r\n <div\r\n ngClass=\"kwikid-sections-container\"\r\n *ngIf=\"showFormSections\"\r\n class=\"active\"\r\n [class.active]=\"showFormSections\"\r\n [class.mobile]=\"rendererService.isMobileView\"\r\n >\r\n <kwikid-forms-list\r\n [showFormFields]=\"this.showFormFields\"\r\n [userConfig]=\"this.userConfig\"\r\n [formsList]=\"this.rendererService.formsList\"\r\n [formsListCompleted]=\"this.rendererService.formsListCompleted\"\r\n [isMobileView]=\"this.rendererService.isMobileView\"\r\n (onClickSetActiveForm)=\"this.handleOnClickSetActiveForm($event)\"\r\n (onClickSubmitForms)=\"this.handleOnClickSubmitForms($event)\"\r\n ></kwikid-forms-list>\r\n </div>\r\n <div\r\n ngClass=\"kwikid-forms-container\"\r\n *ngIf=\"this.showForm && this.showFormFields\"\r\n [class.active]=\"showFormFields\"\r\n [class.mobile]=\"rendererService.isMobileView\"\r\n [@panelInOut]\r\n >\r\n <kwikid-form-view\r\n [formConfig]=\"this.rendererService.activeFormConfig\"\r\n [formData]=\"this.rendererService.activeFormData\"\r\n [apiCallResponse]=\"this.apiCallResponse\"\r\n [formsList]=\"this.rendererService.formsList\"\r\n [allFormsData]=\"this.rendererService.allFormsData\"\r\n [isMobileView]=\"this.rendererService.isMobileView\"\r\n (onClickApiCall)=\"this.handleOnClickApiCall($event)\"\r\n (onClickViewForms)=\"this.handleOnClickViewForms($event)\"\r\n (onClickSaveForm)=\"this.handleOnClickSaveForm($event)\"\r\n (getActiveFormData)=\"this.handleGetActiveFormData($event)\"\r\n ></kwikid-form-view>\r\n </div>\r\n </div>\r\n</div>\r\n<div\r\n ngClass=\"kwikid-forms-renderer-loader\"\r\n *ngIf=\"loader\"\r\n>\r\n <span class=\"loader\"></span>\r\n</div>\r\n<tui-push\r\n id=\"error-notification\"\r\n *tuiPush=\"showErrorNotification\"\r\n heading=\"Please complete the required Forms!\"\r\n type=\"Error\"\r\n (close)=\"toggleErrorNotification(false)\"\r\n>\r\n <tui-svg\r\n src=\"tuiIconCancel\"\r\n style=\"color: #fff !important\"\r\n >\r\n </tui-svg>\r\n</tui-push>\r\n", styles: [":host{position:relative}.kwikid-root{width:100%;height:100%}.kwikid-renderer{display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;align-content:center;width:100%;height:100%}.kwikid-layout-container{display:flex;flex-direction:row;padding:0 1rem;height:100%;justify-content:center;align-items:stretch;background:var(--tui-secondary);position:relative}.kwikid-sections-container{display:block;width:100%;max-width:400px;height:calc(100% - 2rem);padding:.25rem .5rem 0;border-radius:1rem;background-color:var(--tui-base-01);margin:auto 1rem auto 0;box-shadow:0 0 12px -8px var(--tui-primary)}.kwikid-sections-container.mobile{position:absolute;top:0;left:0;z-index:5;opacity:1;visibility:visible;transition:all 1s;height:100%;border-radius:0;max-width:unset}.kwikid-forms-container{display:block;width:100%;max-width:50%;margin:auto 0;height:calc(100% - 2rem);padding:.25rem .5rem 0;border-radius:1rem;background-color:var(--tui-base-01);box-shadow:0 0 12px -8px var(--tui-primary)}.kwikid-forms-container.mobile{position:absolute;top:0;left:0;z-index:5;opacity:1;visibility:visible;transition:all 1s;height:100%;border-radius:0;max-width:unset}@media screen and (max-width: 600px){.kwikid-layout-container{padding:0;background:transparent}.kwikid-sections-container{position:absolute;max-width:100%;bottom:-10000px;left:-10000px;opacity:0;padding:0;visibility:hidden}.kwikid-sections-container.active{visibility:visible}.kwikid-sections-container.mobile{height:100%;opacity:1;visibility:visible;transition:all 2s;border-radius:0;box-shadow:none;top:0px;margin:0;position:absolute}.kwikid-forms-container{display:none;max-width:100%;height:100%;padding:0;border-radius:0;box-shadow:none}.kwikid-forms-container.mobile{height:100%;opacity:1;visibility:visible;transition:all 2s;border-radius:0;box-shadow:none;top:0px;margin:0;position:absolute}.kwikid-forms-container.active{display:block}}.kwikid-forms-renderer-loader{position:absolute;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.75);display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center;z-index:100}.kwikid-forms-renderer-loader .loader{width:48px;height:48px;border-radius:50%;display:inline-block;position:relative;border:3px solid;border-color:#fff #fff transparent;box-sizing:border-box;animation:rotation 1s linear infinite}.kwikid-forms-renderer-loader .loader:after{content:\"\";box-sizing:border-box;position:absolute;left:0;right:0;top:0;bottom:0;margin:auto;border:3px solid;border-color:transparent var(--tui-primary) var(--tui-primary);width:24px;height:24px;border-radius:50%;animation:rotationBack .5s linear infinite;transform-origin:center center}@keyframes rotation{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes rotationBack{0%{transform:rotate(0)}to{transform:rotate(-360deg)}}.kwikid-forms-renderer-loader .t-loader{display:none!important}#error-notification{background-color:var(--tui-error-fill);color:#fff!important}#error-notification .t-top{color:#fff!important}#error-notification .t-close{color:#fff!important}\n"], components: [{ type: KwikIDFormsListComponent, selector: "kwikid-forms-list", inputs: ["showFormFields", "userConfig", "formsList", "formsListCompleted", "isMobileView"], outputs: ["onClickSetActiveForm", "onClickHideFormsList", "onClickSubmitForms"] }, { type: KwikIDFormViewComponent, selector: "kwikid-form-view", inputs: ["formConfig", "formData", "apiCallResponse", "isMobileView", "allFormsData", "formsList"], outputs: ["onClickViewForms", "onClickSaveForm", "onClickApiCall", "getActiveFormData"] }, { type: i4.TuiPushComponent, selector: "tui-push", inputs: ["heading", "type", "timestamp"], outputs: ["close"] }, { type: i3.TuiSvgComponent, selector: "tui-svg", inputs: ["src"] }], directives: [{ type: i5.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.TuiPushAlertDirective, selector: "[tuiPush]", inputs: ["tuiPush"] }, { type: i4.TuiPushDirective, selector: "tui-push" }], animations: [
|
|
2885
|
+
/** @nocollapse */ KwikIDFormsRendererComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: KwikIDFormsRendererComponent, selector: "kwikid-forms-renderer", inputs: { stepConfig: "stepConfig", userConfig: "userConfig", formsData: "formsData", apiCallResponse: "apiCallResponse" }, outputs: { onClickSubmit: "onClickSubmit", getFormData: "getFormData", onClickApiCall: "onClickApiCall" }, host: { listeners: { "window:resize": "windowResizeWatcher($event)" } }, providers: [KwikIDRendererService], usesOnChanges: true, ngImport: i0, template: "<div ngClass=\"kwikid-renderer\">\r\n <div\r\n ngClass=\"kwikid-layout-container\"\r\n *ngIf=\"!loading\"\r\n >\r\n <div\r\n ngClass=\"kwikid-sections-container\"\r\n *ngIf=\"showFormSections\"\r\n class=\"active\"\r\n [class.active]=\"showFormSections\"\r\n [class.mobile]=\"rendererService.isMobileView\"\r\n >\r\n <kwikid-forms-list\r\n [showFormFields]=\"this.showFormFields\"\r\n [userConfig]=\"this.userConfig\"\r\n [formsList]=\"this.rendererService.formsList\"\r\n [formsListCompleted]=\"this.rendererService.formsListCompleted\"\r\n [isMobileView]=\"this.rendererService.isMobileView\"\r\n (onClickSetActiveForm)=\"this.handleOnClickSetActiveForm($event)\"\r\n (onClickSubmitForms)=\"this.handleOnClickSubmitForms($event)\"\r\n ></kwikid-forms-list>\r\n </div>\r\n <div\r\n ngClass=\"kwikid-forms-container\"\r\n *ngIf=\"this.showForm && this.showFormFields\"\r\n [class.active]=\"showFormFields\"\r\n [class.mobile]=\"rendererService.isMobileView\"\r\n [@panelInOut]\r\n >\r\n <kwikid-form-view\r\n [formConfig]=\"this.rendererService.activeFormConfig\"\r\n [formData]=\"this.rendererService.activeFormData\"\r\n [apiCallResponse]=\"this.apiCallResponse\"\r\n [formsList]=\"this.rendererService.formsList\"\r\n [allFormsData]=\"this.rendererService.allFormsData\"\r\n [isMobileView]=\"this.rendererService.isMobileView\"\r\n (onClickApiCall)=\"this.handleOnClickApiCall($event)\"\r\n (onClickViewForms)=\"this.handleOnClickViewForms($event)\"\r\n (onClickSaveForm)=\"this.handleOnClickSaveForm($event)\"\r\n (getActiveFormData)=\"this.handleGetActiveFormData($event)\"\r\n ></kwikid-form-view>\r\n </div>\r\n </div>\r\n</div>\r\n<div\r\n ngClass=\"kwikid-forms-renderer-loader\"\r\n *ngIf=\"loader\"\r\n>\r\n <span class=\"loader\"></span>\r\n</div>\r\n<tui-push\r\n id=\"error-notification\"\r\n *tuiPush=\"showErrorNotification\"\r\n heading=\"Please complete the required Forms!\"\r\n type=\"Error\"\r\n (close)=\"toggleErrorNotification(false)\"\r\n>\r\n <tui-svg\r\n src=\"tuiIconCancel\"\r\n style=\"color: #fff !important\"\r\n >\r\n </tui-svg>\r\n</tui-push>\r\n", styles: [":host{position:relative}.kwikid-root{width:100%;height:100%}.kwikid-renderer{display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;align-content:center;width:100%;height:100%}.kwikid-layout-container{display:flex;flex-direction:row;padding:0 1rem;height:100%;justify-content:center;align-items:stretch;background:var(--tui-secondary);position:relative}.kwikid-sections-container{display:block;width:100%;max-width:400px;height:calc(100% - 2rem);padding:.25rem .5rem 0;border-radius:1rem;background-color:var(--tui-base-01);margin:auto 1rem auto 0;box-shadow:0 0 12px -8px var(--tui-primary)}.kwikid-sections-container.mobile{position:absolute;top:0;left:0;z-index:5;opacity:1;visibility:visible;transition:all 1s;height:100%;border-radius:0;max-width:unset}.kwikid-forms-container{display:block;width:100%;max-width:50%;margin:auto 0;height:calc(100% - 2rem);padding:.25rem .5rem 0;border-radius:1rem;background-color:var(--tui-base-01);box-shadow:0 0 12px -8px var(--tui-primary)}.kwikid-forms-container.mobile{position:absolute;top:0;left:0;z-index:5;opacity:1;visibility:visible;transition:all 1s;height:100%;border-radius:0;max-width:unset}@media screen and (max-width: 600px){.kwikid-layout-container{padding:0;background:transparent}.kwikid-sections-container{position:absolute;max-width:100%;bottom:-10000px;left:-10000px;opacity:0;padding:0;visibility:hidden}.kwikid-sections-container.active{visibility:visible}.kwikid-sections-container.mobile{height:100%;opacity:1;visibility:visible;transition:all 2s;border-radius:0;box-shadow:none;top:0px;margin:0;position:absolute}.kwikid-forms-container{display:none;max-width:100%;height:100%;padding:0;border-radius:0;box-shadow:none}.kwikid-forms-container.mobile{height:100%;opacity:1;visibility:visible;transition:all 2s;border-radius:0;box-shadow:none;top:0px;margin:0;position:absolute}.kwikid-forms-container.active{display:block}}.kwikid-forms-renderer-loader{position:absolute;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.75);display:flex;flex-direction:row;align-content:center;justify-content:center;align-items:center;z-index:100}.kwikid-forms-renderer-loader .loader{width:48px;height:48px;border-radius:50%;display:inline-block;position:relative;border:3px solid;border-color:#fff #fff transparent;box-sizing:border-box;animation:rotation 1s linear infinite}.kwikid-forms-renderer-loader .loader:after{content:\"\";box-sizing:border-box;position:absolute;left:0;right:0;top:0;bottom:0;margin:auto;border:3px solid;border-color:transparent var(--tui-primary) var(--tui-primary);width:24px;height:24px;border-radius:50%;animation:rotationBack .5s linear infinite;transform-origin:center center}@keyframes rotation{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes rotationBack{0%{transform:rotate(0)}to{transform:rotate(-360deg)}}.kwikid-forms-renderer-loader .t-loader{display:none!important}#error-notification{background-color:var(--tui-error-fill);color:#fff!important}#error-notification .t-top{color:#fff!important}#error-notification .t-close{color:#fff!important}\n"], components: [{ type: KwikIDFormsListComponent, selector: "kwikid-forms-list", inputs: ["showFormFields", "userConfig", "formsList", "formsListCompleted", "isMobileView"], outputs: ["onClickSetActiveForm", "onClickHideFormsList", "onClickSubmitForms"] }, { type: KwikIDFormViewComponent, selector: "kwikid-form-view", inputs: ["formConfig", "formData", "apiCallResponse", "isMobileView", "allFormsData", "formsList"], outputs: ["onClickViewForms", "onClickSaveForm", "onClickApiCall", "getActiveFormData"] }, { type: i4.TuiPushComponent, selector: "tui-push", inputs: ["heading", "type", "timestamp"], outputs: ["close"] }, { type: i3.TuiSvgComponent, selector: "tui-svg", inputs: ["src"] }], directives: [{ type: i5.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.TuiPushAlertDirective, selector: "[tuiPush]", inputs: ["tuiPush"] }, { type: i4.TuiPushDirective, selector: "tui-push" }], animations: [
|
|
3373
2886
|
trigger("panelInOut", [
|
|
3374
2887
|
transition(":enter", [
|
|
3375
2888
|
style({ transform: "translateY(100%)" }),
|
|
@@ -3405,6 +2918,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
|
|
|
3405
2918
|
}], ctorParameters: function () { return [{ type: KwikIDRendererService }, { type: i0.ElementRef }]; }, propDecorators: { windowResizeWatcher: [{
|
|
3406
2919
|
type: HostListener,
|
|
3407
2920
|
args: ["window:resize", ["$event"]]
|
|
2921
|
+
}], stepConfig: [{
|
|
2922
|
+
type: Input
|
|
3408
2923
|
}], userConfig: [{
|
|
3409
2924
|
type: Input
|
|
3410
2925
|
}], formsData: [{
|