dino-forms 1.0.3 → 1.0.4
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/dino-forms.umd.js +2174 -2174
- package/bundles/dino-forms.umd.js.map +1 -1
- package/dino-forms.d.ts +5 -5
- package/esm2015/dino-forms.js +4 -4
- package/esm2015/lib/common/constants/comparison.operators.js +10 -10
- package/esm2015/lib/common/constants/constants.js +19 -19
- package/esm2015/lib/common/constants/generic-input-type.js +14 -14
- package/esm2015/lib/common/constants/logical.operators.js +5 -5
- package/esm2015/lib/common/constants/validation.js +10 -10
- package/esm2015/lib/common/custom-validators/custom.validator.js +15 -15
- package/esm2015/lib/common/error/app-error-handler.js +7 -7
- package/esm2015/lib/common/error/app-error.js +6 -6
- package/esm2015/lib/common/error/bad-request-error.js +4 -4
- package/esm2015/lib/common/error/invalid-user-error.js +4 -4
- package/esm2015/lib/common/error/not-found-error.js +4 -4
- package/esm2015/lib/common/utilities/expressions.utility.js +255 -255
- package/esm2015/lib/common/utilities/form.utility.js +143 -143
- package/esm2015/lib/common/utilities/object.utility.js +23 -23
- package/esm2015/lib/common/validators.js +51 -51
- package/esm2015/lib/components/accordion-form/accordion-form.component.js +150 -150
- package/esm2015/lib/components/alert/alert.component.js +27 -27
- package/esm2015/lib/components/expressions-form/expressions-form.component.js +246 -246
- package/esm2015/lib/components/form/form.component.js +175 -175
- package/esm2015/lib/components/modal-form/modal-form.component.js +121 -121
- package/esm2015/lib/components/tab-form/tab-form.component.js +200 -200
- package/esm2015/lib/dino-forms.module.js +70 -70
- package/esm2015/lib/services/data.service.js +72 -72
- package/esm2015/public-api.js +14 -14
- package/fesm2015/dino-forms.js +1502 -1502
- package/fesm2015/dino-forms.js.map +1 -1
- package/lib/common/constants/comparison.operators.d.ts +9 -9
- package/lib/common/constants/constants.d.ts +18 -18
- package/lib/common/constants/generic-input-type.d.ts +13 -13
- package/lib/common/constants/logical.operators.d.ts +4 -4
- package/lib/common/constants/validation.d.ts +9 -9
- package/lib/common/custom-validators/custom.validator.d.ts +6 -6
- package/lib/common/error/app-error-handler.d.ts +4 -4
- package/lib/common/error/app-error.d.ts +4 -4
- package/lib/common/error/bad-request-error.d.ts +3 -3
- package/lib/common/error/invalid-user-error.d.ts +3 -3
- package/lib/common/error/not-found-error.d.ts +3 -3
- package/lib/common/utilities/expressions.utility.d.ts +19 -19
- package/lib/common/utilities/form.utility.d.ts +14 -14
- package/lib/common/utilities/object.utility.d.ts +5 -5
- package/lib/common/validators.d.ts +4 -4
- package/lib/components/accordion-form/accordion-form.component.d.ts +39 -39
- package/lib/components/alert/alert.component.d.ts +12 -12
- package/lib/components/expressions-form/expressions-form.component.d.ts +58 -58
- package/lib/components/form/form.component.d.ts +51 -51
- package/lib/components/modal-form/modal-form.component.d.ts +38 -38
- package/lib/components/tab-form/tab-form.component.d.ts +45 -45
- package/lib/dino-forms.module.d.ts +15 -15
- package/lib/services/data.service.d.ts +17 -17
- package/package.json +1 -1
- package/public-api.d.ts +8 -8
package/fesm2015/dino-forms.js
CHANGED
|
@@ -9,1556 +9,1556 @@ import { map, catchError } from 'rxjs/operators';
|
|
|
9
9
|
import * as i1 from '@angular/common/http';
|
|
10
10
|
import { BrowserModule } from '@angular/platform-browser';
|
|
11
11
|
|
|
12
|
-
class ObjectUtility {
|
|
13
|
-
static isEmpty(value) {
|
|
14
|
-
if (value == {} || value == undefined || value == null || value == "" || value == [])
|
|
15
|
-
return true;
|
|
16
|
-
if (this.isArray(value)) {
|
|
17
|
-
for (let element of value) {
|
|
18
|
-
if (!this.isEmpty(element))
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
static isArray(value) {
|
|
26
|
-
return Array.isArray(value);
|
|
27
|
-
}
|
|
28
|
-
static includes(array, value) {
|
|
29
|
-
if (this.isEmpty(array))
|
|
30
|
-
return false;
|
|
31
|
-
return array.includes(value);
|
|
32
|
-
}
|
|
12
|
+
class ObjectUtility {
|
|
13
|
+
static isEmpty(value) {
|
|
14
|
+
if (value == {} || value == undefined || value == null || value == "" || value == [])
|
|
15
|
+
return true;
|
|
16
|
+
if (this.isArray(value)) {
|
|
17
|
+
for (let element of value) {
|
|
18
|
+
if (!this.isEmpty(element))
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
static isArray(value) {
|
|
26
|
+
return Array.isArray(value);
|
|
27
|
+
}
|
|
28
|
+
static includes(array, value) {
|
|
29
|
+
if (this.isEmpty(array))
|
|
30
|
+
return false;
|
|
31
|
+
return array.includes(value);
|
|
32
|
+
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
class AlertComponent {
|
|
36
|
-
constructor() { }
|
|
37
|
-
ngOnInit() {
|
|
38
|
-
}
|
|
39
|
-
isEmpty(value) {
|
|
40
|
-
return ObjectUtility.isEmpty(value);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/** @nocollapse */ AlertComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: AlertComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
44
|
-
/** @nocollapse */ AlertComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: AlertComponent, selector: "df-alert", inputs: { form: "form", input: "input" }, ngImport: i0, template: "<div *ngIf=\"!isEmpty(form.get(input.id)) && form.get(input.id).touched && form.get(input.id).invalid\" class=\"alert alert-danger mt-2\">\
|
|
45
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: AlertComponent, decorators: [{
|
|
46
|
-
type: Component,
|
|
47
|
-
args: [{
|
|
48
|
-
selector: 'df-alert',
|
|
49
|
-
templateUrl: './alert.component.html',
|
|
50
|
-
styleUrls: ['./alert.component.scss']
|
|
51
|
-
}]
|
|
52
|
-
}], ctorParameters: function () { return []; }, propDecorators: { form: [{
|
|
53
|
-
type: Input
|
|
54
|
-
}], input: [{
|
|
55
|
-
type: Input
|
|
35
|
+
class AlertComponent {
|
|
36
|
+
constructor() { }
|
|
37
|
+
ngOnInit() {
|
|
38
|
+
}
|
|
39
|
+
isEmpty(value) {
|
|
40
|
+
return ObjectUtility.isEmpty(value);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** @nocollapse */ AlertComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: AlertComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
44
|
+
/** @nocollapse */ AlertComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: AlertComponent, selector: "df-alert", inputs: { form: "form", input: "input" }, ngImport: i0, template: "<div *ngIf=\"!isEmpty(form.get(input.id)) && form.get(input.id).touched && form.get(input.id).invalid\" class=\"alert alert-danger mt-2\">\n <div *ngIf=\"form.get(input.id).errors.required\">{{input.label}} is required.</div>\n <div *ngIf=\"form.get(input.id).errors.multipleCheckboxRequireOne\">At least one option is required for {{input.label}}.</div>\n <div *ngIf=\"form.get(input.id).errors.minlength\">{{input.label}} minimum length is {{form.get(input.id).errors.minlength.requiredLength}}.</div>\n <div *ngIf=\"form.get(input.id).errors.maxlength\">{{input.label}} maximum length is {{form.get(input.id).errors.maxlength.requiredLength}}.</div>\n <div *ngIf=\"form.get(input.id).errors.min\">{{input.label}} min value is {{form.get(input.id).errors.min.min}}.</div>\n <div *ngIf=\"form.get(input.id).errors.max\">{{input.label}} max value is {{form.get(input.id).errors.max.max}}.</div>\n <div *ngIf=\"form.get(input.id).errors.email\">{{input.label}} is invalid.</div>\n <div *ngIf=\"form.get(input.id).errors.pattern\">{{input.label}} is invalid.</div>\n</div>\n<div *ngIf=\"!isEmpty(input) && \n input.prerequired!==undefined &&\n input.prerequired.id!==undefined &&\n input.prerequired.label!==undefined &&\n (form.get(input.prerequired.id).value==='' ||\n form.get(input.prerequired.id).value===null) &&\n (!isEmpty(form.get(input.id)) && \n form.get(input.id).touched &&\n form.get(input.id).value!=='')\" class=\"alert alert-danger mt-2\">\n Please provide {{input.prerequired.label}}.\n {{form.setErrors({'incorrect':true})}}\n</div>", styles: [""], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
45
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: AlertComponent, decorators: [{
|
|
46
|
+
type: Component,
|
|
47
|
+
args: [{
|
|
48
|
+
selector: 'df-alert',
|
|
49
|
+
templateUrl: './alert.component.html',
|
|
50
|
+
styleUrls: ['./alert.component.scss']
|
|
51
|
+
}]
|
|
52
|
+
}], ctorParameters: function () { return []; }, propDecorators: { form: [{
|
|
53
|
+
type: Input
|
|
54
|
+
}], input: [{
|
|
55
|
+
type: Input
|
|
56
56
|
}] } });
|
|
57
57
|
|
|
58
|
-
class Constants {
|
|
59
|
-
}
|
|
60
|
-
Constants.EMPTY_SPACE = "";
|
|
61
|
-
Constants.VERTICAL_BAR = "|";
|
|
62
|
-
Constants.BACK_SLASH = "/";
|
|
63
|
-
Constants.LEFT_PARENTHESIS = "(";
|
|
64
|
-
Constants.RIGHT_PARENTHESIS = ")";
|
|
65
|
-
Constants.LEFT_CURLY_BRACE = "{";
|
|
66
|
-
Constants.RIGHT_CURLY_BRACE = "}";
|
|
67
|
-
Constants.CONTROL_PREFIX = "control::";
|
|
68
|
-
Constants.MAX_LEVELS = 30;
|
|
69
|
-
Constants.ALERT_TIMEOUT = 3000;
|
|
70
|
-
Constants.START_LEVEL = "Level[";
|
|
71
|
-
Constants.END_LEVEL = "]: ";
|
|
72
|
-
Constants.VALIDATOR_SPLITTER = "::";
|
|
73
|
-
Constants.AMPERSAND = "&";
|
|
74
|
-
Constants.EQUAL = "=";
|
|
58
|
+
class Constants {
|
|
59
|
+
}
|
|
60
|
+
Constants.EMPTY_SPACE = "";
|
|
61
|
+
Constants.VERTICAL_BAR = "|";
|
|
62
|
+
Constants.BACK_SLASH = "/";
|
|
63
|
+
Constants.LEFT_PARENTHESIS = "(";
|
|
64
|
+
Constants.RIGHT_PARENTHESIS = ")";
|
|
65
|
+
Constants.LEFT_CURLY_BRACE = "{";
|
|
66
|
+
Constants.RIGHT_CURLY_BRACE = "}";
|
|
67
|
+
Constants.CONTROL_PREFIX = "control::";
|
|
68
|
+
Constants.MAX_LEVELS = 30;
|
|
69
|
+
Constants.ALERT_TIMEOUT = 3000;
|
|
70
|
+
Constants.START_LEVEL = "Level[";
|
|
71
|
+
Constants.END_LEVEL = "]: ";
|
|
72
|
+
Constants.VALIDATOR_SPLITTER = "::";
|
|
73
|
+
Constants.AMPERSAND = "&";
|
|
74
|
+
Constants.EQUAL = "=";
|
|
75
75
|
Constants.QUESTION_MARK = "?";
|
|
76
76
|
|
|
77
|
-
class GenericInputType {
|
|
78
|
-
}
|
|
79
|
-
GenericInputType.TEXT = "text";
|
|
80
|
-
GenericInputType.NUMBER = "number";
|
|
81
|
-
GenericInputType.DATE = "date";
|
|
82
|
-
GenericInputType.PASSWORD = "password";
|
|
83
|
-
GenericInputType.TEXTAREA = "textarea";
|
|
84
|
-
GenericInputType.RADIO = "radio";
|
|
85
|
-
GenericInputType.CHECKBOX = "checkbox";
|
|
86
|
-
GenericInputType.COMBOBOX = "combobox";
|
|
87
|
-
GenericInputType.BUTTON = "button";
|
|
88
|
-
GenericInputType.SUBMIT = "submit";
|
|
77
|
+
class GenericInputType {
|
|
78
|
+
}
|
|
79
|
+
GenericInputType.TEXT = "text";
|
|
80
|
+
GenericInputType.NUMBER = "number";
|
|
81
|
+
GenericInputType.DATE = "date";
|
|
82
|
+
GenericInputType.PASSWORD = "password";
|
|
83
|
+
GenericInputType.TEXTAREA = "textarea";
|
|
84
|
+
GenericInputType.RADIO = "radio";
|
|
85
|
+
GenericInputType.CHECKBOX = "checkbox";
|
|
86
|
+
GenericInputType.COMBOBOX = "combobox";
|
|
87
|
+
GenericInputType.BUTTON = "button";
|
|
88
|
+
GenericInputType.SUBMIT = "submit";
|
|
89
89
|
GenericInputType.RESET = "reset";
|
|
90
90
|
|
|
91
|
-
class Validation {
|
|
92
|
-
}
|
|
93
|
-
Validation.REQUIRED = "required";
|
|
94
|
-
Validation.MINLENGTH = "minlength";
|
|
95
|
-
Validation.MAXLENGTH = "maxlength";
|
|
96
|
-
Validation.MIN = "min";
|
|
97
|
-
Validation.MAX = "max";
|
|
98
|
-
Validation.EMAIL = "email";
|
|
91
|
+
class Validation {
|
|
92
|
+
}
|
|
93
|
+
Validation.REQUIRED = "required";
|
|
94
|
+
Validation.MINLENGTH = "minlength";
|
|
95
|
+
Validation.MAXLENGTH = "maxlength";
|
|
96
|
+
Validation.MIN = "min";
|
|
97
|
+
Validation.MAX = "max";
|
|
98
|
+
Validation.EMAIL = "email";
|
|
99
99
|
Validation.PATTERN = "pattern";
|
|
100
100
|
|
|
101
|
-
class FormValidators {
|
|
102
|
-
static getValidators(validators) {
|
|
103
|
-
let validatorObjects = null;
|
|
104
|
-
if (!ObjectUtility.isEmpty(validators)) {
|
|
105
|
-
validatorObjects = [];
|
|
106
|
-
for (let validator of validators) {
|
|
107
|
-
let validatorObject;
|
|
108
|
-
if (validator.indexOf(Constants.VALIDATOR_SPLITTER) > -1)
|
|
109
|
-
validatorObject = this.getValidator(validator.split(Constants.VALIDATOR_SPLITTER)[0]);
|
|
110
|
-
else
|
|
111
|
-
validatorObject = this.getValidator(validator);
|
|
112
|
-
if (!ObjectUtility.isEmpty(validatorObject))
|
|
113
|
-
validatorObjects.push(validatorObject);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return validatorObjects;
|
|
117
|
-
}
|
|
118
|
-
static getValidator(validator) {
|
|
119
|
-
if (validator === Validation.REQUIRED) {
|
|
120
|
-
return Validators.required;
|
|
121
|
-
}
|
|
122
|
-
else if (validator.indexOf(Validation.MINLENGTH) !== -1) {
|
|
123
|
-
let values = validator.split(Constants.VERTICAL_BAR);
|
|
124
|
-
return Validators.minLength(Number(values[1]));
|
|
125
|
-
}
|
|
126
|
-
else if (validator.indexOf(Validation.MAXLENGTH) !== -1) {
|
|
127
|
-
let values = validator.split(Constants.VERTICAL_BAR);
|
|
128
|
-
return Validators.maxLength(Number(values[1]));
|
|
129
|
-
}
|
|
130
|
-
else if (validator.indexOf(Validation.MIN) !== -1) {
|
|
131
|
-
let values = validator.split(Constants.VERTICAL_BAR);
|
|
132
|
-
return Validators.min(Number(values[1]));
|
|
133
|
-
}
|
|
134
|
-
else if (validator.indexOf(Validation.MAX) !== -1) {
|
|
135
|
-
let values = validator.split(Constants.VERTICAL_BAR);
|
|
136
|
-
return Validators.max(Number(values[1]));
|
|
137
|
-
}
|
|
138
|
-
else if (validator.indexOf(Validation.EMAIL) !== -1) {
|
|
139
|
-
return Validators.email;
|
|
140
|
-
}
|
|
141
|
-
else if (validator.indexOf(Validation.PATTERN) !== -1) {
|
|
142
|
-
let values = validator.split(Constants.VERTICAL_BAR);
|
|
143
|
-
return Validators.pattern(values[1]);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
101
|
+
class FormValidators {
|
|
102
|
+
static getValidators(validators) {
|
|
103
|
+
let validatorObjects = null;
|
|
104
|
+
if (!ObjectUtility.isEmpty(validators)) {
|
|
105
|
+
validatorObjects = [];
|
|
106
|
+
for (let validator of validators) {
|
|
107
|
+
let validatorObject;
|
|
108
|
+
if (validator.indexOf(Constants.VALIDATOR_SPLITTER) > -1)
|
|
109
|
+
validatorObject = this.getValidator(validator.split(Constants.VALIDATOR_SPLITTER)[0]);
|
|
110
|
+
else
|
|
111
|
+
validatorObject = this.getValidator(validator);
|
|
112
|
+
if (!ObjectUtility.isEmpty(validatorObject))
|
|
113
|
+
validatorObjects.push(validatorObject);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return validatorObjects;
|
|
117
|
+
}
|
|
118
|
+
static getValidator(validator) {
|
|
119
|
+
if (validator === Validation.REQUIRED) {
|
|
120
|
+
return Validators.required;
|
|
121
|
+
}
|
|
122
|
+
else if (validator.indexOf(Validation.MINLENGTH) !== -1) {
|
|
123
|
+
let values = validator.split(Constants.VERTICAL_BAR);
|
|
124
|
+
return Validators.minLength(Number(values[1]));
|
|
125
|
+
}
|
|
126
|
+
else if (validator.indexOf(Validation.MAXLENGTH) !== -1) {
|
|
127
|
+
let values = validator.split(Constants.VERTICAL_BAR);
|
|
128
|
+
return Validators.maxLength(Number(values[1]));
|
|
129
|
+
}
|
|
130
|
+
else if (validator.indexOf(Validation.MIN) !== -1) {
|
|
131
|
+
let values = validator.split(Constants.VERTICAL_BAR);
|
|
132
|
+
return Validators.min(Number(values[1]));
|
|
133
|
+
}
|
|
134
|
+
else if (validator.indexOf(Validation.MAX) !== -1) {
|
|
135
|
+
let values = validator.split(Constants.VERTICAL_BAR);
|
|
136
|
+
return Validators.max(Number(values[1]));
|
|
137
|
+
}
|
|
138
|
+
else if (validator.indexOf(Validation.EMAIL) !== -1) {
|
|
139
|
+
return Validators.email;
|
|
140
|
+
}
|
|
141
|
+
else if (validator.indexOf(Validation.PATTERN) !== -1) {
|
|
142
|
+
let values = validator.split(Constants.VERTICAL_BAR);
|
|
143
|
+
return Validators.pattern(values[1]);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
class CustomValidator {
|
|
149
|
-
static multipleCheckboxRequireOne(fa) {
|
|
150
|
-
let valid = false;
|
|
151
|
-
for (let x = 0; x < fa.length; ++x) {
|
|
152
|
-
if (fa.at(x).value) {
|
|
153
|
-
valid = true;
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return valid ? null : {
|
|
158
|
-
multipleCheckboxRequireOne: true
|
|
159
|
-
};
|
|
160
|
-
}
|
|
148
|
+
class CustomValidator {
|
|
149
|
+
static multipleCheckboxRequireOne(fa) {
|
|
150
|
+
let valid = false;
|
|
151
|
+
for (let x = 0; x < fa.length; ++x) {
|
|
152
|
+
if (fa.at(x).value) {
|
|
153
|
+
valid = true;
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return valid ? null : {
|
|
158
|
+
multipleCheckboxRequireOne: true
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
class FormsUtility {
|
|
164
|
-
static updateCheckboxValue(form, formArrayName, controlName, checked, value) {
|
|
165
|
-
let formArr = form.controls[formArrayName];
|
|
166
|
-
if (!checked) {
|
|
167
|
-
formArr.controls[controlName].setValue(null);
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
formArr.controls[controlName].setValue(value);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
static updateRadioValue(form, controlName, checked, optionId) {
|
|
174
|
-
let control = form.controls[controlName];
|
|
175
|
-
if (!checked) {
|
|
176
|
-
control.setValue(Constants.EMPTY_SPACE);
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
control.setValue(optionId);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
static isCheckBoxChecked(form, controlName, optionId) {
|
|
183
|
-
let checked = null;
|
|
184
|
-
let formArr = form.controls[controlName];
|
|
185
|
-
let formControl = formArr.controls[optionId];
|
|
186
|
-
if (!ObjectUtility.isEmpty(formControl))
|
|
187
|
-
checked = formControl.value;
|
|
188
|
-
if (!ObjectUtility.isEmpty(checked))
|
|
189
|
-
return checked;
|
|
190
|
-
else
|
|
191
|
-
return null;
|
|
192
|
-
}
|
|
193
|
-
static isRadioChecked(form, controlName, optionId) {
|
|
194
|
-
let checked = null;
|
|
195
|
-
let formControl = form.controls[controlName];
|
|
196
|
-
if (!ObjectUtility.isEmpty(formControl))
|
|
197
|
-
checked = formControl.value;
|
|
198
|
-
if (!ObjectUtility.isEmpty(checked) && checked == optionId)
|
|
199
|
-
return true;
|
|
200
|
-
else
|
|
201
|
-
return false;
|
|
202
|
-
}
|
|
203
|
-
static buildFromGroup(fields, disabled) {
|
|
204
|
-
let form = new FormGroup({});
|
|
205
|
-
if (!ObjectUtility.isEmpty(fields))
|
|
206
|
-
for (const group of Array.from(fields)) {
|
|
207
|
-
console.log("group>",
|
|
208
|
-
for (const input of group === null || group === void 0 ? void 0 : group.groupFields) {
|
|
209
|
-
if (input.id !== undefined) {
|
|
210
|
-
if (input.type !== undefined && input.type === GenericInputType.CHECKBOX) {
|
|
211
|
-
form.addControl(input.id, this.getCheckBoxFormArray(input));
|
|
212
|
-
if (!ObjectUtility.isEmpty(input.value)) {
|
|
213
|
-
form.controls[input.id].reset(input.value);
|
|
214
|
-
form.controls[input.id].updateValueAndValidity();
|
|
215
|
-
}
|
|
216
|
-
if (input.disabled || disabled) {
|
|
217
|
-
form.controls[input.id].disable();
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
if (input.type !== undefined && (input.type === GenericInputType.RADIO ||
|
|
221
|
-
input.type === GenericInputType.DATE ||
|
|
222
|
-
input.type === GenericInputType.COMBOBOX)) {
|
|
223
|
-
form.addControl(input.id, new FormControl((!ObjectUtility.isEmpty(input.value)) ? input.value : Constants.EMPTY_SPACE, (!input.hidden && (input.required || ObjectUtility.includes(input.validators, Validation.REQUIRED))) ? FormValidators.getValidators([Validation.REQUIRED]) : null));
|
|
224
|
-
if (input.disabled || disabled) {
|
|
225
|
-
form.controls[input.id].disable();
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
form.addControl(input.id, new FormControl((!ObjectUtility.isEmpty(input.value)) ? input.value : Constants.EMPTY_SPACE, (!input.hidden) ? FormValidators.getValidators(input.validators) : null));
|
|
230
|
-
if (input.disabled || disabled) {
|
|
231
|
-
form.controls[input.id].disable();
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
return form;
|
|
238
|
-
}
|
|
239
|
-
static getCheckBoxFormArray(input) {
|
|
240
|
-
let fb = new FormBuilder();
|
|
241
|
-
return fb.array(input.options.map(() => fb.control(null, null)), (!input.hidden) ? this.getCheckBoxValidator(input) : null);
|
|
242
|
-
}
|
|
243
|
-
static getCheckBoxValidator(input) {
|
|
244
|
-
if (!input.hidden && (input.required || ObjectUtility.includes(input.validators, Validation.REQUIRED))) {
|
|
245
|
-
return CustomValidator.multipleCheckboxRequireOne;
|
|
246
|
-
}
|
|
247
|
-
return null;
|
|
248
|
-
}
|
|
249
|
-
static includeRequired(validators) {
|
|
250
|
-
if (!ObjectUtility.isEmpty(validators)) {
|
|
251
|
-
for (const validator of Array.from(validators)) {
|
|
252
|
-
if (validator === Validation.REQUIRED) {
|
|
253
|
-
return true;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
return false;
|
|
258
|
-
}
|
|
259
|
-
static resetForm(fields, form) {
|
|
260
|
-
if (!ObjectUtility.isEmpty(fields))
|
|
261
|
-
for (const group of Array.from(fields)) {
|
|
262
|
-
for (const input of group === null || group === void 0 ? void 0 : group.groupFields) {
|
|
263
|
-
if (!ObjectUtility.isEmpty(input.id)
|
|
264
|
-
&& !input.readonly
|
|
265
|
-
&& !input.disabled
|
|
266
|
-
&& !ObjectUtility.isEmpty(form.controls)
|
|
267
|
-
&& !ObjectUtility.isEmpty(form.controls[input.id])) {
|
|
268
|
-
let control = form.controls[input.id];
|
|
269
|
-
control.reset();
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
return form;
|
|
274
|
-
}
|
|
275
|
-
static setValidators(input, form, result) {
|
|
276
|
-
if (!ObjectUtility.isEmpty(form.controls[input.id])) {
|
|
277
|
-
if (result) {
|
|
278
|
-
if (input.type === GenericInputType.CHECKBOX) {
|
|
279
|
-
form.controls[input.id].setValidators(this.getCheckBoxValidator(input));
|
|
280
|
-
}
|
|
281
|
-
else if (input.type !== undefined && (input.type === GenericInputType.RADIO ||
|
|
282
|
-
input.type === GenericInputType.DATE ||
|
|
283
|
-
input.type === GenericInputType.COMBOBOX)) {
|
|
284
|
-
form.controls[input.id].setValidators((!input.hidden && (input.required || ObjectUtility.includes(input.validators, Validation.REQUIRED))) ?
|
|
285
|
-
FormValidators.getValidators([Validation.REQUIRED]) : null);
|
|
286
|
-
}
|
|
287
|
-
else {
|
|
288
|
-
form.controls[input.id].setValidators((!input.hidden) ? FormValidators.getValidators(input.validators) : null);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
else {
|
|
292
|
-
form.controls[input.id].setValidators(null);
|
|
293
|
-
}
|
|
294
|
-
form.controls[input.id].updateValueAndValidity();
|
|
295
|
-
}
|
|
296
|
-
}
|
|
163
|
+
class FormsUtility {
|
|
164
|
+
static updateCheckboxValue(form, formArrayName, controlName, checked, value) {
|
|
165
|
+
let formArr = form.controls[formArrayName];
|
|
166
|
+
if (!checked) {
|
|
167
|
+
formArr.controls[controlName].setValue(null);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
formArr.controls[controlName].setValue(value);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
static updateRadioValue(form, controlName, checked, optionId) {
|
|
174
|
+
let control = form.controls[controlName];
|
|
175
|
+
if (!checked) {
|
|
176
|
+
control.setValue(Constants.EMPTY_SPACE);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
control.setValue(optionId);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
static isCheckBoxChecked(form, controlName, optionId) {
|
|
183
|
+
let checked = null;
|
|
184
|
+
let formArr = form.controls[controlName];
|
|
185
|
+
let formControl = formArr.controls[optionId];
|
|
186
|
+
if (!ObjectUtility.isEmpty(formControl))
|
|
187
|
+
checked = formControl.value;
|
|
188
|
+
if (!ObjectUtility.isEmpty(checked))
|
|
189
|
+
return checked;
|
|
190
|
+
else
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
static isRadioChecked(form, controlName, optionId) {
|
|
194
|
+
let checked = null;
|
|
195
|
+
let formControl = form.controls[controlName];
|
|
196
|
+
if (!ObjectUtility.isEmpty(formControl))
|
|
197
|
+
checked = formControl.value;
|
|
198
|
+
if (!ObjectUtility.isEmpty(checked) && checked == optionId)
|
|
199
|
+
return true;
|
|
200
|
+
else
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
static buildFromGroup(fields, disabled) {
|
|
204
|
+
let form = new FormGroup({});
|
|
205
|
+
if (!ObjectUtility.isEmpty(fields))
|
|
206
|
+
for (const group of Array.from(fields)) {
|
|
207
|
+
//console.log("group>",group);
|
|
208
|
+
for (const input of group === null || group === void 0 ? void 0 : group.groupFields) {
|
|
209
|
+
if (input.id !== undefined) {
|
|
210
|
+
if (input.type !== undefined && input.type === GenericInputType.CHECKBOX) {
|
|
211
|
+
form.addControl(input.id, this.getCheckBoxFormArray(input));
|
|
212
|
+
if (!ObjectUtility.isEmpty(input.value)) {
|
|
213
|
+
form.controls[input.id].reset(input.value);
|
|
214
|
+
form.controls[input.id].updateValueAndValidity();
|
|
215
|
+
}
|
|
216
|
+
if (input.disabled || disabled) {
|
|
217
|
+
form.controls[input.id].disable();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (input.type !== undefined && (input.type === GenericInputType.RADIO ||
|
|
221
|
+
input.type === GenericInputType.DATE ||
|
|
222
|
+
input.type === GenericInputType.COMBOBOX)) {
|
|
223
|
+
form.addControl(input.id, new FormControl((!ObjectUtility.isEmpty(input.value)) ? input.value : Constants.EMPTY_SPACE, (!input.hidden && (input.required || ObjectUtility.includes(input.validators, Validation.REQUIRED))) ? FormValidators.getValidators([Validation.REQUIRED]) : null));
|
|
224
|
+
if (input.disabled || disabled) {
|
|
225
|
+
form.controls[input.id].disable();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
form.addControl(input.id, new FormControl((!ObjectUtility.isEmpty(input.value)) ? input.value : Constants.EMPTY_SPACE, (!input.hidden) ? FormValidators.getValidators(input.validators) : null));
|
|
230
|
+
if (input.disabled || disabled) {
|
|
231
|
+
form.controls[input.id].disable();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return form;
|
|
238
|
+
}
|
|
239
|
+
static getCheckBoxFormArray(input) {
|
|
240
|
+
let fb = new FormBuilder();
|
|
241
|
+
return fb.array(input.options.map(() => fb.control(null, null)), (!input.hidden) ? this.getCheckBoxValidator(input) : null);
|
|
242
|
+
}
|
|
243
|
+
static getCheckBoxValidator(input) {
|
|
244
|
+
if (!input.hidden && (input.required || ObjectUtility.includes(input.validators, Validation.REQUIRED))) {
|
|
245
|
+
return CustomValidator.multipleCheckboxRequireOne;
|
|
246
|
+
}
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
static includeRequired(validators) {
|
|
250
|
+
if (!ObjectUtility.isEmpty(validators)) {
|
|
251
|
+
for (const validator of Array.from(validators)) {
|
|
252
|
+
if (validator === Validation.REQUIRED) {
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
static resetForm(fields, form) {
|
|
260
|
+
if (!ObjectUtility.isEmpty(fields))
|
|
261
|
+
for (const group of Array.from(fields)) {
|
|
262
|
+
for (const input of group === null || group === void 0 ? void 0 : group.groupFields) {
|
|
263
|
+
if (!ObjectUtility.isEmpty(input.id)
|
|
264
|
+
&& !input.readonly
|
|
265
|
+
&& !input.disabled
|
|
266
|
+
&& !ObjectUtility.isEmpty(form.controls)
|
|
267
|
+
&& !ObjectUtility.isEmpty(form.controls[input.id])) {
|
|
268
|
+
let control = form.controls[input.id];
|
|
269
|
+
control.reset();
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return form;
|
|
274
|
+
}
|
|
275
|
+
static setValidators(input, form, result) {
|
|
276
|
+
if (!ObjectUtility.isEmpty(form.controls[input.id])) {
|
|
277
|
+
if (result) {
|
|
278
|
+
if (input.type === GenericInputType.CHECKBOX) {
|
|
279
|
+
form.controls[input.id].setValidators(this.getCheckBoxValidator(input));
|
|
280
|
+
}
|
|
281
|
+
else if (input.type !== undefined && (input.type === GenericInputType.RADIO ||
|
|
282
|
+
input.type === GenericInputType.DATE ||
|
|
283
|
+
input.type === GenericInputType.COMBOBOX)) {
|
|
284
|
+
form.controls[input.id].setValidators((!input.hidden && (input.required || ObjectUtility.includes(input.validators, Validation.REQUIRED))) ?
|
|
285
|
+
FormValidators.getValidators([Validation.REQUIRED]) : null);
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
form.controls[input.id].setValidators((!input.hidden) ? FormValidators.getValidators(input.validators) : null);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
form.controls[input.id].setValidators(null);
|
|
293
|
+
}
|
|
294
|
+
form.controls[input.id].updateValueAndValidity();
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
297
|
}
|
|
298
298
|
|
|
299
|
-
class FormComponent {
|
|
300
|
-
constructor() {
|
|
301
|
-
this.form = new FormGroup({});
|
|
302
|
-
this.fileList = null;
|
|
303
|
-
this.fileName = "";
|
|
304
|
-
this.onSubmit = new EventEmitter();
|
|
305
|
-
this.alert_timeout = Constants.ALERT_TIMEOUT;
|
|
306
|
-
this.danger = { active: false, label: '' };
|
|
307
|
-
this.warning = { active: false, label: '' };
|
|
308
|
-
this.success = { active: false, label: '' };
|
|
309
|
-
this.info = { active: false, label: '' };
|
|
310
|
-
this.primary = { active: false, label: '' };
|
|
311
|
-
this.secondary = { active: false, label: '' };
|
|
312
|
-
}
|
|
313
|
-
onClick(action) {
|
|
314
|
-
let data = {
|
|
315
|
-
action: action,
|
|
316
|
-
formValues: this.form.value
|
|
317
|
-
};
|
|
318
|
-
this.onSubmit.emit(data);
|
|
319
|
-
}
|
|
320
|
-
onEnter() {
|
|
321
|
-
this.onSubmit.emit(this.form.value);
|
|
322
|
-
}
|
|
323
|
-
ngOnInit() {
|
|
324
|
-
this.buildFormGroup(this.formFields);
|
|
325
|
-
//console.log("form>",this.form);
|
|
326
|
-
}
|
|
327
|
-
buildFormGroup(fields) {
|
|
328
|
-
this.form = FormsUtility.buildFromGroup(fields, this.disabled);
|
|
329
|
-
}
|
|
330
|
-
getForm() {
|
|
331
|
-
return this.form;
|
|
332
|
-
}
|
|
333
|
-
getFormControls() {
|
|
334
|
-
if (!ObjectUtility.isEmpty(this.form)) {
|
|
335
|
-
return this.form.controls;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
getFormControl(controlName) {
|
|
339
|
-
if (!ObjectUtility.isEmpty(this.form)
|
|
340
|
-
&& !ObjectUtility.isEmpty(this.form.controls)) {
|
|
341
|
-
return this.form.controls[controlName];
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
setFormControlValue(controlName, value) {
|
|
345
|
-
if (!ObjectUtility.isEmpty(this.form)
|
|
346
|
-
&& !ObjectUtility.isEmpty(this.form.controls)
|
|
347
|
-
&& !ObjectUtility.isEmpty(this.form.controls)
|
|
348
|
-
&& !ObjectUtility.isEmpty(this.form.controls[controlName])) {
|
|
349
|
-
this.form.controls[controlName].reset(value);
|
|
350
|
-
this.form.controls[controlName].updateValueAndValidity();
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
includeRequired(validators) {
|
|
354
|
-
return FormsUtility.includeRequired(validators);
|
|
355
|
-
}
|
|
356
|
-
fileChange(event) {
|
|
357
|
-
this.fileList = event.target.files;
|
|
358
|
-
//console.log("fileList>",this.fileList);
|
|
359
|
-
if (!ObjectUtility.isEmpty(this.fileList) && event.target.files.length > 0)
|
|
360
|
-
this.fileName = this.fileList[0].name;
|
|
361
|
-
else
|
|
362
|
-
this.fileName = "";
|
|
363
|
-
}
|
|
364
|
-
onUploadClick(id) {
|
|
365
|
-
let data = {
|
|
366
|
-
action: 'uploadFile',
|
|
367
|
-
fileList: this.fileList,
|
|
368
|
-
fieldId: id
|
|
369
|
-
};
|
|
370
|
-
this.onSubmit.emit(data);
|
|
371
|
-
}
|
|
372
|
-
updateCheckboxValue(formArray, controlName, checked, value) {
|
|
373
|
-
FormsUtility.updateCheckboxValue(this.form, formArray, controlName, checked, value);
|
|
374
|
-
}
|
|
375
|
-
updateRadioValue(inputId, checked, optionId) {
|
|
376
|
-
FormsUtility.updateRadioValue(this.form, inputId, checked, optionId);
|
|
377
|
-
}
|
|
378
|
-
isCheckBoxChecked(controlName, optionId) {
|
|
379
|
-
return FormsUtility.isCheckBoxChecked(this.form, controlName, optionId);
|
|
380
|
-
}
|
|
381
|
-
isRadioChecked(controlName, optionId) {
|
|
382
|
-
return FormsUtility.isRadioChecked(this.form, controlName, optionId);
|
|
383
|
-
}
|
|
384
|
-
resetForm() {
|
|
385
|
-
this.form = FormsUtility.resetForm(this.formFields, this.form);
|
|
386
|
-
}
|
|
387
|
-
isEmpty(value) {
|
|
388
|
-
return ObjectUtility.isEmpty(value);
|
|
389
|
-
}
|
|
390
|
-
getDisabled() {
|
|
391
|
-
return this.disabled;
|
|
392
|
-
}
|
|
393
|
-
setDisabled(disabled) {
|
|
394
|
-
this.disabled = disabled;
|
|
395
|
-
this.form = FormsUtility.buildFromGroup(this.formFields, this.disabled);
|
|
396
|
-
}
|
|
397
|
-
setDanger(label) {
|
|
398
|
-
this.danger.active = true;
|
|
399
|
-
this.danger.label = label;
|
|
400
|
-
setTimeout(() => {
|
|
401
|
-
this.danger.active = false;
|
|
402
|
-
}, this.alert_timeout);
|
|
403
|
-
}
|
|
404
|
-
setWarning(label) {
|
|
405
|
-
this.warning.active = true;
|
|
406
|
-
this.warning.label = label;
|
|
407
|
-
setTimeout(() => {
|
|
408
|
-
this.warning.active = false;
|
|
409
|
-
}, this.alert_timeout);
|
|
410
|
-
}
|
|
411
|
-
setSuccess(label) {
|
|
412
|
-
this.success.active = true;
|
|
413
|
-
this.success.label = label;
|
|
414
|
-
setTimeout(() => {
|
|
415
|
-
this.success.active = false;
|
|
416
|
-
}, this.alert_timeout);
|
|
417
|
-
}
|
|
418
|
-
setInfo(label) {
|
|
419
|
-
this.info.active = true;
|
|
420
|
-
this.info.label = label;
|
|
421
|
-
setTimeout(() => {
|
|
422
|
-
this.info.active = false;
|
|
423
|
-
}, this.alert_timeout);
|
|
424
|
-
}
|
|
425
|
-
setPrimary(label) {
|
|
426
|
-
this.primary.active = true;
|
|
427
|
-
this.primary.label = label;
|
|
428
|
-
setTimeout(() => {
|
|
429
|
-
this.primary.active = false;
|
|
430
|
-
}, this.alert_timeout);
|
|
431
|
-
}
|
|
432
|
-
setSecondary(label) {
|
|
433
|
-
this.secondary.active = true;
|
|
434
|
-
this.secondary.label = label;
|
|
435
|
-
setTimeout(() => {
|
|
436
|
-
this.secondary.active = false;
|
|
437
|
-
}, this.alert_timeout);
|
|
438
|
-
}
|
|
439
|
-
setAlertTimeout(timeout) {
|
|
440
|
-
this.alert_timeout = timeout;
|
|
441
|
-
}
|
|
442
|
-
getIconClass(input) {
|
|
443
|
-
return input.icon;
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
/** @nocollapse */ FormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: FormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
447
|
-
/** @nocollapse */ FormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: FormComponent, selector: "df-form", inputs: { formFields: "formFields", disabled: "disabled", buttons: "buttons" }, outputs: { onSubmit: "onSubmit" }, ngImport: i0, template: "<form [formGroup]=\"form\" class=\"form\">\r\n <div class=\"row\" [style]=\"group?.style\" *ngFor=\"let group of formFields\">\r\n <span *ngIf=\"!isEmpty(group?.groupTitle)\" class=\"mt-1\">{{group?.groupTitle}}</span>\r\n <div *ngFor=\"let input of group?.groupFields\" class=\"mt-1 mb-2 form-group col-auto\">\r\n <span [hidden]=\"input.hidden\">\r\n <label *ngIf=\"input.type!=='button' && input.type!=='reset' && input.type!=='submit'\" for=\"{{input.id}}\" class=\"mr-sm-2\">\r\n <div *ngIf=\"includeRequired(input.validators) || input.required===true\"\r\n [style.color]=\"input.color\"><i [className]=\"input.icon\" aria-hidden=\"true\"></i> *{{input.label}}</div>\r\n <div *ngIf=\"!includeRequired(input.validators) && (input.required===false || input.required===undefined)\"\r\n [style.color]=\"input.color\"><i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</div>\r\n </label>\r\n <div [ngSwitch]=\"input.type\">\r\n <div *ngSwitchCase=\"'text'\">\r\n <input type=\"{{input.type}}\"\r\n id=\"{{input.id}}\"\r\n name=\"{{input.id}}\"\r\n placeholder=\"{{input.label}}\"\r\n formControlName=\"{{input.id}}\"\r\n class=\"form-control form-control-sm\"\r\n [readonly]=\"input.readonly\"\r\n />\r\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\r\n </div>\r\n <div *ngSwitchCase=\"'number'\">\r\n <input type=\"{{input.type}}\"\r\n id=\"{{input.id}}\"\r\n name=\"{{input.id}}\"\r\n placeholder=\"{{input.label}}\"\r\n formControlName=\"{{input.id}}\"\r\n class=\"form-control form-control-sm\"\r\n [readonly]=\"input.readonly\"\r\n />\r\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\r\n </div>\r\n <div *ngSwitchCase=\"'date'\">\r\n <input type=\"{{input.type}}\"\r\n id=\"{{input.id}}\"\r\n name=\"{{input.id}}\"\r\n formControlName=\"{{input.id}}\"\r\n class=\"form-control form-control-sm\"\r\n [readonly]=\"input.readonly\"\r\n />\r\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\r\n </div>\r\n <div *ngSwitchCase=\"'password'\">\r\n <input type=\"{{input.type}}\"\r\n id=\"{{input.id}}\"\r\n name=\"{{input.id}}\"\r\n placeholder=\"{{input.label}}\"\r\n formControlName=\"{{input.id}}\"\r\n class=\"form-control form-control-sm\"\r\n [readonly]=\"input.readonly\"\r\n />\r\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\r\n </div>\r\n <div *ngSwitchCase=\"'textarea'\">\r\n <textarea\r\n id=\"{{input.id}}\"\r\n name=\"{{input.id}}\"\r\n placeholder=\"{{input.label}}\"\r\n formControlName=\"{{input.id}}\"\r\n class=\"form-control form-control-sm\"\r\n [readonly]=\"input.readonly\"\r\n ></textarea>\r\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\r\n </div>\r\n <div *ngSwitchCase=\"'file'\">\r\n <div class=\"form-group\">\r\n <div class=\"input-group\">\r\n <div class=\"custom-file\">\r\n <input type=\"file\"\r\n class=\"form-control\"\r\n id=\"{{input.id}}\"\r\n accept=\"{{input.accept}}\"\r\n (change)=\"fileChange($event)\" multiple>\r\n <label class=\"custom-file-label\" for=\"{{input.id}}\">{{fileName}}</label>\r\n </div>\r\n <div class=\"input-group-append\">\r\n <span class=\"input-group-text\" (click)=\"onUploadClick(input.id)\">\r\n <i [className]=\"input.uploadIcon\" aria-hidden=\"true\"></i> {{input.uploadLabel}}</span>\r\n </div>\r\n </div>\r\n </div>\r\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\r\n </div>\r\n <div *ngSwitchCase=\"'combobox'\">\r\n <select name=\"{{input.id}}\"\r\n id=\"{{input.id}}\"\r\n formControlName={{input.id}}\r\n class=\"form-control form-control-sm\">\r\n <option [value]=\"\"></option>\r\n <option [value]=\"option.id\" *ngFor=\"let option of input.options\"> {{option.label}}</option>\r\n </select>\r\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\r\n </div>\r\n <div class=\"row\" *ngSwitchCase=\"'radio'\">\r\n <div class=\"col-auto\"\r\n [style.color]=\"input.color\"\r\n *ngFor=\"let option of input.options\">\r\n <div><i [className]=\"option.icon\" aria-hidden=\"true\"></i> {{option.label}}</div>\r\n <input type=\"{{input.type}}\"\r\n name=\"{{input.id}}\"\r\n id=\"{{input.id}}\"\r\n formControlName={{input.id}}\r\n class=\"form-check-input\"\r\n [value]=\"option.id\"\r\n [checked]=\"isRadioChecked(input.id,option.id)\"\r\n (change)=\"updateRadioValue(input.id,$event.target.checked,option.id)\"\r\n />\r\n </div>\r\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\r\n </div>\r\n <div class=\"row\" *ngSwitchCase=\"'checkbox'\">\r\n <div class=\"col-auto\" [style.color]=\"input.color\" formArrayName=\"{{input.id}}\" *ngFor=\"let option of input.options; let i=index;\">\r\n <div><i [className]=\"option.icon\" aria-hidden=\"true\"></i> {{option.label}}</div>\r\n <input type=\"{{input.type}}\"\r\n name=\"{{option.id}}\"\r\n id=\"{{option.id}}\"\r\n [formControlName]=\"i\"\r\n [value]=\"input.options[i].id\"\r\n class=\"form-check-input\"\r\n [checked]=\"isCheckBoxChecked(input.id,i)\"\r\n (change)=\"updateCheckboxValue(input.id,i,$event.target.checked,input.options[i].id)\"\r\n />\r\n </div>\r\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\r\n </div>\r\n </div>\r\n </span>\r\n </div>\r\n </div>\r\n <div class=\"row\">\r\n <div *ngIf=\"success.active\" class=\"grow alert alert-success mb-4 ml-3 mr-3\">\r\n <i class=\"fa fa-check\" aria-hidden=\"true\"></i> {{success.label}}</div>\r\n <div *ngIf=\"danger.active\" class=\"grow alert alert-danger mb-4 ml-3 mr-3\">\r\n <i class=\"fa fa-times\" aria-hidden=\"true\"></i> {{danger.label}}</div>\r\n <div *ngIf=\"warning.active\" class=\"grow alert alert-warning mb-4 ml-3 mr-3\">\r\n <i class=\"fa fa-exclamation-triangle\" aria-hidden=\"true\"></i> {{warning.label}}</div>\r\n <div *ngIf=\"info.active\" class=\"grow alert alert-info mb-4 ml-3 mr-3\">\r\n <i class=\"fa fa-info\" aria-hidden=\"true\"></i> {{info.label}}</div>\r\n <div *ngIf=\"primary.active\" class=\"grow alert alert-primary mb-4 ml-3 mr-3\">\r\n <i class=\"fa fa-exclamation\" aria-hidden=\"true\"></i> {{primary.label}}</div>\r\n <div *ngIf=\"secondary.active\" class=\"grow alert alert-secondary mb-4 ml-3 mr-3\">\r\n <i class=\"fa fa-exclamation\" aria-hidden=\"true\"></i> {{secondary.label}}</div>\r\n </div>\r\n <div class=\"d-flex justify-content-around\">\r\n <div *ngFor=\"let input of buttons\">\r\n <div [ngSwitch]=\"input.type\">\r\n <div *ngSwitchCase=\"'button'\">\r\n <button type=\"{{input.type}}\" class=\"btn btn-secondary ml-2\" (click)=\"onClick(input.action)\">\r\n <i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</button>\r\n </div>\r\n <div *ngSwitchCase=\"'submit'\">\r\n <button type=\"{{input.type}}\" class=\"btn btn-primary ml-2\" (click)=\"onClick(input.action)\" [disabled]=\"!form.valid\">\r\n <i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</button>\r\n </div>\r\n <div *ngSwitchCase=\"'reset'\">\r\n <button type=\"'button'\" class=\"btn btn-secondary ml-2\" (click)=\"resetForm()\">\r\n <i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n</form>\r\n", styles: [".alert{display:inline-block}.grow{flex-grow:1}textarea:focus,select:focus,input[type=text]:focus,input[type=password]:focus,input[type=datetime]:focus,input[type=datetime-local]:focus,input[type=date]:focus,input[type=month]:focus,input[type=time]:focus,input[type=week]:focus,input[type=number]:focus,input[type=email]:focus,input[type=url]:focus,input[type=search]:focus,input[type=tel]:focus,input[type=color]:focus,input[type=checkbox]:focus,input[type=radio]:focus,button:focus,.uneditable-input:focus{border-color:green;box-shadow:0 1px 1px #00000013 inset,0 0 8px green;outline:0 none}.col-auto{flex-grow:1}.radio,.checkbox{width:15px;height:15px}.btn-primary{background-color:green;border-color:green}.form-check-input:checked{background-color:green;border-color:green}\n"], components: [{ type: AlertComponent, selector: "df-alert", inputs: ["form", "input"] }], directives: [{ type: i2$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i2$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i2$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i2.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i2$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i2$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i2$1.FormControlName, selector: "[formControlName]", inputs: ["disabled", "formControlName", "ngModel"], outputs: ["ngModelChange"] }, { type: i2$1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { type: i2$1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i2$1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i2$1.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }] });
|
|
448
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: FormComponent, decorators: [{
|
|
449
|
-
type: Component,
|
|
450
|
-
args: [{
|
|
451
|
-
selector: 'df-form',
|
|
452
|
-
templateUrl: './form.component.html',
|
|
453
|
-
styleUrls: ['./form.component.scss']
|
|
454
|
-
}]
|
|
455
|
-
}], ctorParameters: function () { return []; }, propDecorators: { formFields: [{
|
|
456
|
-
type: Input
|
|
457
|
-
}], disabled: [{
|
|
458
|
-
type: Input
|
|
459
|
-
}], buttons: [{
|
|
460
|
-
type: Input
|
|
461
|
-
}], onSubmit: [{
|
|
462
|
-
type: Output
|
|
299
|
+
class FormComponent {
|
|
300
|
+
constructor() {
|
|
301
|
+
this.form = new FormGroup({});
|
|
302
|
+
this.fileList = null;
|
|
303
|
+
this.fileName = "";
|
|
304
|
+
this.onSubmit = new EventEmitter();
|
|
305
|
+
this.alert_timeout = Constants.ALERT_TIMEOUT;
|
|
306
|
+
this.danger = { active: false, label: '' };
|
|
307
|
+
this.warning = { active: false, label: '' };
|
|
308
|
+
this.success = { active: false, label: '' };
|
|
309
|
+
this.info = { active: false, label: '' };
|
|
310
|
+
this.primary = { active: false, label: '' };
|
|
311
|
+
this.secondary = { active: false, label: '' };
|
|
312
|
+
}
|
|
313
|
+
onClick(action) {
|
|
314
|
+
let data = {
|
|
315
|
+
action: action,
|
|
316
|
+
formValues: this.form.value
|
|
317
|
+
};
|
|
318
|
+
this.onSubmit.emit(data);
|
|
319
|
+
}
|
|
320
|
+
onEnter() {
|
|
321
|
+
this.onSubmit.emit(this.form.value);
|
|
322
|
+
}
|
|
323
|
+
ngOnInit() {
|
|
324
|
+
this.buildFormGroup(this.formFields);
|
|
325
|
+
//console.log("form>",this.form);
|
|
326
|
+
}
|
|
327
|
+
buildFormGroup(fields) {
|
|
328
|
+
this.form = FormsUtility.buildFromGroup(fields, this.disabled);
|
|
329
|
+
}
|
|
330
|
+
getForm() {
|
|
331
|
+
return this.form;
|
|
332
|
+
}
|
|
333
|
+
getFormControls() {
|
|
334
|
+
if (!ObjectUtility.isEmpty(this.form)) {
|
|
335
|
+
return this.form.controls;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
getFormControl(controlName) {
|
|
339
|
+
if (!ObjectUtility.isEmpty(this.form)
|
|
340
|
+
&& !ObjectUtility.isEmpty(this.form.controls)) {
|
|
341
|
+
return this.form.controls[controlName];
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
setFormControlValue(controlName, value) {
|
|
345
|
+
if (!ObjectUtility.isEmpty(this.form)
|
|
346
|
+
&& !ObjectUtility.isEmpty(this.form.controls)
|
|
347
|
+
&& !ObjectUtility.isEmpty(this.form.controls)
|
|
348
|
+
&& !ObjectUtility.isEmpty(this.form.controls[controlName])) {
|
|
349
|
+
this.form.controls[controlName].reset(value);
|
|
350
|
+
this.form.controls[controlName].updateValueAndValidity();
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
includeRequired(validators) {
|
|
354
|
+
return FormsUtility.includeRequired(validators);
|
|
355
|
+
}
|
|
356
|
+
fileChange(event) {
|
|
357
|
+
this.fileList = event.target.files;
|
|
358
|
+
//console.log("fileList>",this.fileList);
|
|
359
|
+
if (!ObjectUtility.isEmpty(this.fileList) && event.target.files.length > 0)
|
|
360
|
+
this.fileName = this.fileList[0].name;
|
|
361
|
+
else
|
|
362
|
+
this.fileName = "";
|
|
363
|
+
}
|
|
364
|
+
onUploadClick(id) {
|
|
365
|
+
let data = {
|
|
366
|
+
action: 'uploadFile',
|
|
367
|
+
fileList: this.fileList,
|
|
368
|
+
fieldId: id
|
|
369
|
+
};
|
|
370
|
+
this.onSubmit.emit(data);
|
|
371
|
+
}
|
|
372
|
+
updateCheckboxValue(formArray, controlName, checked, value) {
|
|
373
|
+
FormsUtility.updateCheckboxValue(this.form, formArray, controlName, checked, value);
|
|
374
|
+
}
|
|
375
|
+
updateRadioValue(inputId, checked, optionId) {
|
|
376
|
+
FormsUtility.updateRadioValue(this.form, inputId, checked, optionId);
|
|
377
|
+
}
|
|
378
|
+
isCheckBoxChecked(controlName, optionId) {
|
|
379
|
+
return FormsUtility.isCheckBoxChecked(this.form, controlName, optionId);
|
|
380
|
+
}
|
|
381
|
+
isRadioChecked(controlName, optionId) {
|
|
382
|
+
return FormsUtility.isRadioChecked(this.form, controlName, optionId);
|
|
383
|
+
}
|
|
384
|
+
resetForm() {
|
|
385
|
+
this.form = FormsUtility.resetForm(this.formFields, this.form);
|
|
386
|
+
}
|
|
387
|
+
isEmpty(value) {
|
|
388
|
+
return ObjectUtility.isEmpty(value);
|
|
389
|
+
}
|
|
390
|
+
getDisabled() {
|
|
391
|
+
return this.disabled;
|
|
392
|
+
}
|
|
393
|
+
setDisabled(disabled) {
|
|
394
|
+
this.disabled = disabled;
|
|
395
|
+
this.form = FormsUtility.buildFromGroup(this.formFields, this.disabled);
|
|
396
|
+
}
|
|
397
|
+
setDanger(label) {
|
|
398
|
+
this.danger.active = true;
|
|
399
|
+
this.danger.label = label;
|
|
400
|
+
setTimeout(() => {
|
|
401
|
+
this.danger.active = false;
|
|
402
|
+
}, this.alert_timeout);
|
|
403
|
+
}
|
|
404
|
+
setWarning(label) {
|
|
405
|
+
this.warning.active = true;
|
|
406
|
+
this.warning.label = label;
|
|
407
|
+
setTimeout(() => {
|
|
408
|
+
this.warning.active = false;
|
|
409
|
+
}, this.alert_timeout);
|
|
410
|
+
}
|
|
411
|
+
setSuccess(label) {
|
|
412
|
+
this.success.active = true;
|
|
413
|
+
this.success.label = label;
|
|
414
|
+
setTimeout(() => {
|
|
415
|
+
this.success.active = false;
|
|
416
|
+
}, this.alert_timeout);
|
|
417
|
+
}
|
|
418
|
+
setInfo(label) {
|
|
419
|
+
this.info.active = true;
|
|
420
|
+
this.info.label = label;
|
|
421
|
+
setTimeout(() => {
|
|
422
|
+
this.info.active = false;
|
|
423
|
+
}, this.alert_timeout);
|
|
424
|
+
}
|
|
425
|
+
setPrimary(label) {
|
|
426
|
+
this.primary.active = true;
|
|
427
|
+
this.primary.label = label;
|
|
428
|
+
setTimeout(() => {
|
|
429
|
+
this.primary.active = false;
|
|
430
|
+
}, this.alert_timeout);
|
|
431
|
+
}
|
|
432
|
+
setSecondary(label) {
|
|
433
|
+
this.secondary.active = true;
|
|
434
|
+
this.secondary.label = label;
|
|
435
|
+
setTimeout(() => {
|
|
436
|
+
this.secondary.active = false;
|
|
437
|
+
}, this.alert_timeout);
|
|
438
|
+
}
|
|
439
|
+
setAlertTimeout(timeout) {
|
|
440
|
+
this.alert_timeout = timeout;
|
|
441
|
+
}
|
|
442
|
+
getIconClass(input) {
|
|
443
|
+
return input.icon;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
/** @nocollapse */ FormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: FormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
447
|
+
/** @nocollapse */ FormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: FormComponent, selector: "df-form", inputs: { formFields: "formFields", disabled: "disabled", buttons: "buttons" }, outputs: { onSubmit: "onSubmit" }, ngImport: i0, template: "<form [formGroup]=\"form\" class=\"form\">\n <div class=\"row\" [style]=\"group?.style\" *ngFor=\"let group of formFields\">\n <span *ngIf=\"!isEmpty(group?.groupTitle)\" class=\"mt-1\">{{group?.groupTitle}}</span>\n <div *ngFor=\"let input of group?.groupFields\" class=\"mt-1 mb-2 form-group col-auto\">\n <span [hidden]=\"input.hidden\">\n <label *ngIf=\"input.type!=='button' && input.type!=='reset' && input.type!=='submit'\" for=\"{{input.id}}\" class=\"mr-sm-2\">\n <div *ngIf=\"includeRequired(input.validators) || input.required===true\"\n [style.color]=\"input.color\"><i [className]=\"input.icon\" aria-hidden=\"true\"></i> *{{input.label}}</div>\n <div *ngIf=\"!includeRequired(input.validators) && (input.required===false || input.required===undefined)\"\n [style.color]=\"input.color\"><i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</div>\n </label>\n <div [ngSwitch]=\"input.type\">\n <div *ngSwitchCase=\"'text'\">\n <input type=\"{{input.type}}\"\n id=\"{{input.id}}\"\n name=\"{{input.id}}\"\n placeholder=\"{{input.label}}\"\n formControlName=\"{{input.id}}\"\n class=\"form-control form-control-sm\"\n [readonly]=\"input.readonly\"\n />\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\n </div>\n <div *ngSwitchCase=\"'number'\">\n <input type=\"{{input.type}}\"\n id=\"{{input.id}}\"\n name=\"{{input.id}}\"\n placeholder=\"{{input.label}}\"\n formControlName=\"{{input.id}}\"\n class=\"form-control form-control-sm\"\n [readonly]=\"input.readonly\"\n />\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\n </div>\n <div *ngSwitchCase=\"'date'\">\n <input type=\"{{input.type}}\"\n id=\"{{input.id}}\"\n name=\"{{input.id}}\"\n formControlName=\"{{input.id}}\"\n class=\"form-control form-control-sm\"\n [readonly]=\"input.readonly\"\n />\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\n </div>\n <div *ngSwitchCase=\"'password'\">\n <input type=\"{{input.type}}\"\n id=\"{{input.id}}\"\n name=\"{{input.id}}\"\n placeholder=\"{{input.label}}\"\n formControlName=\"{{input.id}}\"\n class=\"form-control form-control-sm\"\n [readonly]=\"input.readonly\"\n />\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\n </div>\n <div *ngSwitchCase=\"'textarea'\">\n <textarea\n id=\"{{input.id}}\"\n name=\"{{input.id}}\"\n placeholder=\"{{input.label}}\"\n formControlName=\"{{input.id}}\"\n class=\"form-control form-control-sm\"\n [readonly]=\"input.readonly\"\n ></textarea>\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\n </div>\n <div *ngSwitchCase=\"'file'\">\n <div class=\"form-group\">\n <div class=\"input-group\">\n <div class=\"custom-file\">\n <input type=\"file\"\n class=\"form-control\"\n id=\"{{input.id}}\"\n accept=\"{{input.accept}}\"\n (change)=\"fileChange($event)\" multiple>\n <label class=\"custom-file-label\" for=\"{{input.id}}\">{{fileName}}</label>\n </div>\n <div class=\"input-group-append\">\n <span class=\"input-group-text\" (click)=\"onUploadClick(input.id)\">\n <i [className]=\"input.uploadIcon\" aria-hidden=\"true\"></i> {{input.uploadLabel}}</span>\n </div>\n </div>\n </div>\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\n </div>\n <div *ngSwitchCase=\"'combobox'\">\n <select name=\"{{input.id}}\"\n id=\"{{input.id}}\"\n formControlName={{input.id}}\n class=\"form-control form-control-sm\">\n <option [value]=\"\"></option>\n <option [value]=\"option.id\" *ngFor=\"let option of input.options\"> {{option.label}}</option>\n </select>\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\n </div>\n <div class=\"row\" *ngSwitchCase=\"'radio'\">\n <div class=\"col-auto\"\n [style.color]=\"input.color\"\n *ngFor=\"let option of input.options\">\n <div><i [className]=\"option.icon\" aria-hidden=\"true\"></i> {{option.label}}</div>\n <input type=\"{{input.type}}\"\n name=\"{{input.id}}\"\n id=\"{{input.id}}\"\n formControlName={{input.id}}\n class=\"form-check-input\"\n [value]=\"option.id\"\n [checked]=\"isRadioChecked(input.id,option.id)\"\n (change)=\"updateRadioValue(input.id,$event.target.checked,option.id)\"\n />\n </div>\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\n </div>\n <div class=\"row\" *ngSwitchCase=\"'checkbox'\">\n <div class=\"col-auto\" [style.color]=\"input.color\" formArrayName=\"{{input.id}}\" *ngFor=\"let option of input.options; let i=index;\">\n <div><i [className]=\"option.icon\" aria-hidden=\"true\"></i> {{option.label}}</div>\n <input type=\"{{input.type}}\"\n name=\"{{option.id}}\"\n id=\"{{option.id}}\"\n [formControlName]=\"i\"\n [value]=\"input.options[i].id\"\n class=\"form-check-input\"\n [checked]=\"isCheckBoxChecked(input.id,i)\"\n (change)=\"updateCheckboxValue(input.id,i,$event.target.checked,input.options[i].id)\"\n />\n </div>\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\n </div>\n </div>\n </span>\n </div>\n </div>\n <div class=\"row\">\n <div *ngIf=\"success.active\" class=\"grow alert alert-success mb-4 ml-3 mr-3\">\n <i class=\"fa fa-check\" aria-hidden=\"true\"></i> {{success.label}}</div>\n <div *ngIf=\"danger.active\" class=\"grow alert alert-danger mb-4 ml-3 mr-3\">\n <i class=\"fa fa-times\" aria-hidden=\"true\"></i> {{danger.label}}</div>\n <div *ngIf=\"warning.active\" class=\"grow alert alert-warning mb-4 ml-3 mr-3\">\n <i class=\"fa fa-exclamation-triangle\" aria-hidden=\"true\"></i> {{warning.label}}</div>\n <div *ngIf=\"info.active\" class=\"grow alert alert-info mb-4 ml-3 mr-3\">\n <i class=\"fa fa-info\" aria-hidden=\"true\"></i> {{info.label}}</div>\n <div *ngIf=\"primary.active\" class=\"grow alert alert-primary mb-4 ml-3 mr-3\">\n <i class=\"fa fa-exclamation\" aria-hidden=\"true\"></i> {{primary.label}}</div>\n <div *ngIf=\"secondary.active\" class=\"grow alert alert-secondary mb-4 ml-3 mr-3\">\n <i class=\"fa fa-exclamation\" aria-hidden=\"true\"></i> {{secondary.label}}</div>\n </div>\n <div class=\"d-flex justify-content-around\">\n <div *ngFor=\"let input of buttons\">\n <div [ngSwitch]=\"input.type\">\n <div *ngSwitchCase=\"'button'\">\n <button type=\"{{input.type}}\" class=\"btn btn-secondary ml-2\" (click)=\"onClick(input.action)\">\n <i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</button>\n </div>\n <div *ngSwitchCase=\"'submit'\">\n <button type=\"{{input.type}}\" class=\"btn btn-primary ml-2\" (click)=\"onClick(input.action)\" [disabled]=\"!form.valid\">\n <i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</button>\n </div>\n <div *ngSwitchCase=\"'reset'\">\n <button type=\"'button'\" class=\"btn btn-secondary ml-2\" (click)=\"resetForm()\">\n <i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</button>\n </div>\n </div>\n </div>\n </div>\n</form>\n", styles: [".alert{display:inline-block}.grow{flex-grow:1}.col-auto{flex-grow:1}\n"], components: [{ type: AlertComponent, selector: "df-alert", inputs: ["form", "input"] }], directives: [{ type: i2$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i2$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i2$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i2.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i2$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i2$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i2$1.FormControlName, selector: "[formControlName]", inputs: ["disabled", "formControlName", "ngModel"], outputs: ["ngModelChange"] }, { type: i2$1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { type: i2$1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i2$1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i2$1.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }] });
|
|
448
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: FormComponent, decorators: [{
|
|
449
|
+
type: Component,
|
|
450
|
+
args: [{
|
|
451
|
+
selector: 'df-form',
|
|
452
|
+
templateUrl: './form.component.html',
|
|
453
|
+
styleUrls: ['./form.component.scss']
|
|
454
|
+
}]
|
|
455
|
+
}], ctorParameters: function () { return []; }, propDecorators: { formFields: [{
|
|
456
|
+
type: Input
|
|
457
|
+
}], disabled: [{
|
|
458
|
+
type: Input
|
|
459
|
+
}], buttons: [{
|
|
460
|
+
type: Input
|
|
461
|
+
}], onSubmit: [{
|
|
462
|
+
type: Output
|
|
463
463
|
}] } });
|
|
464
464
|
|
|
465
|
-
class ComparisonOperators {
|
|
466
|
-
}
|
|
467
|
-
ComparisonOperators.EQUAL = '==';
|
|
468
|
-
ComparisonOperators.NOT_EQUAL = '!=';
|
|
469
|
-
ComparisonOperators.GREATER_THAN = '>';
|
|
470
|
-
ComparisonOperators.GREATER_THAN_OR_EQUAL = '>=';
|
|
471
|
-
ComparisonOperators.LESS_THAN = '<';
|
|
472
|
-
ComparisonOperators.LESS_THAN_OR_EQUAL = '<=';
|
|
465
|
+
class ComparisonOperators {
|
|
466
|
+
}
|
|
467
|
+
ComparisonOperators.EQUAL = '==';
|
|
468
|
+
ComparisonOperators.NOT_EQUAL = '!=';
|
|
469
|
+
ComparisonOperators.GREATER_THAN = '>';
|
|
470
|
+
ComparisonOperators.GREATER_THAN_OR_EQUAL = '>=';
|
|
471
|
+
ComparisonOperators.LESS_THAN = '<';
|
|
472
|
+
ComparisonOperators.LESS_THAN_OR_EQUAL = '<=';
|
|
473
473
|
ComparisonOperators.CONTAINS = ':contains:';
|
|
474
474
|
|
|
475
|
-
class LogicalOperators {
|
|
476
|
-
}
|
|
477
|
-
LogicalOperators.AND = '&&';
|
|
475
|
+
class LogicalOperators {
|
|
476
|
+
}
|
|
477
|
+
LogicalOperators.AND = '&&';
|
|
478
478
|
LogicalOperators.OR = '||';
|
|
479
479
|
|
|
480
|
-
class ExpressionsUtility {
|
|
481
|
-
static getExpressionLogs() {
|
|
482
|
-
return ExpressionsUtility.logs;
|
|
483
|
-
}
|
|
484
|
-
static setLoggingFlag(flag) {
|
|
485
|
-
ExpressionsUtility.expressionLoggingFlag = flag;
|
|
486
|
-
}
|
|
487
|
-
static evaluateExpression(expression, form, level) {
|
|
488
|
-
if (level <= 1)
|
|
489
|
-
ExpressionsUtility.logs = Constants.EMPTY_SPACE;
|
|
490
|
-
if (level > Constants.MAX_LEVELS)
|
|
491
|
-
return false;
|
|
492
|
-
if (this.expressionLoggingFlag)
|
|
493
|
-
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "Evaluating Expression> " + expression + " \n";
|
|
494
|
-
if (!ObjectUtility.isEmpty(expression)) {
|
|
495
|
-
if (expression.startsWith(Constants.LEFT_PARENTHESIS)
|
|
496
|
-
&& expression.endsWith(Constants.RIGHT_PARENTHESIS)) {
|
|
497
|
-
expression = expression.substring(1, expression.length - 1);
|
|
498
|
-
if (this.expressionLoggingFlag)
|
|
499
|
-
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "remove outer ( ) \n";
|
|
500
|
-
return this.evaluateExpression(expression, form, level + 1);
|
|
501
|
-
}
|
|
502
|
-
else if (expression.startsWith(Constants.LEFT_CURLY_BRACE) && expression.endsWith(Constants.RIGHT_CURLY_BRACE)) {
|
|
503
|
-
if (this.expressionLoggingFlag)
|
|
504
|
-
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "expression starts with { ends with } \n";
|
|
505
|
-
if (expression.indexOf(Constants.LEFT_PARENTHESIS) > -1 && expression.indexOf(Constants.RIGHT_PARENTHESIS) > -1) {
|
|
506
|
-
if (this.expressionLoggingFlag)
|
|
507
|
-
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "contains subexpressions \n";
|
|
508
|
-
return this.traverseSubExpressions(expression, form, level);
|
|
509
|
-
}
|
|
510
|
-
else {
|
|
511
|
-
if (this.expressionLoggingFlag)
|
|
512
|
-
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "does not contains subexpressions \n";
|
|
513
|
-
if (expression.indexOf(LogicalOperators.AND) > -1 || expression.indexOf(LogicalOperators.OR) > -1) {
|
|
514
|
-
if (this.expressionLoggingFlag)
|
|
515
|
-
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "contains && or || \n";
|
|
516
|
-
let spliter = this.getSpliter(expression);
|
|
517
|
-
let expressions = expression.split(spliter);
|
|
518
|
-
if (this.expressionLoggingFlag)
|
|
519
|
-
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "Split expressions into> " + expressions + "\n";
|
|
520
|
-
return this.validateArrayOfExpressions(expressions, spliter, form, level);
|
|
521
|
-
}
|
|
522
|
-
else {
|
|
523
|
-
if (this.expressionLoggingFlag)
|
|
524
|
-
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "this is a clean expression. \n";
|
|
525
|
-
return this.evaluateCleanExpression(expression, form, level);
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
else if ((expression.startsWith(Constants.LEFT_PARENTHESIS) && !expression.endsWith(Constants.RIGHT_PARENTHESIS)) ||
|
|
530
|
-
(!expression.startsWith(Constants.LEFT_PARENTHESIS) && expression.endsWith(Constants.RIGHT_PARENTHESIS))) {
|
|
531
|
-
if (expression.startsWith(Constants.LEFT_PARENTHESIS) && !expression.endsWith(Constants.RIGHT_PARENTHESIS))
|
|
532
|
-
if (this.expressionLoggingFlag)
|
|
533
|
-
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "expression starts with ( ends with } \n";
|
|
534
|
-
if (!expression.startsWith(Constants.LEFT_PARENTHESIS) && expression.endsWith(Constants.RIGHT_PARENTHESIS))
|
|
535
|
-
if (this.expressionLoggingFlag)
|
|
536
|
-
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "expression starts with { ends with ) \n";
|
|
537
|
-
return this.traverseSubExpressions(expression, form, level);
|
|
538
|
-
}
|
|
539
|
-
else
|
|
540
|
-
return false;
|
|
541
|
-
}
|
|
542
|
-
else
|
|
543
|
-
return true;
|
|
544
|
-
}
|
|
545
|
-
static traverseSubExpressions(expression, form, level) {
|
|
546
|
-
if (this.expressionLoggingFlag)
|
|
547
|
-
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "Traverse expression> " + expression + "\n";
|
|
548
|
-
let operator = Constants.EMPTY_SPACE;
|
|
549
|
-
let lastOperator = Constants.EMPTY_SPACE;
|
|
550
|
-
let index = 0;
|
|
551
|
-
do {
|
|
552
|
-
operator = Constants.EMPTY_SPACE;
|
|
553
|
-
let subexpression = this.extractSubexpression(expression, level);
|
|
554
|
-
let result = this.evaluateExpression(subexpression, form, level + 1);
|
|
555
|
-
operator = expression.substring(subexpression.length, subexpression.length + 2);
|
|
556
|
-
if (this.expressionLoggingFlag)
|
|
557
|
-
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "subExpression> " + subexpression + " >result> " + result + " >for operator> " + operator + "\n";
|
|
558
|
-
if (!result && (operator == LogicalOperators.AND || lastOperator == LogicalOperators.AND))
|
|
559
|
-
return false;
|
|
560
|
-
if (result && (operator == LogicalOperators.OR || lastOperator == LogicalOperators.OR))
|
|
561
|
-
return true;
|
|
562
|
-
expression = expression.substring(subexpression.length + 2, expression.length);
|
|
563
|
-
if (operator !== Constants.EMPTY_SPACE)
|
|
564
|
-
lastOperator = operator;
|
|
565
|
-
if (!ObjectUtility.isEmpty(expression)) {
|
|
566
|
-
if (this.expressionLoggingFlag)
|
|
567
|
-
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "Rest of the expression> " + expression + " > lastOperator> " + lastOperator + "\n";
|
|
568
|
-
}
|
|
569
|
-
else {
|
|
570
|
-
if (this.expressionLoggingFlag)
|
|
571
|
-
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "Rest of the expression is empty.\n";
|
|
572
|
-
}
|
|
573
|
-
} while (operator == LogicalOperators.AND || operator == LogicalOperators.OR);
|
|
574
|
-
if (lastOperator == LogicalOperators.AND)
|
|
575
|
-
return true;
|
|
576
|
-
if (lastOperator == LogicalOperators.OR)
|
|
577
|
-
return false;
|
|
578
|
-
}
|
|
579
|
-
static extractSubexpression(expression, level) {
|
|
580
|
-
let ending;
|
|
581
|
-
let opening = 0;
|
|
582
|
-
if (expression.startsWith(Constants.LEFT_CURLY_BRACE))
|
|
583
|
-
ending = expression.indexOf(Constants.RIGHT_CURLY_BRACE);
|
|
584
|
-
else {
|
|
585
|
-
let index = 1;
|
|
586
|
-
let opening = 1;
|
|
587
|
-
while (opening > 0) {
|
|
588
|
-
let myChar = expression.charAt(index);
|
|
589
|
-
if (myChar == Constants.LEFT_PARENTHESIS) {
|
|
590
|
-
opening++;
|
|
591
|
-
}
|
|
592
|
-
if (myChar == Constants.RIGHT_PARENTHESIS) {
|
|
593
|
-
opening--;
|
|
594
|
-
}
|
|
595
|
-
if (index > (expression.length - 1)) {
|
|
596
|
-
break;
|
|
597
|
-
}
|
|
598
|
-
index++;
|
|
599
|
-
}
|
|
600
|
-
ending = index - 1;
|
|
601
|
-
}
|
|
602
|
-
return expression.substring(0, ending + 1);
|
|
603
|
-
}
|
|
604
|
-
static getSpliter(expression) {
|
|
605
|
-
if (expression.indexOf(LogicalOperators.AND) > -1)
|
|
606
|
-
return LogicalOperators.AND;
|
|
607
|
-
else
|
|
608
|
-
return LogicalOperators.OR;
|
|
609
|
-
}
|
|
610
|
-
static validateArrayOfExpressions(expressions, spliter, form, level) {
|
|
611
|
-
for (let expression of expressions) {
|
|
612
|
-
let result = this.evaluateCleanExpression(expression, form, level);
|
|
613
|
-
if (spliter == LogicalOperators.AND && !result)
|
|
614
|
-
return false;
|
|
615
|
-
else if (spliter == LogicalOperators.OR && result)
|
|
616
|
-
return true;
|
|
617
|
-
}
|
|
618
|
-
return (spliter == LogicalOperators.AND) ? true : false;
|
|
619
|
-
}
|
|
620
|
-
static evaluateCleanExpression(expression, form, level) {
|
|
621
|
-
expression = expression.substring(1, expression.length - 1);
|
|
622
|
-
let operator = this.containsComparisonOperator(expression);
|
|
623
|
-
if (!ObjectUtility.isEmpty(operator)) {
|
|
624
|
-
let expressionResult = this.prepareExpressionWithOperator(expression, operator, form, level);
|
|
625
|
-
return expressionResult;
|
|
626
|
-
}
|
|
627
|
-
return false;
|
|
628
|
-
}
|
|
629
|
-
static containsComparisonOperator(expressions) {
|
|
630
|
-
let i = 0;
|
|
631
|
-
while (i < this.listComparisonOperators.length) {
|
|
632
|
-
if (expressions.indexOf(this.listComparisonOperators[i]) > -1) {
|
|
633
|
-
return this.listComparisonOperators[i];
|
|
634
|
-
}
|
|
635
|
-
i++;
|
|
636
|
-
}
|
|
637
|
-
return null;
|
|
638
|
-
}
|
|
639
|
-
static prepareExpressionWithOperator(expression, operator, form, level) {
|
|
640
|
-
if (!ObjectUtility.isEmpty(this.containsComparisonOperator(expression))
|
|
641
|
-
&& expression.indexOf(operator) > -1) {
|
|
642
|
-
let values = expression.split(operator);
|
|
643
|
-
if (values.length > 1) {
|
|
644
|
-
for (let i = 0; i < values.length; i++) {
|
|
645
|
-
values[i] = this.getControlValue(values[i], form);
|
|
646
|
-
}
|
|
647
|
-
let evaluatedExpression = this.evaluateExpressionWithOperator(values, operator);
|
|
648
|
-
if (this.expressionLoggingFlag)
|
|
649
|
-
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "evaluate clean Expression {}> " + expression + " >result> " + evaluatedExpression + "\n";
|
|
650
|
-
return evaluatedExpression;
|
|
651
|
-
}
|
|
652
|
-
else
|
|
653
|
-
return false;
|
|
654
|
-
}
|
|
655
|
-
else
|
|
656
|
-
return false;
|
|
657
|
-
}
|
|
658
|
-
static getControlValue(value, form) {
|
|
659
|
-
if (value.indexOf(Constants.CONTROL_PREFIX) > -1) {
|
|
660
|
-
return this.getControlFromForm(value, form);
|
|
661
|
-
}
|
|
662
|
-
else
|
|
663
|
-
return value;
|
|
664
|
-
}
|
|
665
|
-
static getControlFromForm(value, form) {
|
|
666
|
-
value = value.replace(Constants.CONTROL_PREFIX, Constants.EMPTY_SPACE);
|
|
667
|
-
if (!ObjectUtility.isEmpty(form)
|
|
668
|
-
&& !ObjectUtility.isEmpty(form.controls)
|
|
669
|
-
&& !ObjectUtility.isEmpty(form.controls[value]))
|
|
670
|
-
value = form.controls[value].value;
|
|
671
|
-
return value;
|
|
672
|
-
}
|
|
673
|
-
static evaluateExpressionWithOperator(values, operator) {
|
|
674
|
-
if (!ObjectUtility.isEmpty(values)
|
|
675
|
-
&& values.length > 1
|
|
676
|
-
&& !ObjectUtility.isEmpty(operator)) {
|
|
677
|
-
switch (operator) {
|
|
678
|
-
case ComparisonOperators.EQUAL: {
|
|
679
|
-
if (values[0] == values[1])
|
|
680
|
-
return true;
|
|
681
|
-
break;
|
|
682
|
-
}
|
|
683
|
-
case ComparisonOperators.NOT_EQUAL: {
|
|
684
|
-
if (!(values[0] == values[1]))
|
|
685
|
-
return true;
|
|
686
|
-
break;
|
|
687
|
-
}
|
|
688
|
-
case ComparisonOperators.GREATER_THAN: {
|
|
689
|
-
if ((new Number(values[0])) > (new Number(values[1])))
|
|
690
|
-
return true;
|
|
691
|
-
break;
|
|
692
|
-
}
|
|
693
|
-
case ComparisonOperators.LESS_THAN: {
|
|
694
|
-
if ((new Number(values[0])) < (new Number(values[1])))
|
|
695
|
-
return true;
|
|
696
|
-
break;
|
|
697
|
-
}
|
|
698
|
-
case ComparisonOperators.GREATER_THAN_OR_EQUAL: {
|
|
699
|
-
if ((new Number(values[0])) >= (new Number(values[1])))
|
|
700
|
-
return true;
|
|
701
|
-
break;
|
|
702
|
-
}
|
|
703
|
-
case ComparisonOperators.LESS_THAN_OR_EQUAL: {
|
|
704
|
-
if ((new Number(values[0])) <= (new Number(values[1])))
|
|
705
|
-
return true;
|
|
706
|
-
break;
|
|
707
|
-
}
|
|
708
|
-
case ComparisonOperators.CONTAINS: {
|
|
709
|
-
if (Array.from(values[0]).includes(values[1]))
|
|
710
|
-
return true;
|
|
711
|
-
break;
|
|
712
|
-
}
|
|
713
|
-
default: return false;
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
return false;
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
ExpressionsUtility.expressionLoggingFlag = false;
|
|
720
|
-
ExpressionsUtility.logs = Constants.EMPTY_SPACE;
|
|
721
|
-
ExpressionsUtility.listComparisonOperators = [
|
|
722
|
-
ComparisonOperators.NOT_EQUAL,
|
|
723
|
-
ComparisonOperators.GREATER_THAN_OR_EQUAL,
|
|
724
|
-
ComparisonOperators.LESS_THAN_OR_EQUAL,
|
|
725
|
-
ComparisonOperators.EQUAL,
|
|
726
|
-
ComparisonOperators.GREATER_THAN,
|
|
727
|
-
ComparisonOperators.LESS_THAN,
|
|
728
|
-
ComparisonOperators.CONTAINS
|
|
480
|
+
class ExpressionsUtility {
|
|
481
|
+
static getExpressionLogs() {
|
|
482
|
+
return ExpressionsUtility.logs;
|
|
483
|
+
}
|
|
484
|
+
static setLoggingFlag(flag) {
|
|
485
|
+
ExpressionsUtility.expressionLoggingFlag = flag;
|
|
486
|
+
}
|
|
487
|
+
static evaluateExpression(expression, form, level) {
|
|
488
|
+
if (level <= 1)
|
|
489
|
+
ExpressionsUtility.logs = Constants.EMPTY_SPACE;
|
|
490
|
+
if (level > Constants.MAX_LEVELS)
|
|
491
|
+
return false;
|
|
492
|
+
if (this.expressionLoggingFlag)
|
|
493
|
+
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "Evaluating Expression> " + expression + " \n";
|
|
494
|
+
if (!ObjectUtility.isEmpty(expression)) {
|
|
495
|
+
if (expression.startsWith(Constants.LEFT_PARENTHESIS)
|
|
496
|
+
&& expression.endsWith(Constants.RIGHT_PARENTHESIS)) {
|
|
497
|
+
expression = expression.substring(1, expression.length - 1);
|
|
498
|
+
if (this.expressionLoggingFlag)
|
|
499
|
+
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "remove outer ( ) \n";
|
|
500
|
+
return this.evaluateExpression(expression, form, level + 1);
|
|
501
|
+
}
|
|
502
|
+
else if (expression.startsWith(Constants.LEFT_CURLY_BRACE) && expression.endsWith(Constants.RIGHT_CURLY_BRACE)) {
|
|
503
|
+
if (this.expressionLoggingFlag)
|
|
504
|
+
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "expression starts with { ends with } \n";
|
|
505
|
+
if (expression.indexOf(Constants.LEFT_PARENTHESIS) > -1 && expression.indexOf(Constants.RIGHT_PARENTHESIS) > -1) {
|
|
506
|
+
if (this.expressionLoggingFlag)
|
|
507
|
+
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "contains subexpressions \n";
|
|
508
|
+
return this.traverseSubExpressions(expression, form, level);
|
|
509
|
+
}
|
|
510
|
+
else {
|
|
511
|
+
if (this.expressionLoggingFlag)
|
|
512
|
+
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "does not contains subexpressions \n";
|
|
513
|
+
if (expression.indexOf(LogicalOperators.AND) > -1 || expression.indexOf(LogicalOperators.OR) > -1) {
|
|
514
|
+
if (this.expressionLoggingFlag)
|
|
515
|
+
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "contains && or || \n";
|
|
516
|
+
let spliter = this.getSpliter(expression);
|
|
517
|
+
let expressions = expression.split(spliter);
|
|
518
|
+
if (this.expressionLoggingFlag)
|
|
519
|
+
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "Split expressions into> " + expressions + "\n";
|
|
520
|
+
return this.validateArrayOfExpressions(expressions, spliter, form, level);
|
|
521
|
+
}
|
|
522
|
+
else {
|
|
523
|
+
if (this.expressionLoggingFlag)
|
|
524
|
+
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "this is a clean expression. \n";
|
|
525
|
+
return this.evaluateCleanExpression(expression, form, level);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
else if ((expression.startsWith(Constants.LEFT_PARENTHESIS) && !expression.endsWith(Constants.RIGHT_PARENTHESIS)) ||
|
|
530
|
+
(!expression.startsWith(Constants.LEFT_PARENTHESIS) && expression.endsWith(Constants.RIGHT_PARENTHESIS))) {
|
|
531
|
+
if (expression.startsWith(Constants.LEFT_PARENTHESIS) && !expression.endsWith(Constants.RIGHT_PARENTHESIS))
|
|
532
|
+
if (this.expressionLoggingFlag)
|
|
533
|
+
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "expression starts with ( ends with } \n";
|
|
534
|
+
if (!expression.startsWith(Constants.LEFT_PARENTHESIS) && expression.endsWith(Constants.RIGHT_PARENTHESIS))
|
|
535
|
+
if (this.expressionLoggingFlag)
|
|
536
|
+
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "expression starts with { ends with ) \n";
|
|
537
|
+
return this.traverseSubExpressions(expression, form, level);
|
|
538
|
+
}
|
|
539
|
+
else
|
|
540
|
+
return false;
|
|
541
|
+
}
|
|
542
|
+
else
|
|
543
|
+
return true;
|
|
544
|
+
}
|
|
545
|
+
static traverseSubExpressions(expression, form, level) {
|
|
546
|
+
if (this.expressionLoggingFlag)
|
|
547
|
+
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "Traverse expression> " + expression + "\n";
|
|
548
|
+
let operator = Constants.EMPTY_SPACE;
|
|
549
|
+
let lastOperator = Constants.EMPTY_SPACE;
|
|
550
|
+
let index = 0;
|
|
551
|
+
do {
|
|
552
|
+
operator = Constants.EMPTY_SPACE;
|
|
553
|
+
let subexpression = this.extractSubexpression(expression, level);
|
|
554
|
+
let result = this.evaluateExpression(subexpression, form, level + 1);
|
|
555
|
+
operator = expression.substring(subexpression.length, subexpression.length + 2);
|
|
556
|
+
if (this.expressionLoggingFlag)
|
|
557
|
+
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "subExpression> " + subexpression + " >result> " + result + " >for operator> " + operator + "\n";
|
|
558
|
+
if (!result && (operator == LogicalOperators.AND || lastOperator == LogicalOperators.AND))
|
|
559
|
+
return false;
|
|
560
|
+
if (result && (operator == LogicalOperators.OR || lastOperator == LogicalOperators.OR))
|
|
561
|
+
return true;
|
|
562
|
+
expression = expression.substring(subexpression.length + 2, expression.length);
|
|
563
|
+
if (operator !== Constants.EMPTY_SPACE)
|
|
564
|
+
lastOperator = operator;
|
|
565
|
+
if (!ObjectUtility.isEmpty(expression)) {
|
|
566
|
+
if (this.expressionLoggingFlag)
|
|
567
|
+
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "Rest of the expression> " + expression + " > lastOperator> " + lastOperator + "\n";
|
|
568
|
+
}
|
|
569
|
+
else {
|
|
570
|
+
if (this.expressionLoggingFlag)
|
|
571
|
+
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "Rest of the expression is empty.\n";
|
|
572
|
+
}
|
|
573
|
+
} while (operator == LogicalOperators.AND || operator == LogicalOperators.OR);
|
|
574
|
+
if (lastOperator == LogicalOperators.AND)
|
|
575
|
+
return true;
|
|
576
|
+
if (lastOperator == LogicalOperators.OR)
|
|
577
|
+
return false;
|
|
578
|
+
}
|
|
579
|
+
static extractSubexpression(expression, level) {
|
|
580
|
+
let ending;
|
|
581
|
+
let opening = 0;
|
|
582
|
+
if (expression.startsWith(Constants.LEFT_CURLY_BRACE))
|
|
583
|
+
ending = expression.indexOf(Constants.RIGHT_CURLY_BRACE);
|
|
584
|
+
else {
|
|
585
|
+
let index = 1;
|
|
586
|
+
let opening = 1;
|
|
587
|
+
while (opening > 0) {
|
|
588
|
+
let myChar = expression.charAt(index);
|
|
589
|
+
if (myChar == Constants.LEFT_PARENTHESIS) {
|
|
590
|
+
opening++;
|
|
591
|
+
}
|
|
592
|
+
if (myChar == Constants.RIGHT_PARENTHESIS) {
|
|
593
|
+
opening--;
|
|
594
|
+
}
|
|
595
|
+
if (index > (expression.length - 1)) {
|
|
596
|
+
break;
|
|
597
|
+
}
|
|
598
|
+
index++;
|
|
599
|
+
}
|
|
600
|
+
ending = index - 1;
|
|
601
|
+
}
|
|
602
|
+
return expression.substring(0, ending + 1);
|
|
603
|
+
}
|
|
604
|
+
static getSpliter(expression) {
|
|
605
|
+
if (expression.indexOf(LogicalOperators.AND) > -1)
|
|
606
|
+
return LogicalOperators.AND;
|
|
607
|
+
else
|
|
608
|
+
return LogicalOperators.OR;
|
|
609
|
+
}
|
|
610
|
+
static validateArrayOfExpressions(expressions, spliter, form, level) {
|
|
611
|
+
for (let expression of expressions) {
|
|
612
|
+
let result = this.evaluateCleanExpression(expression, form, level);
|
|
613
|
+
if (spliter == LogicalOperators.AND && !result)
|
|
614
|
+
return false;
|
|
615
|
+
else if (spliter == LogicalOperators.OR && result)
|
|
616
|
+
return true;
|
|
617
|
+
}
|
|
618
|
+
return (spliter == LogicalOperators.AND) ? true : false;
|
|
619
|
+
}
|
|
620
|
+
static evaluateCleanExpression(expression, form, level) {
|
|
621
|
+
expression = expression.substring(1, expression.length - 1);
|
|
622
|
+
let operator = this.containsComparisonOperator(expression);
|
|
623
|
+
if (!ObjectUtility.isEmpty(operator)) {
|
|
624
|
+
let expressionResult = this.prepareExpressionWithOperator(expression, operator, form, level);
|
|
625
|
+
return expressionResult;
|
|
626
|
+
}
|
|
627
|
+
return false;
|
|
628
|
+
}
|
|
629
|
+
static containsComparisonOperator(expressions) {
|
|
630
|
+
let i = 0;
|
|
631
|
+
while (i < this.listComparisonOperators.length) {
|
|
632
|
+
if (expressions.indexOf(this.listComparisonOperators[i]) > -1) {
|
|
633
|
+
return this.listComparisonOperators[i];
|
|
634
|
+
}
|
|
635
|
+
i++;
|
|
636
|
+
}
|
|
637
|
+
return null;
|
|
638
|
+
}
|
|
639
|
+
static prepareExpressionWithOperator(expression, operator, form, level) {
|
|
640
|
+
if (!ObjectUtility.isEmpty(this.containsComparisonOperator(expression))
|
|
641
|
+
&& expression.indexOf(operator) > -1) {
|
|
642
|
+
let values = expression.split(operator);
|
|
643
|
+
if (values.length > 1) {
|
|
644
|
+
for (let i = 0; i < values.length; i++) {
|
|
645
|
+
values[i] = this.getControlValue(values[i], form);
|
|
646
|
+
}
|
|
647
|
+
let evaluatedExpression = this.evaluateExpressionWithOperator(values, operator);
|
|
648
|
+
if (this.expressionLoggingFlag)
|
|
649
|
+
ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "evaluate clean Expression {}> " + expression + " >result> " + evaluatedExpression + "\n";
|
|
650
|
+
return evaluatedExpression;
|
|
651
|
+
}
|
|
652
|
+
else
|
|
653
|
+
return false;
|
|
654
|
+
}
|
|
655
|
+
else
|
|
656
|
+
return false;
|
|
657
|
+
}
|
|
658
|
+
static getControlValue(value, form) {
|
|
659
|
+
if (value.indexOf(Constants.CONTROL_PREFIX) > -1) {
|
|
660
|
+
return this.getControlFromForm(value, form);
|
|
661
|
+
}
|
|
662
|
+
else
|
|
663
|
+
return value;
|
|
664
|
+
}
|
|
665
|
+
static getControlFromForm(value, form) {
|
|
666
|
+
value = value.replace(Constants.CONTROL_PREFIX, Constants.EMPTY_SPACE);
|
|
667
|
+
if (!ObjectUtility.isEmpty(form)
|
|
668
|
+
&& !ObjectUtility.isEmpty(form.controls)
|
|
669
|
+
&& !ObjectUtility.isEmpty(form.controls[value]))
|
|
670
|
+
value = form.controls[value].value;
|
|
671
|
+
return value;
|
|
672
|
+
}
|
|
673
|
+
static evaluateExpressionWithOperator(values, operator) {
|
|
674
|
+
if (!ObjectUtility.isEmpty(values)
|
|
675
|
+
&& values.length > 1
|
|
676
|
+
&& !ObjectUtility.isEmpty(operator)) {
|
|
677
|
+
switch (operator) {
|
|
678
|
+
case ComparisonOperators.EQUAL: {
|
|
679
|
+
if (values[0] == values[1])
|
|
680
|
+
return true;
|
|
681
|
+
break;
|
|
682
|
+
}
|
|
683
|
+
case ComparisonOperators.NOT_EQUAL: {
|
|
684
|
+
if (!(values[0] == values[1]))
|
|
685
|
+
return true;
|
|
686
|
+
break;
|
|
687
|
+
}
|
|
688
|
+
case ComparisonOperators.GREATER_THAN: {
|
|
689
|
+
if ((new Number(values[0])) > (new Number(values[1])))
|
|
690
|
+
return true;
|
|
691
|
+
break;
|
|
692
|
+
}
|
|
693
|
+
case ComparisonOperators.LESS_THAN: {
|
|
694
|
+
if ((new Number(values[0])) < (new Number(values[1])))
|
|
695
|
+
return true;
|
|
696
|
+
break;
|
|
697
|
+
}
|
|
698
|
+
case ComparisonOperators.GREATER_THAN_OR_EQUAL: {
|
|
699
|
+
if ((new Number(values[0])) >= (new Number(values[1])))
|
|
700
|
+
return true;
|
|
701
|
+
break;
|
|
702
|
+
}
|
|
703
|
+
case ComparisonOperators.LESS_THAN_OR_EQUAL: {
|
|
704
|
+
if ((new Number(values[0])) <= (new Number(values[1])))
|
|
705
|
+
return true;
|
|
706
|
+
break;
|
|
707
|
+
}
|
|
708
|
+
case ComparisonOperators.CONTAINS: {
|
|
709
|
+
if (Array.from(values[0]).includes(values[1]))
|
|
710
|
+
return true;
|
|
711
|
+
break;
|
|
712
|
+
}
|
|
713
|
+
default: return false;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
return false;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
ExpressionsUtility.expressionLoggingFlag = false;
|
|
720
|
+
ExpressionsUtility.logs = Constants.EMPTY_SPACE;
|
|
721
|
+
ExpressionsUtility.listComparisonOperators = [
|
|
722
|
+
ComparisonOperators.NOT_EQUAL,
|
|
723
|
+
ComparisonOperators.GREATER_THAN_OR_EQUAL,
|
|
724
|
+
ComparisonOperators.LESS_THAN_OR_EQUAL,
|
|
725
|
+
ComparisonOperators.EQUAL,
|
|
726
|
+
ComparisonOperators.GREATER_THAN,
|
|
727
|
+
ComparisonOperators.LESS_THAN,
|
|
728
|
+
ComparisonOperators.CONTAINS
|
|
729
729
|
];
|
|
730
730
|
|
|
731
|
-
class ExpressionsFormComponent {
|
|
732
|
-
constructor() {
|
|
733
|
-
this.form = new FormGroup({});
|
|
734
|
-
this.activeMap = new Map();
|
|
735
|
-
this.fileList = null;
|
|
736
|
-
this.fileName = "";
|
|
737
|
-
this.onSubmit = new EventEmitter();
|
|
738
|
-
this.onInit = new EventEmitter();
|
|
739
|
-
this.alert_timeout = Constants.ALERT_TIMEOUT;
|
|
740
|
-
this.danger = { active: false, label: '' };
|
|
741
|
-
this.warning = { active: false, label: '' };
|
|
742
|
-
this.success = { active: false, label: '' };
|
|
743
|
-
this.info = { active: false, label: '' };
|
|
744
|
-
this.primary = { active: false, label: '' };
|
|
745
|
-
this.secondary = { active: false, label: '' };
|
|
746
|
-
}
|
|
747
|
-
onClick(action) {
|
|
748
|
-
let data = {
|
|
749
|
-
action: action,
|
|
750
|
-
formValues: this.form.value
|
|
751
|
-
};
|
|
752
|
-
this.onSubmit.emit(data);
|
|
753
|
-
}
|
|
754
|
-
onInitialiazation() {
|
|
755
|
-
this.onInit.emit(this.form);
|
|
756
|
-
}
|
|
757
|
-
onEnter() {
|
|
758
|
-
this.onSubmit.emit(this.form.value);
|
|
759
|
-
}
|
|
760
|
-
onChange(changeFieldId) {
|
|
761
|
-
for (let group of this.formFields) {
|
|
762
|
-
for (let input of group === null || group === void 0 ? void 0 : group.groupFields) {
|
|
763
|
-
if (!ObjectUtility.isEmpty(input.expression)
|
|
764
|
-
&& !ObjectUtility.isEmpty(input.id)
|
|
765
|
-
&& input.expression.indexOf(changeFieldId) > -1
|
|
766
|
-
&& input.id.indexOf(changeFieldId) < 0) {
|
|
767
|
-
let validationResult = this.validateExpression(input);
|
|
768
|
-
this.activeMap.set(input.id, validationResult);
|
|
769
|
-
if (!validationResult) {
|
|
770
|
-
this.onChange(input.id);
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
if (!ObjectUtility.isEmpty(this.buttons))
|
|
776
|
-
for (let input of this.buttons) {
|
|
777
|
-
if (!ObjectUtility.isEmpty(input.expression)
|
|
778
|
-
&& !ObjectUtility.isEmpty(input.id)
|
|
779
|
-
&& input.expression.indexOf(changeFieldId) > -1
|
|
780
|
-
&& input.id.indexOf(changeFieldId) < 0)
|
|
781
|
-
this.activeMap.set(input.id, this.validateExpression(input));
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
ngOnInit() {
|
|
785
|
-
this.buildFormGroup(this.formFields);
|
|
786
|
-
this.onInitialiazation();
|
|
787
|
-
}
|
|
788
|
-
runExpressionValidations() {
|
|
789
|
-
for (let group of this.formFields) {
|
|
790
|
-
for (let input of group.groupFields) {
|
|
791
|
-
this.activeMap.set(input.id, this.validateExpression(input));
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
if (!ObjectUtility.isEmpty(this.buttons))
|
|
795
|
-
for (let input of this.buttons) {
|
|
796
|
-
this.activeMap.set(input.id, this.validateExpression(input));
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
buildFormGroup(fields) {
|
|
800
|
-
this.form = FormsUtility.buildFromGroup(fields, this.disabled);
|
|
801
|
-
this.runExpressionValidations();
|
|
802
|
-
}
|
|
803
|
-
getForm() {
|
|
804
|
-
return this.form;
|
|
805
|
-
}
|
|
806
|
-
setFormValue(value) {
|
|
807
|
-
if (!ObjectUtility.isEmpty(this.form)) {
|
|
808
|
-
this.form.reset(value);
|
|
809
|
-
this.form.updateValueAndValidity();
|
|
810
|
-
this.runExpressionValidations();
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
getFormControls() {
|
|
814
|
-
if (!ObjectUtility.isEmpty(this.form)) {
|
|
815
|
-
return this.form.controls;
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
getFormControl(controlName) {
|
|
819
|
-
if (!ObjectUtility.isEmpty(this.form)
|
|
820
|
-
&& !ObjectUtility.isEmpty(this.form.controls)) {
|
|
821
|
-
return this.form.controls[controlName];
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
setFormControlValue(controlName, value) {
|
|
825
|
-
if (!ObjectUtility.isEmpty(this.form)
|
|
826
|
-
&& !ObjectUtility.isEmpty(this.form.controls)
|
|
827
|
-
&& !ObjectUtility.isEmpty(this.form.controls)
|
|
828
|
-
&& !ObjectUtility.isEmpty(this.form.controls[controlName])) {
|
|
829
|
-
this.form.controls[controlName].reset(value);
|
|
830
|
-
this.form.controls[controlName].updateValueAndValidity();
|
|
831
|
-
this.onChange(controlName);
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
includeRequired(validators) {
|
|
835
|
-
return FormsUtility.includeRequired(validators);
|
|
836
|
-
}
|
|
837
|
-
updateCheckboxValue(formArray, controlName, event, value) {
|
|
838
|
-
FormsUtility.updateCheckboxValue(this.form, formArray, controlName, event.target.checked, value);
|
|
839
|
-
this.onChange(event.target.name);
|
|
840
|
-
}
|
|
841
|
-
updateRadioValue(controlName, event, optionId) {
|
|
842
|
-
FormsUtility.updateRadioValue(this.form, controlName, event.target.checked, optionId);
|
|
843
|
-
this.onChange(event.target.name);
|
|
844
|
-
}
|
|
845
|
-
isCheckBoxChecked(controlName, optionId) {
|
|
846
|
-
return FormsUtility.isCheckBoxChecked(this.form, controlName, optionId);
|
|
847
|
-
}
|
|
848
|
-
isRadioChecked(controlName, optionId) {
|
|
849
|
-
return FormsUtility.isRadioChecked(this.form, controlName, optionId);
|
|
850
|
-
}
|
|
851
|
-
validateExpression(input) {
|
|
852
|
-
let result = ExpressionsUtility.evaluateExpression(input.expression, this.form, 1);
|
|
853
|
-
if (!result
|
|
854
|
-
&& !ObjectUtility.isEmpty(this.form)
|
|
855
|
-
&& !ObjectUtility.isEmpty(this.form.controls)
|
|
856
|
-
&& !ObjectUtility.isEmpty(this.form.controls[input.id])) {
|
|
857
|
-
this.form.controls[input.id].reset();
|
|
858
|
-
this.form.controls[input.id].updateValueAndValidity();
|
|
859
|
-
}
|
|
860
|
-
FormsUtility.setValidators(input, this.form, result);
|
|
861
|
-
return result;
|
|
862
|
-
}
|
|
863
|
-
validateExpressionsInRow(row) {
|
|
864
|
-
for (let input of row) {
|
|
865
|
-
if (this.activeMap.get(input.id))
|
|
866
|
-
return true;
|
|
867
|
-
}
|
|
868
|
-
return false;
|
|
869
|
-
}
|
|
870
|
-
resetForm() {
|
|
871
|
-
this.form = FormsUtility.resetForm(this.formFields, this.form);
|
|
872
|
-
this.runExpressionValidations();
|
|
873
|
-
}
|
|
874
|
-
getDisabled() {
|
|
875
|
-
return this.disabled;
|
|
876
|
-
}
|
|
877
|
-
setDisabled(disabled) {
|
|
878
|
-
this.disabled = disabled;
|
|
879
|
-
this.form = FormsUtility.buildFromGroup(this.formFields, this.disabled);
|
|
880
|
-
}
|
|
881
|
-
fileChange(event) {
|
|
882
|
-
this.fileList = event.target.files;
|
|
883
|
-
//console.log("fileList>",this.fileList);
|
|
884
|
-
if (!ObjectUtility.isEmpty(this.fileList) && event.target.files.length > 0)
|
|
885
|
-
this.fileName = this.fileList[0].name;
|
|
886
|
-
else
|
|
887
|
-
this.fileName = "";
|
|
888
|
-
}
|
|
889
|
-
onUploadClick(id) {
|
|
890
|
-
let data = {
|
|
891
|
-
action: 'uploadFile',
|
|
892
|
-
fileList: this.fileList,
|
|
893
|
-
fieldId: id
|
|
894
|
-
};
|
|
895
|
-
this.onSubmit.emit(data);
|
|
896
|
-
}
|
|
897
|
-
isEmpty(value) {
|
|
898
|
-
return ObjectUtility.isEmpty(value);
|
|
899
|
-
}
|
|
900
|
-
setDanger(label) {
|
|
901
|
-
this.danger.active = true;
|
|
902
|
-
this.danger.label = label;
|
|
903
|
-
setTimeout(() => {
|
|
904
|
-
this.danger.active = false;
|
|
905
|
-
}, this.alert_timeout);
|
|
906
|
-
}
|
|
907
|
-
setWarning(label) {
|
|
908
|
-
this.warning.active = true;
|
|
909
|
-
this.warning.label = label;
|
|
910
|
-
setTimeout(() => {
|
|
911
|
-
this.warning.active = false;
|
|
912
|
-
}, this.alert_timeout);
|
|
913
|
-
}
|
|
914
|
-
setSuccess(label) {
|
|
915
|
-
this.success.active = true;
|
|
916
|
-
this.success.label = label;
|
|
917
|
-
setTimeout(() => {
|
|
918
|
-
this.success.active = false;
|
|
919
|
-
}, this.alert_timeout);
|
|
920
|
-
}
|
|
921
|
-
setInfo(label) {
|
|
922
|
-
this.info.active = true;
|
|
923
|
-
this.info.label = label;
|
|
924
|
-
setTimeout(() => {
|
|
925
|
-
this.info.active = false;
|
|
926
|
-
}, this.alert_timeout);
|
|
927
|
-
}
|
|
928
|
-
setPrimary(label) {
|
|
929
|
-
this.primary.active = true;
|
|
930
|
-
this.primary.label = label;
|
|
931
|
-
setTimeout(() => {
|
|
932
|
-
this.primary.active = false;
|
|
933
|
-
}, this.alert_timeout);
|
|
934
|
-
}
|
|
935
|
-
setSecondary(label) {
|
|
936
|
-
this.secondary.active = true;
|
|
937
|
-
this.secondary.label = label;
|
|
938
|
-
setTimeout(() => {
|
|
939
|
-
this.secondary.active = false;
|
|
940
|
-
}, this.alert_timeout);
|
|
941
|
-
}
|
|
942
|
-
setAlertTimeout(timeout) {
|
|
943
|
-
this.alert_timeout = timeout;
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
/** @nocollapse */ ExpressionsFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: ExpressionsFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
947
|
-
/** @nocollapse */ ExpressionsFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: ExpressionsFormComponent, selector: "df-expressions-form", inputs: { formFields: "formFields", disabled: "disabled", buttons: "buttons" }, outputs: { onSubmit: "onSubmit", onInit: "onInit" }, ngImport: i0, template: "<form [formGroup]=\"form\" class=\"form\">\r\n <span *ngFor=\"let group of formFields\">\r\n <div class=\"row group-box\" [style]=\"group?.style\" *ngIf=\"validateExpressionsInRow(group?.groupFields)\">\r\n <span *ngIf=\"!isEmpty(group?.groupTitle)\" class=\"mt-1\">{{group?.groupTitle}}</span>\r\n <span *ngFor=\"let input of group?.groupFields\" class=\"form-group col-auto\" [hidden]=\"!activeMap.get(input.id)\">\r\n <!-- {{validateExpression(input.expression)}} -->\r\n <span *ngIf=\"activeMap.get(input.id)\">\r\n <label *ngIf=\"input.type!=='button' && input.type!=='reset' && input.type!=='submit'\" for=\"{{input.id}}\" class=\"mr-sm-2\">\r\n <div *ngIf=\"includeRequired(input.validators) || input.required===true\"\r\n [style.color]=\"input.color\"><i [className]=\"input.icon\" aria-hidden=\"true\"></i> *{{input.label}}</div>\r\n <div *ngIf=\"!includeRequired(input.validators) && (input.required===false || input.required===undefined)\"\r\n [style.color]=\"input.color\"><i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</div>\r\n </label>\r\n <div [ngSwitch]=\"input.type\">\r\n <div *ngSwitchCase=\"'text'\">\r\n <input type=\"{{input.type}}\"\r\n id=\"{{input.id}}\"\r\n name=\"{{input.id}}\"\r\n placeholder=\"{{input.label}}\"\r\n formControlName=\"{{input.id}}\"\r\n class=\"form-control form-control-sm mb-2\"\r\n (change)=\"onChange($event.target.name)\"\r\n [readonly]=\"input.readonly\"\r\n />\r\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\r\n </div>\r\n <div *ngSwitchCase=\"'number'\">\r\n <input type=\"{{input.type}}\"\r\n id=\"{{input.id}}\"\r\n name=\"{{input.id}}\"\r\n placeholder=\"{{input.label}}\"\r\n formControlName=\"{{input.id}}\"\r\n class=\"form-control form-control-sm mb-2\"\r\n (change)=\"onChange($event.target.name)\"\r\n [readonly]=\"input.readonly\"\r\n />\r\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\r\n </div>\r\n <div *ngSwitchCase=\"'date'\">\r\n <input type=\"{{input.type}}\"\r\n id=\"{{input.id}}\"\r\n name=\"{{input.id}}\"\r\n formControlName=\"{{input.id}}\"\r\n class=\"form-control form-control-sm mb-2\"\r\n (change)=\"onChange($event.target.name)\"\r\n [readonly]=\"input.readonly\"\r\n />\r\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\r\n </div>\r\n <div *ngSwitchCase=\"'password'\">\r\n <input type=\"{{input.type}}\"\r\n id=\"{{input.id}}\"\r\n name=\"{{input.id}}\"\r\n placeholder=\"{{input.label}}\"\r\n formControlName=\"{{input.id}}\"\r\n class=\"form-control mb-2\"\r\n (change)=\"onChange($event.target.name)\"\r\n [readonly]=\"input.readonly\"\r\n />\r\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\r\n </div>\r\n <div *ngSwitchCase=\"'file'\">\r\n <div class=\"form-group\">\r\n <div class=\"input-group\">\r\n <div class=\"custom-file\">\r\n <input type=\"file\"\r\n class=\"form-control mb-2\"\r\n id=\"{{input.id}}\"\r\n accept=\"{{input.accept}}\"\r\n (change)=\"fileChange($event)\">\r\n <label class=\"custom-file-label\" for=\"{{input.id}}\">{{fileName}}</label>\r\n </div>\r\n <div class=\"input-group-append\">\r\n <span class=\"input-group-text\" (click)=\"onUploadClick(input.id)\"><i [className]=\"input.uploadIcon\" aria-hidden=\"true\"></i> {{input.uploadLabel}}</span>\r\n </div>\r\n </div>\r\n </div>\r\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\r\n </div>\r\n <div *ngSwitchCase=\"'textarea'\">\r\n <textarea\r\n id=\"{{input.id}}\"\r\n name=\"{{input.id}}\"\r\n placeholder=\"{{input.label}}\"\r\n formControlName=\"{{input.id}}\"\r\n class=\"form-control mb-2 mr-sm-2\"\r\n (change)=\"onChange($event.target.name)\"\r\n [readonly]=\"input.readonly\"\r\n ></textarea>\r\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\r\n </div>\r\n <div *ngSwitchCase=\"'combobox'\">\r\n <select name=\"{{input.id}}\"\r\n id=\"{{input.id}}\"\r\n formControlName={{input.id}}\r\n (change)=\"onChange($event.target.name)\"\r\n class=\"form-control form-control-sm mb-2\">\r\n <option [value]=\"\"></option>\r\n <option [value]=\"option.id\" *ngFor=\"let option of input.options\">\r\n <i [className]=\"option.icon\" aria-hidden=\"true\"></i> {{option.label}}</option>\r\n </select>\r\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\r\n </div>\r\n <div class=\"row\" *ngSwitchCase=\"'radio'\">\r\n <div class=\"col-auto\" [style.color]=\"input.color\" *ngFor=\"let option of input.options\">\r\n <div><i [className]=\"option.icon\" aria-hidden=\"true\"></i> {{option.label}}</div>\r\n <input type=\"{{input.type}}\"\r\n name=\"{{input.id}}\"\r\n id=\"{{input.id}}\"\r\n formControlName={{input.id}}\r\n class=\"mb-2 form-check-input\"\r\n [value]=\"option.id\"\r\n [checked]=\"isRadioChecked(input.id,option.id)\"\r\n (change)=\"updateRadioValue(input.id,$event,option.id)\"\r\n />\r\n </div>\r\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\r\n </div>\r\n <div class=\"row\" *ngSwitchCase=\"'checkbox'\">\r\n <div class=\"col-auto\" [style.color]=\"input.color\" formArrayName=\"{{input.id}}\" *ngFor=\"let option of input.options; let i=index;\">\r\n <div><i [className]=\"option.icon\" aria-hidden=\"true\"></i> {{option.label}}</div>\r\n <input type=\"{{input.type}}\"\r\n name=\"{{option.id}}\"\r\n id=\"{{option.id}}\"\r\n [formControlName]=\"i\"\r\n [value]=\"input.options[i].id\"\r\n class=\"mb-2 form-check-input\"\r\n [checked]=\"isCheckBoxChecked(input.id,i)\"\r\n (change)=\"updateCheckboxValue(input.id,i,$event,input.options[i].id)\"\r\n />\r\n </div>\r\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\r\n </div>\r\n </div>\r\n </span>\r\n </span>\r\n </div>\r\n </span>\r\n <div class=\"row\">\r\n <div *ngIf=\"success.active\" class=\"grow alert alert-success mb-4 ml-3 mr-3\">\r\n <i class=\"fa fa-check\" aria-hidden=\"true\"></i> {{success.label}}</div>\r\n <div *ngIf=\"danger.active\" class=\"grow alert alert-danger mb-4 ml-3 mr-3\">\r\n <i class=\"fa fa-times\" aria-hidden=\"true\"></i> {{danger.label}}</div>\r\n <div *ngIf=\"warning.active\" class=\"grow alert alert-warning mb-4 ml-3 mr-3\">\r\n <i class=\"fa fa-exclamation-triangle\" aria-hidden=\"true\"></i> {{warning.label}}</div>\r\n <div *ngIf=\"info.active\" class=\"grow alert alert-info mb-4 ml-3 mr-3\">\r\n <i class=\"fa fa-info\" aria-hidden=\"true\"></i> {{info.label}}</div>\r\n <div *ngIf=\"primary.active\" class=\"grow alert alert-primary mb-4 ml-3 mr-3\">\r\n <i class=\"fa fa-exclamation\" aria-hidden=\"true\"></i> {{primary.label}}</div>\r\n <div *ngIf=\"secondary.active\" class=\"grow alert alert-secondary mb-4 ml-3 mr-3\">\r\n <i class=\"fa fa-exclamation\" aria-hidden=\"true\"></i> {{secondary.label}}</div>\r\n </div>\r\n <div class=\"d-flex justify-content-around\">\r\n <div *ngFor=\"let input of buttons\" [hidden]=\"!activeMap.get(input.id)\">\r\n <div [ngSwitch]=\"input.type\" *ngIf=\"activeMap.get(input.id)\">\r\n <div *ngSwitchCase=\"'button'\">\r\n <button type=\"{{input.type}}\" class=\"btn btn-secondary m-2\" (click)=\"onClick(input.action)\">\r\n <i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</button>\r\n </div>\r\n <div *ngSwitchCase=\"'submit'\">\r\n <button type=\"{{input.type}}\" class=\"btn btn-primary m-2\" (click)=\"onClick(input.action)\" [disabled]=\"!form.valid\">\r\n <i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</button>\r\n </div>\r\n <div *ngSwitchCase=\"'reset'\">\r\n <button type=\"'button'\" class=\"btn btn-secondary m-2\" (click)=\"resetForm()\">\r\n <i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </form>\r\n", styles: [".alert{display:inline-block}.grow{flex-grow:1}textarea:focus,select:focus,input[type=text]:focus,input[type=password]:focus,input[type=datetime]:focus,input[type=datetime-local]:focus,input[type=date]:focus,input[type=month]:focus,input[type=time]:focus,input[type=week]:focus,input[type=number]:focus,input[type=email]:focus,input[type=url]:focus,input[type=search]:focus,input[type=tel]:focus,input[type=color]:focus,input[type=checkbox]:focus,input[type=radio]:focus,button:focus,.uneditable-input:focus{border-color:green;box-shadow:0 1px 1px #00000013 inset,0 0 8px green;outline:0 none}.col-auto{flex-grow:1}.radio,.checkbox{width:15px;height:15px}.group-box{padding:4px}.btn-primary{background-color:green;border-color:green}.form-check-input:checked{background-color:green;border-color:green}\n"], components: [{ type: AlertComponent, selector: "df-alert", inputs: ["form", "input"] }], directives: [{ type: i2$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i2$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i2$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i2.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i2$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i2$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i2$1.FormControlName, selector: "[formControlName]", inputs: ["disabled", "formControlName", "ngModel"], outputs: ["ngModelChange"] }, { type: i2$1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { type: i2$1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i2$1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i2$1.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }] });
|
|
948
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: ExpressionsFormComponent, decorators: [{
|
|
949
|
-
type: Component,
|
|
950
|
-
args: [{
|
|
951
|
-
selector: 'df-expressions-form',
|
|
952
|
-
templateUrl: './expressions-form.component.html',
|
|
953
|
-
styleUrls: ['./expressions-form.component.scss']
|
|
954
|
-
}]
|
|
955
|
-
}], ctorParameters: function () { return []; }, propDecorators: { formFields: [{
|
|
956
|
-
type: Input
|
|
957
|
-
}], disabled: [{
|
|
958
|
-
type: Input
|
|
959
|
-
}], buttons: [{
|
|
960
|
-
type: Input
|
|
961
|
-
}], onSubmit: [{
|
|
962
|
-
type: Output
|
|
963
|
-
}], onInit: [{
|
|
964
|
-
type: Output
|
|
731
|
+
class ExpressionsFormComponent {
|
|
732
|
+
constructor() {
|
|
733
|
+
this.form = new FormGroup({});
|
|
734
|
+
this.activeMap = new Map();
|
|
735
|
+
this.fileList = null;
|
|
736
|
+
this.fileName = "";
|
|
737
|
+
this.onSubmit = new EventEmitter();
|
|
738
|
+
this.onInit = new EventEmitter();
|
|
739
|
+
this.alert_timeout = Constants.ALERT_TIMEOUT;
|
|
740
|
+
this.danger = { active: false, label: '' };
|
|
741
|
+
this.warning = { active: false, label: '' };
|
|
742
|
+
this.success = { active: false, label: '' };
|
|
743
|
+
this.info = { active: false, label: '' };
|
|
744
|
+
this.primary = { active: false, label: '' };
|
|
745
|
+
this.secondary = { active: false, label: '' };
|
|
746
|
+
}
|
|
747
|
+
onClick(action) {
|
|
748
|
+
let data = {
|
|
749
|
+
action: action,
|
|
750
|
+
formValues: this.form.value
|
|
751
|
+
};
|
|
752
|
+
this.onSubmit.emit(data);
|
|
753
|
+
}
|
|
754
|
+
onInitialiazation() {
|
|
755
|
+
this.onInit.emit(this.form);
|
|
756
|
+
}
|
|
757
|
+
onEnter() {
|
|
758
|
+
this.onSubmit.emit(this.form.value);
|
|
759
|
+
}
|
|
760
|
+
onChange(changeFieldId) {
|
|
761
|
+
for (let group of this.formFields) {
|
|
762
|
+
for (let input of group === null || group === void 0 ? void 0 : group.groupFields) {
|
|
763
|
+
if (!ObjectUtility.isEmpty(input.expression)
|
|
764
|
+
&& !ObjectUtility.isEmpty(input.id)
|
|
765
|
+
&& input.expression.indexOf(changeFieldId) > -1
|
|
766
|
+
&& input.id.indexOf(changeFieldId) < 0) {
|
|
767
|
+
let validationResult = this.validateExpression(input);
|
|
768
|
+
this.activeMap.set(input.id, validationResult);
|
|
769
|
+
if (!validationResult) {
|
|
770
|
+
this.onChange(input.id);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
if (!ObjectUtility.isEmpty(this.buttons))
|
|
776
|
+
for (let input of this.buttons) {
|
|
777
|
+
if (!ObjectUtility.isEmpty(input.expression)
|
|
778
|
+
&& !ObjectUtility.isEmpty(input.id)
|
|
779
|
+
&& input.expression.indexOf(changeFieldId) > -1
|
|
780
|
+
&& input.id.indexOf(changeFieldId) < 0)
|
|
781
|
+
this.activeMap.set(input.id, this.validateExpression(input));
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
ngOnInit() {
|
|
785
|
+
this.buildFormGroup(this.formFields);
|
|
786
|
+
this.onInitialiazation();
|
|
787
|
+
}
|
|
788
|
+
runExpressionValidations() {
|
|
789
|
+
for (let group of this.formFields) {
|
|
790
|
+
for (let input of group.groupFields) {
|
|
791
|
+
this.activeMap.set(input.id, this.validateExpression(input));
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
if (!ObjectUtility.isEmpty(this.buttons))
|
|
795
|
+
for (let input of this.buttons) {
|
|
796
|
+
this.activeMap.set(input.id, this.validateExpression(input));
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
buildFormGroup(fields) {
|
|
800
|
+
this.form = FormsUtility.buildFromGroup(fields, this.disabled);
|
|
801
|
+
this.runExpressionValidations();
|
|
802
|
+
}
|
|
803
|
+
getForm() {
|
|
804
|
+
return this.form;
|
|
805
|
+
}
|
|
806
|
+
setFormValue(value) {
|
|
807
|
+
if (!ObjectUtility.isEmpty(this.form)) {
|
|
808
|
+
this.form.reset(value);
|
|
809
|
+
this.form.updateValueAndValidity();
|
|
810
|
+
this.runExpressionValidations();
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
getFormControls() {
|
|
814
|
+
if (!ObjectUtility.isEmpty(this.form)) {
|
|
815
|
+
return this.form.controls;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
getFormControl(controlName) {
|
|
819
|
+
if (!ObjectUtility.isEmpty(this.form)
|
|
820
|
+
&& !ObjectUtility.isEmpty(this.form.controls)) {
|
|
821
|
+
return this.form.controls[controlName];
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
setFormControlValue(controlName, value) {
|
|
825
|
+
if (!ObjectUtility.isEmpty(this.form)
|
|
826
|
+
&& !ObjectUtility.isEmpty(this.form.controls)
|
|
827
|
+
&& !ObjectUtility.isEmpty(this.form.controls)
|
|
828
|
+
&& !ObjectUtility.isEmpty(this.form.controls[controlName])) {
|
|
829
|
+
this.form.controls[controlName].reset(value);
|
|
830
|
+
this.form.controls[controlName].updateValueAndValidity();
|
|
831
|
+
this.onChange(controlName);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
includeRequired(validators) {
|
|
835
|
+
return FormsUtility.includeRequired(validators);
|
|
836
|
+
}
|
|
837
|
+
updateCheckboxValue(formArray, controlName, event, value) {
|
|
838
|
+
FormsUtility.updateCheckboxValue(this.form, formArray, controlName, event.target.checked, value);
|
|
839
|
+
this.onChange(event.target.name);
|
|
840
|
+
}
|
|
841
|
+
updateRadioValue(controlName, event, optionId) {
|
|
842
|
+
FormsUtility.updateRadioValue(this.form, controlName, event.target.checked, optionId);
|
|
843
|
+
this.onChange(event.target.name);
|
|
844
|
+
}
|
|
845
|
+
isCheckBoxChecked(controlName, optionId) {
|
|
846
|
+
return FormsUtility.isCheckBoxChecked(this.form, controlName, optionId);
|
|
847
|
+
}
|
|
848
|
+
isRadioChecked(controlName, optionId) {
|
|
849
|
+
return FormsUtility.isRadioChecked(this.form, controlName, optionId);
|
|
850
|
+
}
|
|
851
|
+
validateExpression(input) {
|
|
852
|
+
let result = ExpressionsUtility.evaluateExpression(input.expression, this.form, 1);
|
|
853
|
+
if (!result
|
|
854
|
+
&& !ObjectUtility.isEmpty(this.form)
|
|
855
|
+
&& !ObjectUtility.isEmpty(this.form.controls)
|
|
856
|
+
&& !ObjectUtility.isEmpty(this.form.controls[input.id])) {
|
|
857
|
+
this.form.controls[input.id].reset();
|
|
858
|
+
this.form.controls[input.id].updateValueAndValidity();
|
|
859
|
+
}
|
|
860
|
+
FormsUtility.setValidators(input, this.form, result);
|
|
861
|
+
return result;
|
|
862
|
+
}
|
|
863
|
+
validateExpressionsInRow(row) {
|
|
864
|
+
for (let input of row) {
|
|
865
|
+
if (this.activeMap.get(input.id))
|
|
866
|
+
return true;
|
|
867
|
+
}
|
|
868
|
+
return false;
|
|
869
|
+
}
|
|
870
|
+
resetForm() {
|
|
871
|
+
this.form = FormsUtility.resetForm(this.formFields, this.form);
|
|
872
|
+
this.runExpressionValidations();
|
|
873
|
+
}
|
|
874
|
+
getDisabled() {
|
|
875
|
+
return this.disabled;
|
|
876
|
+
}
|
|
877
|
+
setDisabled(disabled) {
|
|
878
|
+
this.disabled = disabled;
|
|
879
|
+
this.form = FormsUtility.buildFromGroup(this.formFields, this.disabled);
|
|
880
|
+
}
|
|
881
|
+
fileChange(event) {
|
|
882
|
+
this.fileList = event.target.files;
|
|
883
|
+
//console.log("fileList>",this.fileList);
|
|
884
|
+
if (!ObjectUtility.isEmpty(this.fileList) && event.target.files.length > 0)
|
|
885
|
+
this.fileName = this.fileList[0].name;
|
|
886
|
+
else
|
|
887
|
+
this.fileName = "";
|
|
888
|
+
}
|
|
889
|
+
onUploadClick(id) {
|
|
890
|
+
let data = {
|
|
891
|
+
action: 'uploadFile',
|
|
892
|
+
fileList: this.fileList,
|
|
893
|
+
fieldId: id
|
|
894
|
+
};
|
|
895
|
+
this.onSubmit.emit(data);
|
|
896
|
+
}
|
|
897
|
+
isEmpty(value) {
|
|
898
|
+
return ObjectUtility.isEmpty(value);
|
|
899
|
+
}
|
|
900
|
+
setDanger(label) {
|
|
901
|
+
this.danger.active = true;
|
|
902
|
+
this.danger.label = label;
|
|
903
|
+
setTimeout(() => {
|
|
904
|
+
this.danger.active = false;
|
|
905
|
+
}, this.alert_timeout);
|
|
906
|
+
}
|
|
907
|
+
setWarning(label) {
|
|
908
|
+
this.warning.active = true;
|
|
909
|
+
this.warning.label = label;
|
|
910
|
+
setTimeout(() => {
|
|
911
|
+
this.warning.active = false;
|
|
912
|
+
}, this.alert_timeout);
|
|
913
|
+
}
|
|
914
|
+
setSuccess(label) {
|
|
915
|
+
this.success.active = true;
|
|
916
|
+
this.success.label = label;
|
|
917
|
+
setTimeout(() => {
|
|
918
|
+
this.success.active = false;
|
|
919
|
+
}, this.alert_timeout);
|
|
920
|
+
}
|
|
921
|
+
setInfo(label) {
|
|
922
|
+
this.info.active = true;
|
|
923
|
+
this.info.label = label;
|
|
924
|
+
setTimeout(() => {
|
|
925
|
+
this.info.active = false;
|
|
926
|
+
}, this.alert_timeout);
|
|
927
|
+
}
|
|
928
|
+
setPrimary(label) {
|
|
929
|
+
this.primary.active = true;
|
|
930
|
+
this.primary.label = label;
|
|
931
|
+
setTimeout(() => {
|
|
932
|
+
this.primary.active = false;
|
|
933
|
+
}, this.alert_timeout);
|
|
934
|
+
}
|
|
935
|
+
setSecondary(label) {
|
|
936
|
+
this.secondary.active = true;
|
|
937
|
+
this.secondary.label = label;
|
|
938
|
+
setTimeout(() => {
|
|
939
|
+
this.secondary.active = false;
|
|
940
|
+
}, this.alert_timeout);
|
|
941
|
+
}
|
|
942
|
+
setAlertTimeout(timeout) {
|
|
943
|
+
this.alert_timeout = timeout;
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
/** @nocollapse */ ExpressionsFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: ExpressionsFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
947
|
+
/** @nocollapse */ ExpressionsFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: ExpressionsFormComponent, selector: "df-expressions-form", inputs: { formFields: "formFields", disabled: "disabled", buttons: "buttons" }, outputs: { onSubmit: "onSubmit", onInit: "onInit" }, ngImport: i0, template: "<form [formGroup]=\"form\" class=\"form\">\n <span *ngFor=\"let group of formFields\">\n <div class=\"row group-box\" [style]=\"group?.style\" *ngIf=\"validateExpressionsInRow(group?.groupFields)\">\n <span *ngIf=\"!isEmpty(group?.groupTitle)\" class=\"mt-1\">{{group?.groupTitle}}</span>\n <span *ngFor=\"let input of group?.groupFields\" class=\"form-group col-auto\" [hidden]=\"!activeMap.get(input.id)\">\n <!-- {{validateExpression(input.expression)}} -->\n <span *ngIf=\"activeMap.get(input.id)\">\n <label *ngIf=\"input.type!=='button' && input.type!=='reset' && input.type!=='submit'\" for=\"{{input.id}}\" class=\"mr-sm-2\">\n <div *ngIf=\"includeRequired(input.validators) || input.required===true\"\n [style.color]=\"input.color\"><i [className]=\"input.icon\" aria-hidden=\"true\"></i> *{{input.label}}</div>\n <div *ngIf=\"!includeRequired(input.validators) && (input.required===false || input.required===undefined)\"\n [style.color]=\"input.color\"><i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</div>\n </label>\n <div [ngSwitch]=\"input.type\">\n <div *ngSwitchCase=\"'text'\">\n <input type=\"{{input.type}}\"\n id=\"{{input.id}}\"\n name=\"{{input.id}}\"\n placeholder=\"{{input.label}}\"\n formControlName=\"{{input.id}}\"\n class=\"form-control form-control-sm mb-2\"\n (change)=\"onChange($event.target.name)\"\n [readonly]=\"input.readonly\"\n />\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\n </div>\n <div *ngSwitchCase=\"'number'\">\n <input type=\"{{input.type}}\"\n id=\"{{input.id}}\"\n name=\"{{input.id}}\"\n placeholder=\"{{input.label}}\"\n formControlName=\"{{input.id}}\"\n class=\"form-control form-control-sm mb-2\"\n (change)=\"onChange($event.target.name)\"\n [readonly]=\"input.readonly\"\n />\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\n </div>\n <div *ngSwitchCase=\"'date'\">\n <input type=\"{{input.type}}\"\n id=\"{{input.id}}\"\n name=\"{{input.id}}\"\n formControlName=\"{{input.id}}\"\n class=\"form-control form-control-sm mb-2\"\n (change)=\"onChange($event.target.name)\"\n [readonly]=\"input.readonly\"\n />\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\n </div>\n <div *ngSwitchCase=\"'password'\">\n <input type=\"{{input.type}}\"\n id=\"{{input.id}}\"\n name=\"{{input.id}}\"\n placeholder=\"{{input.label}}\"\n formControlName=\"{{input.id}}\"\n class=\"form-control mb-2\"\n (change)=\"onChange($event.target.name)\"\n [readonly]=\"input.readonly\"\n />\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\n </div>\n <div *ngSwitchCase=\"'file'\">\n <div class=\"form-group\">\n <div class=\"input-group\">\n <div class=\"custom-file\">\n <input type=\"file\"\n class=\"form-control mb-2\"\n id=\"{{input.id}}\"\n accept=\"{{input.accept}}\"\n (change)=\"fileChange($event)\">\n <label class=\"custom-file-label\" for=\"{{input.id}}\">{{fileName}}</label>\n </div>\n <div class=\"input-group-append\">\n <span class=\"input-group-text\" (click)=\"onUploadClick(input.id)\"><i [className]=\"input.uploadIcon\" aria-hidden=\"true\"></i> {{input.uploadLabel}}</span>\n </div>\n </div>\n </div>\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\n </div>\n <div *ngSwitchCase=\"'textarea'\">\n <textarea\n id=\"{{input.id}}\"\n name=\"{{input.id}}\"\n placeholder=\"{{input.label}}\"\n formControlName=\"{{input.id}}\"\n class=\"form-control mb-2 mr-sm-2\"\n (change)=\"onChange($event.target.name)\"\n [readonly]=\"input.readonly\"\n ></textarea>\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\n </div>\n <div *ngSwitchCase=\"'combobox'\">\n <select name=\"{{input.id}}\"\n id=\"{{input.id}}\"\n formControlName={{input.id}}\n (change)=\"onChange($event.target.name)\"\n class=\"form-control form-control-sm mb-2\">\n <option [value]=\"\"></option>\n <option [value]=\"option.id\" *ngFor=\"let option of input.options\">\n <i [className]=\"option.icon\" aria-hidden=\"true\"></i> {{option.label}}</option>\n </select>\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\n </div>\n <div class=\"row\" *ngSwitchCase=\"'radio'\">\n <div class=\"col-auto\" [style.color]=\"input.color\" *ngFor=\"let option of input.options\">\n <div><i [className]=\"option.icon\" aria-hidden=\"true\"></i> {{option.label}}</div>\n <input type=\"{{input.type}}\"\n name=\"{{input.id}}\"\n id=\"{{input.id}}\"\n formControlName={{input.id}}\n class=\"mb-2 form-check-input\"\n [value]=\"option.id\"\n [checked]=\"isRadioChecked(input.id,option.id)\"\n (change)=\"updateRadioValue(input.id,$event,option.id)\"\n />\n </div>\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\n </div>\n <div class=\"row\" *ngSwitchCase=\"'checkbox'\">\n <div class=\"col-auto\" [style.color]=\"input.color\" formArrayName=\"{{input.id}}\" *ngFor=\"let option of input.options; let i=index;\">\n <div><i [className]=\"option.icon\" aria-hidden=\"true\"></i> {{option.label}}</div>\n <input type=\"{{input.type}}\"\n name=\"{{option.id}}\"\n id=\"{{option.id}}\"\n [formControlName]=\"i\"\n [value]=\"input.options[i].id\"\n class=\"mb-2 form-check-input\"\n [checked]=\"isCheckBoxChecked(input.id,i)\"\n (change)=\"updateCheckboxValue(input.id,i,$event,input.options[i].id)\"\n />\n </div>\n <df-alert [input]=\"input\" [form]=\"form\"></df-alert>\n </div>\n </div>\n </span>\n </span>\n </div>\n </span>\n <div class=\"row\">\n <div *ngIf=\"success.active\" class=\"grow alert alert-success mb-4 ml-3 mr-3\">\n <i class=\"fa fa-check\" aria-hidden=\"true\"></i> {{success.label}}</div>\n <div *ngIf=\"danger.active\" class=\"grow alert alert-danger mb-4 ml-3 mr-3\">\n <i class=\"fa fa-times\" aria-hidden=\"true\"></i> {{danger.label}}</div>\n <div *ngIf=\"warning.active\" class=\"grow alert alert-warning mb-4 ml-3 mr-3\">\n <i class=\"fa fa-exclamation-triangle\" aria-hidden=\"true\"></i> {{warning.label}}</div>\n <div *ngIf=\"info.active\" class=\"grow alert alert-info mb-4 ml-3 mr-3\">\n <i class=\"fa fa-info\" aria-hidden=\"true\"></i> {{info.label}}</div>\n <div *ngIf=\"primary.active\" class=\"grow alert alert-primary mb-4 ml-3 mr-3\">\n <i class=\"fa fa-exclamation\" aria-hidden=\"true\"></i> {{primary.label}}</div>\n <div *ngIf=\"secondary.active\" class=\"grow alert alert-secondary mb-4 ml-3 mr-3\">\n <i class=\"fa fa-exclamation\" aria-hidden=\"true\"></i> {{secondary.label}}</div>\n </div>\n <div class=\"d-flex justify-content-around\">\n <div *ngFor=\"let input of buttons\" [hidden]=\"!activeMap.get(input.id)\">\n <div [ngSwitch]=\"input.type\" *ngIf=\"activeMap.get(input.id)\">\n <div *ngSwitchCase=\"'button'\">\n <button type=\"{{input.type}}\" class=\"btn btn-secondary m-2\" (click)=\"onClick(input.action)\">\n <i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</button>\n </div>\n <div *ngSwitchCase=\"'submit'\">\n <button type=\"{{input.type}}\" class=\"btn btn-primary m-2\" (click)=\"onClick(input.action)\" [disabled]=\"!form.valid\">\n <i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</button>\n </div>\n <div *ngSwitchCase=\"'reset'\">\n <button type=\"'button'\" class=\"btn btn-secondary m-2\" (click)=\"resetForm()\">\n <i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</button>\n </div>\n </div>\n </div>\n </div>\n </form>\n", styles: [".alert{display:inline-block}.grow{flex-grow:1}.col-auto{flex-grow:1}.group-box{padding:4px}\n"], components: [{ type: AlertComponent, selector: "df-alert", inputs: ["form", "input"] }], directives: [{ type: i2$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i2$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i2$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i2.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i2$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i2$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i2$1.FormControlName, selector: "[formControlName]", inputs: ["disabled", "formControlName", "ngModel"], outputs: ["ngModelChange"] }, { type: i2$1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { type: i2$1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i2$1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i2$1.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }] });
|
|
948
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: ExpressionsFormComponent, decorators: [{
|
|
949
|
+
type: Component,
|
|
950
|
+
args: [{
|
|
951
|
+
selector: 'df-expressions-form',
|
|
952
|
+
templateUrl: './expressions-form.component.html',
|
|
953
|
+
styleUrls: ['./expressions-form.component.scss']
|
|
954
|
+
}]
|
|
955
|
+
}], ctorParameters: function () { return []; }, propDecorators: { formFields: [{
|
|
956
|
+
type: Input
|
|
957
|
+
}], disabled: [{
|
|
958
|
+
type: Input
|
|
959
|
+
}], buttons: [{
|
|
960
|
+
type: Input
|
|
961
|
+
}], onSubmit: [{
|
|
962
|
+
type: Output
|
|
963
|
+
}], onInit: [{
|
|
964
|
+
type: Output
|
|
965
965
|
}] } });
|
|
966
966
|
|
|
967
|
-
class AccordionFormComponent {
|
|
968
|
-
constructor() {
|
|
969
|
-
this.currentSection = 0;
|
|
970
|
-
this.initIndex = 0;
|
|
971
|
-
this.forms = [];
|
|
972
|
-
this.onSubmit = new EventEmitter();
|
|
973
|
-
this.alert_timeout = Constants.ALERT_TIMEOUT;
|
|
974
|
-
this.danger = { active: false, label: '' };
|
|
975
|
-
this.warning = { active: false, label: '' };
|
|
976
|
-
this.success = { active: false, label: '' };
|
|
977
|
-
this.info = { active: false, label: '' };
|
|
978
|
-
this.primary = { active: false, label: '' };
|
|
979
|
-
this.secondary = { active: false, label: '' };
|
|
980
|
-
}
|
|
981
|
-
ngOnInit() {
|
|
982
|
-
}
|
|
983
|
-
onClick(action) {
|
|
984
|
-
let formValues = [];
|
|
985
|
-
for (let myform of this.forms) {
|
|
986
|
-
formValues.push(myform.value);
|
|
987
|
-
}
|
|
988
|
-
let result = { action: action, formValues: formValues };
|
|
989
|
-
this.onSubmit.emit(result);
|
|
990
|
-
}
|
|
991
|
-
onSectionButtonClicked(event, index, sectionLabel) {
|
|
992
|
-
event['index'] = index;
|
|
993
|
-
event['sectionLabel'] = sectionLabel;
|
|
994
|
-
this.onSubmit.emit(event);
|
|
995
|
-
}
|
|
996
|
-
resetForms() {
|
|
997
|
-
for (const [index, section] of this.sections.entries()) {
|
|
998
|
-
for (let rows of section.sectionFields) {
|
|
999
|
-
for (let input of rows) {
|
|
1000
|
-
if (!ObjectUtility.isEmpty(input.id)
|
|
1001
|
-
&& !input.readonly
|
|
1002
|
-
&& !input.disabled) {
|
|
1003
|
-
let form = this.forms[index].form;
|
|
1004
|
-
let control = form.controls[input.id];
|
|
1005
|
-
control.reset();
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
onStart(event) {
|
|
1012
|
-
if (this.sections.length == this.forms.length) {
|
|
1013
|
-
this.forms[this.initIndex] = event;
|
|
1014
|
-
if (this.initIndex == (this.forms.length - 1))
|
|
1015
|
-
this.initIndex = 0;
|
|
1016
|
-
else
|
|
1017
|
-
this.initIndex++;
|
|
1018
|
-
}
|
|
1019
|
-
else
|
|
1020
|
-
this.forms.push(event);
|
|
1021
|
-
}
|
|
1022
|
-
getCurrentSection() {
|
|
1023
|
-
return this.currentSection;
|
|
1024
|
-
}
|
|
1025
|
-
setCurrentSection(sectionNumber) {
|
|
1026
|
-
this.currentSection = sectionNumber;
|
|
1027
|
-
}
|
|
1028
|
-
allFormsAreValid() {
|
|
1029
|
-
if (!this.forms[this.currentSection].valid)
|
|
1030
|
-
return false;
|
|
1031
|
-
for (let i = 0; i < this.forms.length; i++) {
|
|
1032
|
-
if (i != this.currentSection && !this.forms[i].valid)
|
|
1033
|
-
return false;
|
|
1034
|
-
}
|
|
1035
|
-
return true;
|
|
1036
|
-
}
|
|
1037
|
-
getHeadingId(i) {
|
|
1038
|
-
return this.accordionId + '-heading-' + i;
|
|
1039
|
-
}
|
|
1040
|
-
getCollapseId(i) {
|
|
1041
|
-
return this.accordionId + '-collapse-' + i;
|
|
1042
|
-
}
|
|
1043
|
-
isEmpty(value) {
|
|
1044
|
-
return ObjectUtility.isEmpty(value);
|
|
1045
|
-
}
|
|
1046
|
-
setDanger(label) {
|
|
1047
|
-
this.danger.active = true;
|
|
1048
|
-
this.danger.label = label;
|
|
1049
|
-
setTimeout(() => {
|
|
1050
|
-
this.danger.active = false;
|
|
1051
|
-
}, this.alert_timeout);
|
|
1052
|
-
}
|
|
1053
|
-
setWarning(label) {
|
|
1054
|
-
this.warning.active = true;
|
|
1055
|
-
this.warning.label = label;
|
|
1056
|
-
setTimeout(() => {
|
|
1057
|
-
this.warning.active = false;
|
|
1058
|
-
}, this.alert_timeout);
|
|
1059
|
-
}
|
|
1060
|
-
setSuccess(label) {
|
|
1061
|
-
this.success.active = true;
|
|
1062
|
-
this.success.label = label;
|
|
1063
|
-
setTimeout(() => {
|
|
1064
|
-
this.success.active = false;
|
|
1065
|
-
}, this.alert_timeout);
|
|
1066
|
-
}
|
|
1067
|
-
setInfo(label) {
|
|
1068
|
-
this.info.active = true;
|
|
1069
|
-
this.info.label = label;
|
|
1070
|
-
setTimeout(() => {
|
|
1071
|
-
this.info.active = false;
|
|
1072
|
-
}, this.alert_timeout);
|
|
1073
|
-
}
|
|
1074
|
-
setPrimary(label) {
|
|
1075
|
-
this.primary.active = true;
|
|
1076
|
-
this.primary.label = label;
|
|
1077
|
-
setTimeout(() => {
|
|
1078
|
-
this.primary.active = false;
|
|
1079
|
-
}, this.alert_timeout);
|
|
1080
|
-
}
|
|
1081
|
-
setSecondary(label) {
|
|
1082
|
-
this.secondary.active = true;
|
|
1083
|
-
this.secondary.label = label;
|
|
1084
|
-
setTimeout(() => {
|
|
1085
|
-
this.secondary.active = false;
|
|
1086
|
-
}, this.alert_timeout);
|
|
1087
|
-
}
|
|
1088
|
-
setAlertTimeout(timeout) {
|
|
1089
|
-
this.alert_timeout = timeout;
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
/** @nocollapse */ AccordionFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: AccordionFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1093
|
-
/** @nocollapse */ AccordionFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: AccordionFormComponent, selector: "df-accordion-form", inputs: { sections: "sections", accordionId: "accordionId", buttons: "buttons" }, outputs: { onSubmit: "onSubmit" }, ngImport: i0, template: "<div id=\"{{accordionId}}\" *ngIf=\"!isEmpty(accordionId)\">\
|
|
1094
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: AccordionFormComponent, decorators: [{
|
|
1095
|
-
type: Component,
|
|
1096
|
-
args: [{
|
|
1097
|
-
selector: 'df-accordion-form',
|
|
1098
|
-
templateUrl: './accordion-form.component.html',
|
|
1099
|
-
styleUrls: ['./accordion-form.component.scss']
|
|
1100
|
-
}]
|
|
1101
|
-
}], ctorParameters: function () { return []; }, propDecorators: { sections: [{
|
|
1102
|
-
type: Input
|
|
1103
|
-
}], accordionId: [{
|
|
1104
|
-
type: Input
|
|
1105
|
-
}], buttons: [{
|
|
1106
|
-
type: Input
|
|
1107
|
-
}], onSubmit: [{
|
|
1108
|
-
type: Output
|
|
967
|
+
class AccordionFormComponent {
|
|
968
|
+
constructor() {
|
|
969
|
+
this.currentSection = 0;
|
|
970
|
+
this.initIndex = 0;
|
|
971
|
+
this.forms = [];
|
|
972
|
+
this.onSubmit = new EventEmitter();
|
|
973
|
+
this.alert_timeout = Constants.ALERT_TIMEOUT;
|
|
974
|
+
this.danger = { active: false, label: '' };
|
|
975
|
+
this.warning = { active: false, label: '' };
|
|
976
|
+
this.success = { active: false, label: '' };
|
|
977
|
+
this.info = { active: false, label: '' };
|
|
978
|
+
this.primary = { active: false, label: '' };
|
|
979
|
+
this.secondary = { active: false, label: '' };
|
|
980
|
+
}
|
|
981
|
+
ngOnInit() {
|
|
982
|
+
}
|
|
983
|
+
onClick(action) {
|
|
984
|
+
let formValues = [];
|
|
985
|
+
for (let myform of this.forms) {
|
|
986
|
+
formValues.push(myform.value);
|
|
987
|
+
}
|
|
988
|
+
let result = { action: action, formValues: formValues };
|
|
989
|
+
this.onSubmit.emit(result);
|
|
990
|
+
}
|
|
991
|
+
onSectionButtonClicked(event, index, sectionLabel) {
|
|
992
|
+
event['index'] = index;
|
|
993
|
+
event['sectionLabel'] = sectionLabel;
|
|
994
|
+
this.onSubmit.emit(event);
|
|
995
|
+
}
|
|
996
|
+
resetForms() {
|
|
997
|
+
for (const [index, section] of this.sections.entries()) {
|
|
998
|
+
for (let rows of section.sectionFields) {
|
|
999
|
+
for (let input of rows) {
|
|
1000
|
+
if (!ObjectUtility.isEmpty(input.id)
|
|
1001
|
+
&& !input.readonly
|
|
1002
|
+
&& !input.disabled) {
|
|
1003
|
+
let form = this.forms[index].form;
|
|
1004
|
+
let control = form.controls[input.id];
|
|
1005
|
+
control.reset();
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
onStart(event) {
|
|
1012
|
+
if (this.sections.length == this.forms.length) {
|
|
1013
|
+
this.forms[this.initIndex] = event;
|
|
1014
|
+
if (this.initIndex == (this.forms.length - 1))
|
|
1015
|
+
this.initIndex = 0;
|
|
1016
|
+
else
|
|
1017
|
+
this.initIndex++;
|
|
1018
|
+
}
|
|
1019
|
+
else
|
|
1020
|
+
this.forms.push(event);
|
|
1021
|
+
}
|
|
1022
|
+
getCurrentSection() {
|
|
1023
|
+
return this.currentSection;
|
|
1024
|
+
}
|
|
1025
|
+
setCurrentSection(sectionNumber) {
|
|
1026
|
+
this.currentSection = sectionNumber;
|
|
1027
|
+
}
|
|
1028
|
+
allFormsAreValid() {
|
|
1029
|
+
if (!this.forms[this.currentSection].valid)
|
|
1030
|
+
return false;
|
|
1031
|
+
for (let i = 0; i < this.forms.length; i++) {
|
|
1032
|
+
if (i != this.currentSection && !this.forms[i].valid)
|
|
1033
|
+
return false;
|
|
1034
|
+
}
|
|
1035
|
+
return true;
|
|
1036
|
+
}
|
|
1037
|
+
getHeadingId(i) {
|
|
1038
|
+
return this.accordionId + '-heading-' + i;
|
|
1039
|
+
}
|
|
1040
|
+
getCollapseId(i) {
|
|
1041
|
+
return this.accordionId + '-collapse-' + i;
|
|
1042
|
+
}
|
|
1043
|
+
isEmpty(value) {
|
|
1044
|
+
return ObjectUtility.isEmpty(value);
|
|
1045
|
+
}
|
|
1046
|
+
setDanger(label) {
|
|
1047
|
+
this.danger.active = true;
|
|
1048
|
+
this.danger.label = label;
|
|
1049
|
+
setTimeout(() => {
|
|
1050
|
+
this.danger.active = false;
|
|
1051
|
+
}, this.alert_timeout);
|
|
1052
|
+
}
|
|
1053
|
+
setWarning(label) {
|
|
1054
|
+
this.warning.active = true;
|
|
1055
|
+
this.warning.label = label;
|
|
1056
|
+
setTimeout(() => {
|
|
1057
|
+
this.warning.active = false;
|
|
1058
|
+
}, this.alert_timeout);
|
|
1059
|
+
}
|
|
1060
|
+
setSuccess(label) {
|
|
1061
|
+
this.success.active = true;
|
|
1062
|
+
this.success.label = label;
|
|
1063
|
+
setTimeout(() => {
|
|
1064
|
+
this.success.active = false;
|
|
1065
|
+
}, this.alert_timeout);
|
|
1066
|
+
}
|
|
1067
|
+
setInfo(label) {
|
|
1068
|
+
this.info.active = true;
|
|
1069
|
+
this.info.label = label;
|
|
1070
|
+
setTimeout(() => {
|
|
1071
|
+
this.info.active = false;
|
|
1072
|
+
}, this.alert_timeout);
|
|
1073
|
+
}
|
|
1074
|
+
setPrimary(label) {
|
|
1075
|
+
this.primary.active = true;
|
|
1076
|
+
this.primary.label = label;
|
|
1077
|
+
setTimeout(() => {
|
|
1078
|
+
this.primary.active = false;
|
|
1079
|
+
}, this.alert_timeout);
|
|
1080
|
+
}
|
|
1081
|
+
setSecondary(label) {
|
|
1082
|
+
this.secondary.active = true;
|
|
1083
|
+
this.secondary.label = label;
|
|
1084
|
+
setTimeout(() => {
|
|
1085
|
+
this.secondary.active = false;
|
|
1086
|
+
}, this.alert_timeout);
|
|
1087
|
+
}
|
|
1088
|
+
setAlertTimeout(timeout) {
|
|
1089
|
+
this.alert_timeout = timeout;
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
/** @nocollapse */ AccordionFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: AccordionFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1093
|
+
/** @nocollapse */ AccordionFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: AccordionFormComponent, selector: "df-accordion-form", inputs: { sections: "sections", accordionId: "accordionId", buttons: "buttons" }, outputs: { onSubmit: "onSubmit" }, ngImport: i0, template: "<div id=\"{{accordionId}}\" *ngIf=\"!isEmpty(accordionId)\">\n <div *ngFor=\"let section of sections; let i=index\">\n <div class=\"accordion-item\">\n <h2 class=\"accordion-header\" id=\"{{getHeadingId(i)}}\">\n <button class=\"accordion-button\"\n [class.collapsed]=\"i!=0\"\n type=\"button\"\n data-bs-toggle=\"collapse\"\n (click)=\"setCurrentSection(i)\"\n [attr.data-bs-target]=\"'#'+accordionId+'-collapse-'+i\"\n aria-expanded=\"(i==0)?true:false\"\n aria-controls=\"accordionId+'-collapse-'+i\">\n <i [className]=\"section.icon\" aria-hidden=\"true\"></i> {{section.label}}\n </button>\n </h2>\n <div id=\"{{getCollapseId(i)}}\"\n class=\"accordion-collapse collapse\"\n [class.show]=\"i==0\"\n aria-labelledby=\"accordionId+'-heading-'+i\"\n [attr.data-bs-parent]=\"'#'+accordionId\">\n <div class=\"card-body\">\n <df-expressions-form\n (onInit)=\"onStart($event)\"\n (onSubmit)=\"onSectionButtonClicked($event,i,section.label)\"\n [formFields]=\"section.sectionFields\"\n [buttons]=\"section.sectionButtons\"></df-expressions-form>\n </div>\n </div>\n </div>\n </div>\n <div class=\"card\">\n <div class=\"card-header\" id=\"buttons\">\n <div class=\"row\">\n <div *ngIf=\"success.active\" class=\"grow alert alert-success mb-2\"><i class=\"fa fa-check\" aria-hidden=\"true\"></i> {{success.label}}</div>\n <div *ngIf=\"danger.active\" class=\"grow alert alert-danger mb-2\"><i class=\"fa fa-times\" aria-hidden=\"true\"></i> {{danger.label}}</div>\n <div *ngIf=\"warning.active\" class=\"grow alert alert-warning mb-2\"><i class=\"fa fa-exclamation-triangle\" aria-hidden=\"true\"></i> {{warning.label}}</div>\n <div *ngIf=\"info.active\" class=\"grow alert alert-info mb-2\"><i class=\"fa fa-info\" aria-hidden=\"true\"></i> {{info.label}}</div>\n <div *ngIf=\"primary.active\" class=\"grow alert alert-primary mb-2\"><i class=\"fa fa-exclamation\" aria-hidden=\"true\"></i> {{primary.label}}</div>\n <div *ngIf=\"secondary.active\" class=\"grow alert alert-secondary mb-2\"><i class=\"fa fa-exclamation\" aria-hidden=\"true\"></i> {{secondary.label}}</div>\n </div>\n <h5 class=\"mb-0 d-flex justify-content-around\" [hidden]=\"isEmpty(buttons)\">\n <div *ngFor=\"let input of buttons\">\n <div [ngSwitch]=\"input.type\">\n <div *ngSwitchCase=\"'button'\">\n <button type=\"{{input.type}}\" class=\"btn btn-secondary ml-2\" (click)=\"onClick(input.action)\"><i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</button>\n </div>\n <div *ngSwitchCase=\"'submit'\">\n <button type=\"{{input.type}}\" class=\"btn btn-primary ml-2\" (click)=\"onClick(input.action)\" [disabled]=\"!allFormsAreValid()\"><i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</button>\n </div>\n <div *ngSwitchCase=\"'reset'\">\n <button type=\"'button'\" class=\"btn btn-secondary ml-2\" (click)=\"resetForms()\"><i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</button>\n </div>\n </div>\n </div>\n </h5>\n </div>\n </div>\n </div>\n <div *ngIf=\"isEmpty(accordionId)\">\n <div class=\"grow alert alert-danger mb-2\"><i class=\"fa fa-times\" aria-hidden=\"true\"></i> Error:accordionId is required, please provide a value.</div>\n </div>\n", styles: [".grow{flex-grow:1}\n"], components: [{ type: ExpressionsFormComponent, selector: "df-expressions-form", inputs: ["formFields", "disabled", "buttons"], outputs: ["onSubmit", "onInit"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i2.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }] });
|
|
1094
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: AccordionFormComponent, decorators: [{
|
|
1095
|
+
type: Component,
|
|
1096
|
+
args: [{
|
|
1097
|
+
selector: 'df-accordion-form',
|
|
1098
|
+
templateUrl: './accordion-form.component.html',
|
|
1099
|
+
styleUrls: ['./accordion-form.component.scss']
|
|
1100
|
+
}]
|
|
1101
|
+
}], ctorParameters: function () { return []; }, propDecorators: { sections: [{
|
|
1102
|
+
type: Input
|
|
1103
|
+
}], accordionId: [{
|
|
1104
|
+
type: Input
|
|
1105
|
+
}], buttons: [{
|
|
1106
|
+
type: Input
|
|
1107
|
+
}], onSubmit: [{
|
|
1108
|
+
type: Output
|
|
1109
1109
|
}] } });
|
|
1110
1110
|
|
|
1111
|
-
class ModalFormComponent {
|
|
1112
|
-
constructor() {
|
|
1113
|
-
this.onSubmit = new EventEmitter();
|
|
1114
|
-
this.alert_timeout = Constants.ALERT_TIMEOUT;
|
|
1115
|
-
this.danger = { active: false, label: '' };
|
|
1116
|
-
this.warning = { active: false, label: '' };
|
|
1117
|
-
this.success = { active: false, label: '' };
|
|
1118
|
-
this.info = { active: false, label: '' };
|
|
1119
|
-
this.primary = { active: false, label: '' };
|
|
1120
|
-
this.secondary = { active: false, label: '' };
|
|
1121
|
-
}
|
|
1122
|
-
ngOnInit() {
|
|
1123
|
-
}
|
|
1124
|
-
onStart(event) {
|
|
1125
|
-
this.form = event;
|
|
1126
|
-
}
|
|
1127
|
-
getForm() {
|
|
1128
|
-
if (!ObjectUtility.isEmpty(this.form))
|
|
1129
|
-
return this.form;
|
|
1130
|
-
}
|
|
1131
|
-
getFormControls() {
|
|
1132
|
-
if (!ObjectUtility.isEmpty(this.form))
|
|
1133
|
-
return this.form.controls;
|
|
1134
|
-
}
|
|
1135
|
-
onClick(action) {
|
|
1136
|
-
let data = {
|
|
1137
|
-
action: action,
|
|
1138
|
-
formValues: this.form.value
|
|
1139
|
-
};
|
|
1140
|
-
this.onSubmit.emit(data);
|
|
1141
|
-
}
|
|
1142
|
-
isFormValid() {
|
|
1143
|
-
return this.form.valid;
|
|
1144
|
-
}
|
|
1145
|
-
resetForm() {
|
|
1146
|
-
for (let row of this.modal.fields) {
|
|
1147
|
-
for (let input of row) {
|
|
1148
|
-
if (!input.disabled
|
|
1149
|
-
&& !input.readonly) {
|
|
1150
|
-
this.form.controls[input.id].reset();
|
|
1151
|
-
}
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
}
|
|
1155
|
-
closeModal() {
|
|
1156
|
-
this.closeModalElement.nativeElement.click();
|
|
1157
|
-
}
|
|
1158
|
-
setDanger(label) {
|
|
1159
|
-
this.danger.active = true;
|
|
1160
|
-
this.danger.label = label;
|
|
1161
|
-
setTimeout(() => {
|
|
1162
|
-
this.danger.active = false;
|
|
1163
|
-
}, this.alert_timeout);
|
|
1164
|
-
}
|
|
1165
|
-
setWarning(label) {
|
|
1166
|
-
this.warning.active = true;
|
|
1167
|
-
this.warning.label = label;
|
|
1168
|
-
setTimeout(() => {
|
|
1169
|
-
this.warning.active = false;
|
|
1170
|
-
}, this.alert_timeout);
|
|
1171
|
-
}
|
|
1172
|
-
setSuccess(label) {
|
|
1173
|
-
this.success.active = true;
|
|
1174
|
-
this.success.label = label;
|
|
1175
|
-
setTimeout(() => {
|
|
1176
|
-
this.success.active = false;
|
|
1177
|
-
}, this.alert_timeout);
|
|
1178
|
-
}
|
|
1179
|
-
setInfo(label) {
|
|
1180
|
-
this.info.active = true;
|
|
1181
|
-
this.info.label = label;
|
|
1182
|
-
setTimeout(() => {
|
|
1183
|
-
this.info.active = false;
|
|
1184
|
-
}, this.alert_timeout);
|
|
1185
|
-
}
|
|
1186
|
-
setPrimary(label) {
|
|
1187
|
-
this.primary.active = true;
|
|
1188
|
-
this.primary.label = label;
|
|
1189
|
-
setTimeout(() => {
|
|
1190
|
-
this.primary.active = false;
|
|
1191
|
-
}, this.alert_timeout);
|
|
1192
|
-
}
|
|
1193
|
-
setSecondary(label) {
|
|
1194
|
-
this.secondary.active = true;
|
|
1195
|
-
this.secondary.label = label;
|
|
1196
|
-
setTimeout(() => {
|
|
1197
|
-
this.secondary.active = false;
|
|
1198
|
-
}, this.alert_timeout);
|
|
1199
|
-
}
|
|
1200
|
-
setAlertTimeout(timeout) {
|
|
1201
|
-
this.alert_timeout = timeout;
|
|
1202
|
-
}
|
|
1203
|
-
}
|
|
1204
|
-
/** @nocollapse */ ModalFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: ModalFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1205
|
-
/** @nocollapse */ ModalFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: ModalFormComponent, selector: "df-modal-form", inputs: { modal: "modal", buttons: "buttons", disabled: "disabled" }, outputs: { onSubmit: "onSubmit" }, viewQueries: [{ propertyName: "closeModalElement", first: true, predicate: ["closeModalElement"], descendants: true }], ngImport: i0, template: "<!-- Modal -->\
|
|
1206
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: ModalFormComponent, decorators: [{
|
|
1207
|
-
type: Component,
|
|
1208
|
-
args: [{
|
|
1209
|
-
selector: 'df-modal-form',
|
|
1210
|
-
templateUrl: './modal-form.component.html',
|
|
1211
|
-
styleUrls: ['./modal-form.component.scss']
|
|
1212
|
-
}]
|
|
1213
|
-
}], ctorParameters: function () { return []; }, propDecorators: { modal: [{
|
|
1214
|
-
type: Input
|
|
1215
|
-
}], buttons: [{
|
|
1216
|
-
type: Input
|
|
1217
|
-
}], disabled: [{
|
|
1218
|
-
type: Input
|
|
1219
|
-
}], onSubmit: [{
|
|
1220
|
-
type: Output
|
|
1221
|
-
}], closeModalElement: [{
|
|
1222
|
-
type: ViewChild,
|
|
1223
|
-
args: ['closeModalElement', {}]
|
|
1111
|
+
class ModalFormComponent {
|
|
1112
|
+
constructor() {
|
|
1113
|
+
this.onSubmit = new EventEmitter();
|
|
1114
|
+
this.alert_timeout = Constants.ALERT_TIMEOUT;
|
|
1115
|
+
this.danger = { active: false, label: '' };
|
|
1116
|
+
this.warning = { active: false, label: '' };
|
|
1117
|
+
this.success = { active: false, label: '' };
|
|
1118
|
+
this.info = { active: false, label: '' };
|
|
1119
|
+
this.primary = { active: false, label: '' };
|
|
1120
|
+
this.secondary = { active: false, label: '' };
|
|
1121
|
+
}
|
|
1122
|
+
ngOnInit() {
|
|
1123
|
+
}
|
|
1124
|
+
onStart(event) {
|
|
1125
|
+
this.form = event;
|
|
1126
|
+
}
|
|
1127
|
+
getForm() {
|
|
1128
|
+
if (!ObjectUtility.isEmpty(this.form))
|
|
1129
|
+
return this.form;
|
|
1130
|
+
}
|
|
1131
|
+
getFormControls() {
|
|
1132
|
+
if (!ObjectUtility.isEmpty(this.form))
|
|
1133
|
+
return this.form.controls;
|
|
1134
|
+
}
|
|
1135
|
+
onClick(action) {
|
|
1136
|
+
let data = {
|
|
1137
|
+
action: action,
|
|
1138
|
+
formValues: this.form.value
|
|
1139
|
+
};
|
|
1140
|
+
this.onSubmit.emit(data);
|
|
1141
|
+
}
|
|
1142
|
+
isFormValid() {
|
|
1143
|
+
return this.form.valid;
|
|
1144
|
+
}
|
|
1145
|
+
resetForm() {
|
|
1146
|
+
for (let row of this.modal.fields) {
|
|
1147
|
+
for (let input of row) {
|
|
1148
|
+
if (!input.disabled
|
|
1149
|
+
&& !input.readonly) {
|
|
1150
|
+
this.form.controls[input.id].reset();
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
closeModal() {
|
|
1156
|
+
this.closeModalElement.nativeElement.click();
|
|
1157
|
+
}
|
|
1158
|
+
setDanger(label) {
|
|
1159
|
+
this.danger.active = true;
|
|
1160
|
+
this.danger.label = label;
|
|
1161
|
+
setTimeout(() => {
|
|
1162
|
+
this.danger.active = false;
|
|
1163
|
+
}, this.alert_timeout);
|
|
1164
|
+
}
|
|
1165
|
+
setWarning(label) {
|
|
1166
|
+
this.warning.active = true;
|
|
1167
|
+
this.warning.label = label;
|
|
1168
|
+
setTimeout(() => {
|
|
1169
|
+
this.warning.active = false;
|
|
1170
|
+
}, this.alert_timeout);
|
|
1171
|
+
}
|
|
1172
|
+
setSuccess(label) {
|
|
1173
|
+
this.success.active = true;
|
|
1174
|
+
this.success.label = label;
|
|
1175
|
+
setTimeout(() => {
|
|
1176
|
+
this.success.active = false;
|
|
1177
|
+
}, this.alert_timeout);
|
|
1178
|
+
}
|
|
1179
|
+
setInfo(label) {
|
|
1180
|
+
this.info.active = true;
|
|
1181
|
+
this.info.label = label;
|
|
1182
|
+
setTimeout(() => {
|
|
1183
|
+
this.info.active = false;
|
|
1184
|
+
}, this.alert_timeout);
|
|
1185
|
+
}
|
|
1186
|
+
setPrimary(label) {
|
|
1187
|
+
this.primary.active = true;
|
|
1188
|
+
this.primary.label = label;
|
|
1189
|
+
setTimeout(() => {
|
|
1190
|
+
this.primary.active = false;
|
|
1191
|
+
}, this.alert_timeout);
|
|
1192
|
+
}
|
|
1193
|
+
setSecondary(label) {
|
|
1194
|
+
this.secondary.active = true;
|
|
1195
|
+
this.secondary.label = label;
|
|
1196
|
+
setTimeout(() => {
|
|
1197
|
+
this.secondary.active = false;
|
|
1198
|
+
}, this.alert_timeout);
|
|
1199
|
+
}
|
|
1200
|
+
setAlertTimeout(timeout) {
|
|
1201
|
+
this.alert_timeout = timeout;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
/** @nocollapse */ ModalFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: ModalFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1205
|
+
/** @nocollapse */ ModalFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: ModalFormComponent, selector: "df-modal-form", inputs: { modal: "modal", buttons: "buttons", disabled: "disabled" }, outputs: { onSubmit: "onSubmit" }, viewQueries: [{ propertyName: "closeModalElement", first: true, predicate: ["closeModalElement"], descendants: true }], ngImport: i0, template: "<!-- Modal -->\n<div class=\"modal fade\" id=\"{{modal.id}}\" tabindex=\"-1\" role=\"dialog\"\n aria-labelledby=\"exampleModalCenterTitle\" aria-hidden=\"true\">\n <div class=\"modal-dialog modal-dialog-centered modal-lg\" role=\"document\">\n <div class=\"modal-content\">\n <div class=\"modal-header\">\n <h5 class=\"modal-title\" id=\"exampleModalLongTitle\"><i [className]=\"modal.icon\" aria-hidden=\"true\"></i> {{modal.tittle}}</h5>\n <button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"modal\" aria-label=\"Close\" #closeModalElement>\n </button>\n </div>\n <div class=\"modal-body\">\n <df-expressions-form\n (onInit)=\"onStart($event)\"\n [formFields]=\"modal.fields\"\n [disabled]=\"disabled\"></df-expressions-form>\n </div>\n <div class=\"modal-footer\">\n <div class=\"row grow\">\n <div *ngIf=\"success.active\" class=\"grow alert alert-success m-2\"><i class=\"fa fa-check\" aria-hidden=\"true\"></i> {{success.label}}</div>\n <div *ngIf=\"danger.active\" class=\"grow alert alert-danger m-2\"><i class=\"fa fa-times\" aria-hidden=\"true\"></i> {{danger.label}}</div>\n <div *ngIf=\"warning.active\" class=\"grow alert alert-warning m-2\"><i class=\"fa fa-exclamation-triangle\" aria-hidden=\"true\"></i> {{warning.label}}</div>\n <div *ngIf=\"info.active\" class=\"grow alert alert-info m-2\"><i class=\"fa fa-info\" aria-hidden=\"true\"></i> {{info.label}}</div>\n <div *ngIf=\"primary.active\" class=\"grow alert alert-primary m-2\"><i class=\"fa fa-exclamation\" aria-hidden=\"true\"></i> {{primary.label}}</div>\n <div *ngIf=\"secondary.active\" class=\"grow alert alert-secondary m-2\"><i class=\"fa fa-exclamation\" aria-hidden=\"true\"></i> {{secondary.label}}</div>\n </div>\n <div *ngFor=\"let input of buttons\" class=\"d-flex justify-content-around\">\n <div [ngSwitch]=\"input.type\">\n <div *ngSwitchCase=\"'button'\">\n <button type=\"{{input.type}}\" class=\"btn btn-secondary m-2\" (click)=\"onClick(input.action)\"><i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</button>\n </div>\n <div *ngSwitchCase=\"'submit'\">\n <button type=\"{{input.type}}\" class=\"btn btn-primary m-2\" (click)=\"onClick(input.action)\" [disabled]=\"!isFormValid()\"><i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</button>\n </div>\n <div *ngSwitchCase=\"'reset'\">\n <button type=\"'button'\" class=\"btn btn-secondary m-2\" (click)=\"resetForm()\"><i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</button>\n </div>\n <div *ngSwitchCase=\"'close'\">\n <button type=\"'button'\" class=\"btn btn-secondary m-2\" (click)=\"closeModal()\"><i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</button>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n", styles: [".grow{flex-grow:1}\n"], components: [{ type: ExpressionsFormComponent, selector: "df-expressions-form", inputs: ["formFields", "disabled", "buttons"], outputs: ["onSubmit", "onInit"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i2.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }] });
|
|
1206
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: ModalFormComponent, decorators: [{
|
|
1207
|
+
type: Component,
|
|
1208
|
+
args: [{
|
|
1209
|
+
selector: 'df-modal-form',
|
|
1210
|
+
templateUrl: './modal-form.component.html',
|
|
1211
|
+
styleUrls: ['./modal-form.component.scss']
|
|
1212
|
+
}]
|
|
1213
|
+
}], ctorParameters: function () { return []; }, propDecorators: { modal: [{
|
|
1214
|
+
type: Input
|
|
1215
|
+
}], buttons: [{
|
|
1216
|
+
type: Input
|
|
1217
|
+
}], disabled: [{
|
|
1218
|
+
type: Input
|
|
1219
|
+
}], onSubmit: [{
|
|
1220
|
+
type: Output
|
|
1221
|
+
}], closeModalElement: [{
|
|
1222
|
+
type: ViewChild,
|
|
1223
|
+
args: ['closeModalElement', {}]
|
|
1224
1224
|
}] } });
|
|
1225
1225
|
|
|
1226
|
-
class TabFormComponent {
|
|
1227
|
-
constructor() {
|
|
1228
|
-
this.currentSection = 0;
|
|
1229
|
-
this.initIndex = 0;
|
|
1230
|
-
this.forms = [];
|
|
1231
|
-
this.position = 'top';
|
|
1232
|
-
this.onSubmit = new EventEmitter();
|
|
1233
|
-
this.alert_timeout = Constants.ALERT_TIMEOUT;
|
|
1234
|
-
this.danger = { active: false, label: '' };
|
|
1235
|
-
this.warning = { active: false, label: '' };
|
|
1236
|
-
this.success = { active: false, label: '' };
|
|
1237
|
-
this.info = { active: false, label: '' };
|
|
1238
|
-
this.primary = { active: false, label: '' };
|
|
1239
|
-
this.secondary = { active: false, label: '' };
|
|
1240
|
-
}
|
|
1241
|
-
ngOnInit() {
|
|
1242
|
-
}
|
|
1243
|
-
getNavType() {
|
|
1244
|
-
if (!ObjectUtility.isEmpty(this.type)) {
|
|
1245
|
-
if (this.type === 'pills') {
|
|
1246
|
-
if (this.position === 'left' || this.position === 'right')
|
|
1247
|
-
return 'nav nav-pills flex-column';
|
|
1248
|
-
else
|
|
1249
|
-
return 'nav nav-pills';
|
|
1250
|
-
}
|
|
1251
|
-
else
|
|
1252
|
-
return 'nav nav-tabs';
|
|
1253
|
-
}
|
|
1254
|
-
else
|
|
1255
|
-
return 'nav nav-tabs';
|
|
1256
|
-
}
|
|
1257
|
-
getMargin() {
|
|
1258
|
-
if (!ObjectUtility.isEmpty(this.type) && this.type === 'pills') {
|
|
1259
|
-
return 'margin-item';
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
onClick(action) {
|
|
1263
|
-
let formValues = [];
|
|
1264
|
-
for (let myform of this.forms) {
|
|
1265
|
-
formValues.push(myform.value);
|
|
1266
|
-
}
|
|
1267
|
-
let result = { action: action, formValues: formValues };
|
|
1268
|
-
this.onSubmit.emit(result);
|
|
1269
|
-
}
|
|
1270
|
-
onSectionButtonClicked(event, index, sectionLabel) {
|
|
1271
|
-
event['index'] = index;
|
|
1272
|
-
event['sectionLabel'] = sectionLabel;
|
|
1273
|
-
this.onSubmit.emit(event);
|
|
1274
|
-
}
|
|
1275
|
-
getForms() {
|
|
1276
|
-
return this.forms;
|
|
1277
|
-
}
|
|
1278
|
-
resetForms() {
|
|
1279
|
-
for (const [index, section] of this.sections.entries()) {
|
|
1280
|
-
for (let rows of section.sectionFields) {
|
|
1281
|
-
for (let input of rows) {
|
|
1282
|
-
if (!ObjectUtility.isEmpty(input.id)
|
|
1283
|
-
&& !input.readonly
|
|
1284
|
-
&& !input.disabled) {
|
|
1285
|
-
let form = this.forms[index].form;
|
|
1286
|
-
let control = form.controls[input.id];
|
|
1287
|
-
control.reset();
|
|
1288
|
-
}
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
getCurrentSection() {
|
|
1294
|
-
return this.currentSection;
|
|
1295
|
-
}
|
|
1296
|
-
onStart(event) {
|
|
1297
|
-
if (this.sections.length == this.forms.length) {
|
|
1298
|
-
this.forms[this.initIndex] = event;
|
|
1299
|
-
if (this.initIndex == (this.forms.length - 1))
|
|
1300
|
-
this.initIndex = 0;
|
|
1301
|
-
else
|
|
1302
|
-
this.initIndex++;
|
|
1303
|
-
}
|
|
1304
|
-
else
|
|
1305
|
-
this.forms.push(event);
|
|
1306
|
-
}
|
|
1307
|
-
setCurrentSection(sectionNumber) {
|
|
1308
|
-
this.currentSection = sectionNumber;
|
|
1309
|
-
}
|
|
1310
|
-
allFormsAreValid() {
|
|
1311
|
-
if (!this.forms[this.currentSection].valid)
|
|
1312
|
-
return false;
|
|
1313
|
-
for (let i = 0; i < this.forms.length; i++) {
|
|
1314
|
-
if (i != this.currentSection && !this.forms[i].valid)
|
|
1315
|
-
return false;
|
|
1316
|
-
}
|
|
1317
|
-
return true;
|
|
1318
|
-
}
|
|
1319
|
-
getCols(type, position, column) {
|
|
1320
|
-
if (type == 'pills') {
|
|
1321
|
-
if (position == 'left') {
|
|
1322
|
-
if (column == 1) {
|
|
1323
|
-
return 'col-3 mycol';
|
|
1324
|
-
}
|
|
1325
|
-
else if (column == 2)
|
|
1326
|
-
return 'col-9 mycol';
|
|
1327
|
-
}
|
|
1328
|
-
else if (position == 'right') {
|
|
1329
|
-
if (column == 2) {
|
|
1330
|
-
return 'col-9 mycol';
|
|
1331
|
-
}
|
|
1332
|
-
else if (column == 3)
|
|
1333
|
-
return 'col-3 mycol';
|
|
1334
|
-
}
|
|
1335
|
-
else {
|
|
1336
|
-
if (column == 2)
|
|
1337
|
-
return 'col-12 mycol';
|
|
1338
|
-
}
|
|
1339
|
-
}
|
|
1340
|
-
else {
|
|
1341
|
-
if (column == 2)
|
|
1342
|
-
return 'col-12 mycol';
|
|
1343
|
-
}
|
|
1344
|
-
}
|
|
1345
|
-
isEmpty(value) {
|
|
1346
|
-
return ObjectUtility.isEmpty(value);
|
|
1347
|
-
}
|
|
1348
|
-
setDanger(label) {
|
|
1349
|
-
this.danger.active = true;
|
|
1350
|
-
this.danger.label = label;
|
|
1351
|
-
setTimeout(() => {
|
|
1352
|
-
this.danger.active = false;
|
|
1353
|
-
}, this.alert_timeout);
|
|
1354
|
-
}
|
|
1355
|
-
setWarning(label) {
|
|
1356
|
-
this.warning.active = true;
|
|
1357
|
-
this.warning.label = label;
|
|
1358
|
-
setTimeout(() => {
|
|
1359
|
-
this.warning.active = false;
|
|
1360
|
-
}, this.alert_timeout);
|
|
1361
|
-
}
|
|
1362
|
-
setSuccess(label) {
|
|
1363
|
-
this.success.active = true;
|
|
1364
|
-
this.success.label = label;
|
|
1365
|
-
setTimeout(() => {
|
|
1366
|
-
this.success.active = false;
|
|
1367
|
-
}, this.alert_timeout);
|
|
1368
|
-
}
|
|
1369
|
-
setInfo(label) {
|
|
1370
|
-
this.info.active = true;
|
|
1371
|
-
this.info.label = label;
|
|
1372
|
-
setTimeout(() => {
|
|
1373
|
-
this.info.active = false;
|
|
1374
|
-
}, this.alert_timeout);
|
|
1375
|
-
}
|
|
1376
|
-
setPrimary(label) {
|
|
1377
|
-
this.primary.active = true;
|
|
1378
|
-
this.primary.label = label;
|
|
1379
|
-
setTimeout(() => {
|
|
1380
|
-
this.primary.active = false;
|
|
1381
|
-
}, this.alert_timeout);
|
|
1382
|
-
}
|
|
1383
|
-
setSecondary(label) {
|
|
1384
|
-
this.secondary.active = true;
|
|
1385
|
-
this.secondary.label = label;
|
|
1386
|
-
setTimeout(() => {
|
|
1387
|
-
this.secondary.active = false;
|
|
1388
|
-
}, this.alert_timeout);
|
|
1389
|
-
}
|
|
1390
|
-
setAlertTimeout(timeout) {
|
|
1391
|
-
this.alert_timeout = timeout;
|
|
1392
|
-
}
|
|
1393
|
-
}
|
|
1394
|
-
/** @nocollapse */ TabFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: TabFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1395
|
-
/** @nocollapse */ TabFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: TabFormComponent, selector: "df-tab-form", inputs: { sections: "sections", buttons: "buttons", type: "type", tabsId: "tabsId", position: "position" }, outputs: { onSubmit: "onSubmit" }, viewQueries: [{ propertyName: "myForm", first: true, predicate: ["myForm"], descendants: true }], ngImport: i0, template: "<div *ngIf=\"!isEmpty(tabsId)\">\
|
|
1396
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: TabFormComponent, decorators: [{
|
|
1397
|
-
type: Component,
|
|
1398
|
-
args: [{
|
|
1399
|
-
selector: 'df-tab-form',
|
|
1400
|
-
templateUrl: './tab-form.component.html',
|
|
1401
|
-
styleUrls: ['./tab-form.component.scss']
|
|
1402
|
-
}]
|
|
1403
|
-
}], ctorParameters: function () { return []; }, propDecorators: { sections: [{
|
|
1404
|
-
type: Input
|
|
1405
|
-
}], buttons: [{
|
|
1406
|
-
type: Input
|
|
1407
|
-
}], type: [{
|
|
1408
|
-
type: Input
|
|
1409
|
-
}], tabsId: [{
|
|
1410
|
-
type: Input
|
|
1411
|
-
}], position: [{
|
|
1412
|
-
type: Input
|
|
1413
|
-
}], onSubmit: [{
|
|
1414
|
-
type: Output
|
|
1415
|
-
}], myForm: [{
|
|
1416
|
-
type: ViewChild,
|
|
1417
|
-
args: ['myForm', {}]
|
|
1226
|
+
class TabFormComponent {
|
|
1227
|
+
constructor() {
|
|
1228
|
+
this.currentSection = 0;
|
|
1229
|
+
this.initIndex = 0;
|
|
1230
|
+
this.forms = [];
|
|
1231
|
+
this.position = 'top';
|
|
1232
|
+
this.onSubmit = new EventEmitter();
|
|
1233
|
+
this.alert_timeout = Constants.ALERT_TIMEOUT;
|
|
1234
|
+
this.danger = { active: false, label: '' };
|
|
1235
|
+
this.warning = { active: false, label: '' };
|
|
1236
|
+
this.success = { active: false, label: '' };
|
|
1237
|
+
this.info = { active: false, label: '' };
|
|
1238
|
+
this.primary = { active: false, label: '' };
|
|
1239
|
+
this.secondary = { active: false, label: '' };
|
|
1240
|
+
}
|
|
1241
|
+
ngOnInit() {
|
|
1242
|
+
}
|
|
1243
|
+
getNavType() {
|
|
1244
|
+
if (!ObjectUtility.isEmpty(this.type)) {
|
|
1245
|
+
if (this.type === 'pills') {
|
|
1246
|
+
if (this.position === 'left' || this.position === 'right')
|
|
1247
|
+
return 'nav nav-pills flex-column';
|
|
1248
|
+
else
|
|
1249
|
+
return 'nav nav-pills';
|
|
1250
|
+
}
|
|
1251
|
+
else
|
|
1252
|
+
return 'nav nav-tabs';
|
|
1253
|
+
}
|
|
1254
|
+
else
|
|
1255
|
+
return 'nav nav-tabs';
|
|
1256
|
+
}
|
|
1257
|
+
getMargin() {
|
|
1258
|
+
if (!ObjectUtility.isEmpty(this.type) && this.type === 'pills') {
|
|
1259
|
+
return 'margin-item';
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
onClick(action) {
|
|
1263
|
+
let formValues = [];
|
|
1264
|
+
for (let myform of this.forms) {
|
|
1265
|
+
formValues.push(myform.value);
|
|
1266
|
+
}
|
|
1267
|
+
let result = { action: action, formValues: formValues };
|
|
1268
|
+
this.onSubmit.emit(result);
|
|
1269
|
+
}
|
|
1270
|
+
onSectionButtonClicked(event, index, sectionLabel) {
|
|
1271
|
+
event['index'] = index;
|
|
1272
|
+
event['sectionLabel'] = sectionLabel;
|
|
1273
|
+
this.onSubmit.emit(event);
|
|
1274
|
+
}
|
|
1275
|
+
getForms() {
|
|
1276
|
+
return this.forms;
|
|
1277
|
+
}
|
|
1278
|
+
resetForms() {
|
|
1279
|
+
for (const [index, section] of this.sections.entries()) {
|
|
1280
|
+
for (let rows of section.sectionFields) {
|
|
1281
|
+
for (let input of rows) {
|
|
1282
|
+
if (!ObjectUtility.isEmpty(input.id)
|
|
1283
|
+
&& !input.readonly
|
|
1284
|
+
&& !input.disabled) {
|
|
1285
|
+
let form = this.forms[index].form;
|
|
1286
|
+
let control = form.controls[input.id];
|
|
1287
|
+
control.reset();
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
getCurrentSection() {
|
|
1294
|
+
return this.currentSection;
|
|
1295
|
+
}
|
|
1296
|
+
onStart(event) {
|
|
1297
|
+
if (this.sections.length == this.forms.length) {
|
|
1298
|
+
this.forms[this.initIndex] = event;
|
|
1299
|
+
if (this.initIndex == (this.forms.length - 1))
|
|
1300
|
+
this.initIndex = 0;
|
|
1301
|
+
else
|
|
1302
|
+
this.initIndex++;
|
|
1303
|
+
}
|
|
1304
|
+
else
|
|
1305
|
+
this.forms.push(event);
|
|
1306
|
+
}
|
|
1307
|
+
setCurrentSection(sectionNumber) {
|
|
1308
|
+
this.currentSection = sectionNumber;
|
|
1309
|
+
}
|
|
1310
|
+
allFormsAreValid() {
|
|
1311
|
+
if (!this.forms[this.currentSection].valid)
|
|
1312
|
+
return false;
|
|
1313
|
+
for (let i = 0; i < this.forms.length; i++) {
|
|
1314
|
+
if (i != this.currentSection && !this.forms[i].valid)
|
|
1315
|
+
return false;
|
|
1316
|
+
}
|
|
1317
|
+
return true;
|
|
1318
|
+
}
|
|
1319
|
+
getCols(type, position, column) {
|
|
1320
|
+
if (type == 'pills') {
|
|
1321
|
+
if (position == 'left') {
|
|
1322
|
+
if (column == 1) {
|
|
1323
|
+
return 'col-3 mycol';
|
|
1324
|
+
}
|
|
1325
|
+
else if (column == 2)
|
|
1326
|
+
return 'col-9 mycol';
|
|
1327
|
+
}
|
|
1328
|
+
else if (position == 'right') {
|
|
1329
|
+
if (column == 2) {
|
|
1330
|
+
return 'col-9 mycol';
|
|
1331
|
+
}
|
|
1332
|
+
else if (column == 3)
|
|
1333
|
+
return 'col-3 mycol';
|
|
1334
|
+
}
|
|
1335
|
+
else {
|
|
1336
|
+
if (column == 2)
|
|
1337
|
+
return 'col-12 mycol';
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
else {
|
|
1341
|
+
if (column == 2)
|
|
1342
|
+
return 'col-12 mycol';
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
isEmpty(value) {
|
|
1346
|
+
return ObjectUtility.isEmpty(value);
|
|
1347
|
+
}
|
|
1348
|
+
setDanger(label) {
|
|
1349
|
+
this.danger.active = true;
|
|
1350
|
+
this.danger.label = label;
|
|
1351
|
+
setTimeout(() => {
|
|
1352
|
+
this.danger.active = false;
|
|
1353
|
+
}, this.alert_timeout);
|
|
1354
|
+
}
|
|
1355
|
+
setWarning(label) {
|
|
1356
|
+
this.warning.active = true;
|
|
1357
|
+
this.warning.label = label;
|
|
1358
|
+
setTimeout(() => {
|
|
1359
|
+
this.warning.active = false;
|
|
1360
|
+
}, this.alert_timeout);
|
|
1361
|
+
}
|
|
1362
|
+
setSuccess(label) {
|
|
1363
|
+
this.success.active = true;
|
|
1364
|
+
this.success.label = label;
|
|
1365
|
+
setTimeout(() => {
|
|
1366
|
+
this.success.active = false;
|
|
1367
|
+
}, this.alert_timeout);
|
|
1368
|
+
}
|
|
1369
|
+
setInfo(label) {
|
|
1370
|
+
this.info.active = true;
|
|
1371
|
+
this.info.label = label;
|
|
1372
|
+
setTimeout(() => {
|
|
1373
|
+
this.info.active = false;
|
|
1374
|
+
}, this.alert_timeout);
|
|
1375
|
+
}
|
|
1376
|
+
setPrimary(label) {
|
|
1377
|
+
this.primary.active = true;
|
|
1378
|
+
this.primary.label = label;
|
|
1379
|
+
setTimeout(() => {
|
|
1380
|
+
this.primary.active = false;
|
|
1381
|
+
}, this.alert_timeout);
|
|
1382
|
+
}
|
|
1383
|
+
setSecondary(label) {
|
|
1384
|
+
this.secondary.active = true;
|
|
1385
|
+
this.secondary.label = label;
|
|
1386
|
+
setTimeout(() => {
|
|
1387
|
+
this.secondary.active = false;
|
|
1388
|
+
}, this.alert_timeout);
|
|
1389
|
+
}
|
|
1390
|
+
setAlertTimeout(timeout) {
|
|
1391
|
+
this.alert_timeout = timeout;
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
/** @nocollapse */ TabFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: TabFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1395
|
+
/** @nocollapse */ TabFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: TabFormComponent, selector: "df-tab-form", inputs: { sections: "sections", buttons: "buttons", type: "type", tabsId: "tabsId", position: "position" }, outputs: { onSubmit: "onSubmit" }, viewQueries: [{ propertyName: "myForm", first: true, predicate: ["myForm"], descendants: true }], ngImport: i0, template: "<div *ngIf=\"!isEmpty(tabsId)\">\n <div class=\"d-flex\">\n <div class=\"col-12 mycol\">\n <ul [className]=\"getNavType()\" *ngIf=\"type=='tabs' || (position!=='left' && position!=='right')\">\n <span *ngFor=\"let section of sections; let i=index\">\n <li class=\"nav-item\" [className]=\"getMargin()\">\n <a class=\"nav-link\" [class.active]=\"(i==getCurrentSection())?true:false\"\n data-bs-toggle=\"tab\" href=\"#{{tabsId+section.id}}\"\n (click)=\"setCurrentSection(i)\">\n <i [className]=\"section.icon\" aria-hidden=\"true\"></i> {{section.label}}</a>\n </li>\n </span>\n </ul>\n </div>\n </div>\n <div class=\"d-flex\">\n <div [className]=\"getCols(type,position,1)\" *ngIf=\"type=='pills' && position=='left'\">\n <ul [className]=\"getNavType()\" class=\"flex-column\">\n <span *ngFor=\"let section of sections; let i=index\">\n <li class=\"nav-item row myrow\" [className]=\"getMargin()\">\n <a class=\"nav-link\" [class.active]=\"(i==getCurrentSection())?true:false\"\n data-bs-toggle=\"tab\" href=\"#{{tabsId+section.id}}\"\n (click)=\"setCurrentSection(i)\">\n <i [className]=\"section.icon\" aria-hidden=\"true\"></i> {{section.label}}</a>\n </li>\n </span>\n </ul>\n </div>\n <div [className]=\"getCols(type,position,2)\">\n <div id=\"myTabContent\" class=\"tab-content tab-box\">\n <span *ngFor=\"let section of sections; let j=index\">\n <div class=\"tab-pane fade\"\n [class.active]=\"(j==getCurrentSection())?true:false\"\n [class.show]=\"(j==getCurrentSection())?true:false\"\n [hidden]=\"(j!==getCurrentSection())?true:false\"\n id=\"{{tabsId+section.id}}\">\n <df-expressions-form #myForm\n (onInit)=\"onStart($event)\"\n (onSubmit)=\"onSectionButtonClicked($event,j,section.label)\"\n [formFields]=\"section.sectionFields\"\n [buttons]=\"section.sectionButtons\"></df-expressions-form>\n </div>\n </span>\n </div>\n <div class=\"tab-box mt-1\">\n <div class=\"me-3 ms-3 row\" *ngIf=\"success.active\">\n <div class=\"grow alert alert-success\"><i class=\"fa fa-check\" aria-hidden=\"true\"></i> {{success.label}}</div>\n </div>\n <div class=\"me-3 ms-3 row\" *ngIf=\"danger.active\">\n <div class=\"grow alert alert-danger\"><i class=\"fa fa-times\" aria-hidden=\"true\"></i> {{danger.label}}</div>\n </div>\n <div class=\"me-3 ms-3 row\" *ngIf=\"warning.active\">\n <div class=\"grow alert alert-warning\"><i class=\"fa fa-exclamation-triangle\" aria-hidden=\"true\"></i> {{warning.label}}</div>\n </div>\n <div class=\"me-3 ms-3 row\" *ngIf=\"info.active\">\n <div class=\"grow alert alert-info\"><i class=\"fa fa-info\" aria-hidden=\"true\"></i> {{info.label}}</div>\n </div>\n <div class=\"me-3 ms-3 row\" *ngIf=\"primary.active\">\n <div class=\"grow alert alert-primary\"><i class=\"fa fa-exclamation\" aria-hidden=\"true\"></i> {{primary.label}}</div>\n </div>\n <div class=\"me-3 ms-3 row\" *ngIf=\"secondary.active\">\n <div class=\"grow alert alert-secondary\"><i class=\"fa fa-exclamation\" aria-hidden=\"true\"></i> {{secondary.label}}</div>\n </div>\n <div class=\"m-2 d-flex justify-content-around\" *ngIf=\"!isEmpty(buttons)\">\n <div *ngFor=\"let input of buttons\">\n <div [ngSwitch]=\"input.type\">\n <div *ngSwitchCase=\"'button'\">\n <button type=\"{{input.type}}\" class=\"btn btn-secondary ms-2\" (click)=\"onClick(input.action)\"><i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</button>\n </div>\n <div *ngSwitchCase=\"'submit'\">\n <button type=\"{{input.type}}\" class=\"btn btn-primary ms-2\" (click)=\"onClick(input.action)\" [disabled]=\"!allFormsAreValid()\"><i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</button>\n </div>\n <div *ngSwitchCase=\"'reset'\">\n <button type=\"'button'\" class=\"btn btn-secondary ms-2\" (click)=\"resetForms()\"><i [className]=\"input.icon\" aria-hidden=\"true\"></i> {{input.label}}</button>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n <div [className]=\"getCols(type,position,3)\" *ngIf=\"type=='pills' && position=='right'\">\n <ul [className]=\"getNavType()\" class=\"flex-column\">\n <span *ngFor=\"let section of sections; let i=index\">\n <li class=\"nav-item row myrow\" [className]=\"getMargin()\">\n <a class=\"nav-link\" [class.active]=\"(i==getCurrentSection())?true:false\"\n data-bs-toggle=\"tab\" href=\"#{{tabsId+section.id}}\"\n (click)=\"setCurrentSection(i)\">\n <i [className]=\"section.icon\" aria-hidden=\"true\"></i> {{section.label}}</a>\n </li>\n </span>\n </ul>\n </div>\n </div>\n</div>\n<div *ngIf=\"isEmpty(tabsId)\">\n <div class=\"grow alert alert-danger mb-2\"><i class=\"fa fa-times\" aria-hidden=\"true\"></i> Error:tabsId is required, please provide a value.</div>\n</div>\n", styles: [".tab-box{padding:10px;background-color:#fff;border:#cccccc 1px solid;border-radius:4px}.tab-pane{padding:10px}.grow{flex-grow:1}.margin-item{margin:4px}.myrow{flex-grow:1;padding:0}.mycol{flex-grow:1;padding:0}\n"], components: [{ type: ExpressionsFormComponent, selector: "df-expressions-form", inputs: ["formFields", "disabled", "buttons"], outputs: ["onSubmit", "onInit"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i2.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }] });
|
|
1396
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: TabFormComponent, decorators: [{
|
|
1397
|
+
type: Component,
|
|
1398
|
+
args: [{
|
|
1399
|
+
selector: 'df-tab-form',
|
|
1400
|
+
templateUrl: './tab-form.component.html',
|
|
1401
|
+
styleUrls: ['./tab-form.component.scss']
|
|
1402
|
+
}]
|
|
1403
|
+
}], ctorParameters: function () { return []; }, propDecorators: { sections: [{
|
|
1404
|
+
type: Input
|
|
1405
|
+
}], buttons: [{
|
|
1406
|
+
type: Input
|
|
1407
|
+
}], type: [{
|
|
1408
|
+
type: Input
|
|
1409
|
+
}], tabsId: [{
|
|
1410
|
+
type: Input
|
|
1411
|
+
}], position: [{
|
|
1412
|
+
type: Input
|
|
1413
|
+
}], onSubmit: [{
|
|
1414
|
+
type: Output
|
|
1415
|
+
}], myForm: [{
|
|
1416
|
+
type: ViewChild,
|
|
1417
|
+
args: ['myForm', {}]
|
|
1418
1418
|
}] } });
|
|
1419
1419
|
|
|
1420
|
-
class AppError {
|
|
1421
|
-
constructor(originalError) {
|
|
1422
|
-
this.originalError = originalError;
|
|
1423
|
-
}
|
|
1420
|
+
class AppError {
|
|
1421
|
+
constructor(originalError) {
|
|
1422
|
+
this.originalError = originalError;
|
|
1423
|
+
}
|
|
1424
1424
|
}
|
|
1425
1425
|
|
|
1426
|
-
class InvalidUserError extends AppError {
|
|
1426
|
+
class InvalidUserError extends AppError {
|
|
1427
1427
|
}
|
|
1428
1428
|
|
|
1429
|
-
class BadRequestError extends AppError {
|
|
1429
|
+
class BadRequestError extends AppError {
|
|
1430
1430
|
}
|
|
1431
1431
|
|
|
1432
|
-
class NotFoundError extends AppError {
|
|
1432
|
+
class NotFoundError extends AppError {
|
|
1433
1433
|
}
|
|
1434
1434
|
|
|
1435
|
-
//Angular Core
|
|
1436
|
-
class DataService {
|
|
1437
|
-
constructor(_url, http) {
|
|
1438
|
-
this._url = _url;
|
|
1439
|
-
this.http = http;
|
|
1440
|
-
}
|
|
1441
|
-
getAll() {
|
|
1442
|
-
return this.http.get(this._url)
|
|
1443
|
-
.pipe(map(response => response)).pipe(catchError(this.handleError));
|
|
1444
|
-
}
|
|
1445
|
-
getByParam(params) {
|
|
1446
|
-
let param = Constants.QUESTION_MARK;
|
|
1447
|
-
params.forEach(element => {
|
|
1448
|
-
param = param + element.key + Constants.EQUAL + element.value + Constants.AMPERSAND;
|
|
1449
|
-
});
|
|
1450
|
-
return this.http.get(this._url + param)
|
|
1451
|
-
.pipe(map(response => response)).pipe(catchError(this.handleError));
|
|
1452
|
-
}
|
|
1453
|
-
create(resource) {
|
|
1454
|
-
return this.http.post(this._url, JSON.stringify(resource))
|
|
1455
|
-
.pipe(map(response => response)).pipe(catchError(this.handleError));
|
|
1456
|
-
}
|
|
1457
|
-
update(resource) {
|
|
1458
|
-
return this.http.patch(this._url + Constants.BACK_SLASH + resource.id, JSON.stringify({ isRead: true }))
|
|
1459
|
-
.pipe(map(response => response)).pipe(catchError(this.handleError));
|
|
1460
|
-
}
|
|
1461
|
-
delete(id) {
|
|
1462
|
-
return this.http.delete(this._url + Constants.BACK_SLASH + id)
|
|
1463
|
-
.pipe(map(response => response)).pipe(catchError(this.handleError));
|
|
1464
|
-
}
|
|
1465
|
-
getId(id) {
|
|
1466
|
-
return this.http.get(this._url + Constants.BACK_SLASH + id)
|
|
1467
|
-
.pipe(map(response => response)).pipe(catchError(this.handleError));
|
|
1468
|
-
}
|
|
1469
|
-
getObject(resource) {
|
|
1470
|
-
return this.http.post(this._url, resource)
|
|
1471
|
-
.pipe(map(response => response)).pipe(catchError(this.handleError));
|
|
1472
|
-
}
|
|
1473
|
-
handleError(error) {
|
|
1474
|
-
console.log('DataService.handleError.error', error);
|
|
1475
|
-
if (error.status === 404)
|
|
1476
|
-
return throwError(new NotFoundError());
|
|
1477
|
-
if (error.status === 400)
|
|
1478
|
-
return throwError(new BadRequestError());
|
|
1479
|
-
if (error.status === 401)
|
|
1480
|
-
return throwError(new InvalidUserError());
|
|
1481
|
-
return throwError(new AppError(error));
|
|
1482
|
-
}
|
|
1483
|
-
}
|
|
1484
|
-
/** @nocollapse */ DataService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: DataService, deps: [{ token: String }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1485
|
-
/** @nocollapse */ DataService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: DataService });
|
|
1486
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: DataService, decorators: [{
|
|
1487
|
-
type: Injectable
|
|
1488
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1489
|
-
type: Inject,
|
|
1490
|
-
args: [String]
|
|
1435
|
+
//Angular Core
|
|
1436
|
+
class DataService {
|
|
1437
|
+
constructor(_url, http) {
|
|
1438
|
+
this._url = _url;
|
|
1439
|
+
this.http = http;
|
|
1440
|
+
}
|
|
1441
|
+
getAll() {
|
|
1442
|
+
return this.http.get(this._url)
|
|
1443
|
+
.pipe(map(response => response)).pipe(catchError(this.handleError));
|
|
1444
|
+
}
|
|
1445
|
+
getByParam(params) {
|
|
1446
|
+
let param = Constants.QUESTION_MARK;
|
|
1447
|
+
params.forEach(element => {
|
|
1448
|
+
param = param + element.key + Constants.EQUAL + element.value + Constants.AMPERSAND;
|
|
1449
|
+
});
|
|
1450
|
+
return this.http.get(this._url + param)
|
|
1451
|
+
.pipe(map(response => response)).pipe(catchError(this.handleError));
|
|
1452
|
+
}
|
|
1453
|
+
create(resource) {
|
|
1454
|
+
return this.http.post(this._url, JSON.stringify(resource))
|
|
1455
|
+
.pipe(map(response => response)).pipe(catchError(this.handleError));
|
|
1456
|
+
}
|
|
1457
|
+
update(resource) {
|
|
1458
|
+
return this.http.patch(this._url + Constants.BACK_SLASH + resource.id, JSON.stringify({ isRead: true }))
|
|
1459
|
+
.pipe(map(response => response)).pipe(catchError(this.handleError));
|
|
1460
|
+
}
|
|
1461
|
+
delete(id) {
|
|
1462
|
+
return this.http.delete(this._url + Constants.BACK_SLASH + id)
|
|
1463
|
+
.pipe(map(response => response)).pipe(catchError(this.handleError));
|
|
1464
|
+
}
|
|
1465
|
+
getId(id) {
|
|
1466
|
+
return this.http.get(this._url + Constants.BACK_SLASH + id)
|
|
1467
|
+
.pipe(map(response => response)).pipe(catchError(this.handleError));
|
|
1468
|
+
}
|
|
1469
|
+
getObject(resource) {
|
|
1470
|
+
return this.http.post(this._url, resource)
|
|
1471
|
+
.pipe(map(response => response)).pipe(catchError(this.handleError));
|
|
1472
|
+
}
|
|
1473
|
+
handleError(error) {
|
|
1474
|
+
console.log('DataService.handleError.error', error);
|
|
1475
|
+
if (error.status === 404)
|
|
1476
|
+
return throwError(new NotFoundError());
|
|
1477
|
+
if (error.status === 400)
|
|
1478
|
+
return throwError(new BadRequestError());
|
|
1479
|
+
if (error.status === 401)
|
|
1480
|
+
return throwError(new InvalidUserError());
|
|
1481
|
+
return throwError(new AppError(error));
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
/** @nocollapse */ DataService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: DataService, deps: [{ token: String }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1485
|
+
/** @nocollapse */ DataService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: DataService });
|
|
1486
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: DataService, decorators: [{
|
|
1487
|
+
type: Injectable
|
|
1488
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1489
|
+
type: Inject,
|
|
1490
|
+
args: [String]
|
|
1491
1491
|
}] }, { type: i1.HttpClient }]; } });
|
|
1492
1492
|
|
|
1493
|
-
class AppErrorHandler {
|
|
1494
|
-
handleError(error) {
|
|
1495
|
-
alert('An unexpected error occured.');
|
|
1496
|
-
console.log(error);
|
|
1497
|
-
}
|
|
1493
|
+
class AppErrorHandler {
|
|
1494
|
+
handleError(error) {
|
|
1495
|
+
alert('An unexpected error occured.');
|
|
1496
|
+
console.log(error);
|
|
1497
|
+
}
|
|
1498
1498
|
}
|
|
1499
1499
|
|
|
1500
|
-
class DinoFormsModule {
|
|
1501
|
-
}
|
|
1502
|
-
/** @nocollapse */ DinoFormsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: DinoFormsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1503
|
-
/** @nocollapse */ DinoFormsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: DinoFormsModule, declarations: [FormComponent,
|
|
1504
|
-
AlertComponent,
|
|
1505
|
-
ExpressionsFormComponent,
|
|
1506
|
-
AccordionFormComponent,
|
|
1507
|
-
ModalFormComponent,
|
|
1508
|
-
TabFormComponent], imports: [CommonModule,
|
|
1509
|
-
FormsModule,
|
|
1510
|
-
ReactiveFormsModule,
|
|
1511
|
-
BrowserModule], exports: [FormComponent,
|
|
1512
|
-
AlertComponent,
|
|
1513
|
-
ExpressionsFormComponent,
|
|
1514
|
-
AccordionFormComponent,
|
|
1515
|
-
ModalFormComponent,
|
|
1516
|
-
TabFormComponent] });
|
|
1517
|
-
/** @nocollapse */ DinoFormsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: DinoFormsModule, providers: [
|
|
1518
|
-
{ provide: ErrorHandler, useClass: AppErrorHandler }
|
|
1519
|
-
], imports: [[
|
|
1520
|
-
CommonModule,
|
|
1521
|
-
FormsModule,
|
|
1522
|
-
ReactiveFormsModule,
|
|
1523
|
-
BrowserModule,
|
|
1524
|
-
]] });
|
|
1525
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: DinoFormsModule, decorators: [{
|
|
1526
|
-
type: NgModule,
|
|
1527
|
-
args: [{
|
|
1528
|
-
declarations: [
|
|
1529
|
-
FormComponent,
|
|
1530
|
-
AlertComponent,
|
|
1531
|
-
ExpressionsFormComponent,
|
|
1532
|
-
AccordionFormComponent,
|
|
1533
|
-
ModalFormComponent,
|
|
1534
|
-
TabFormComponent
|
|
1535
|
-
],
|
|
1536
|
-
imports: [
|
|
1537
|
-
CommonModule,
|
|
1538
|
-
FormsModule,
|
|
1539
|
-
ReactiveFormsModule,
|
|
1540
|
-
BrowserModule,
|
|
1541
|
-
],
|
|
1542
|
-
exports: [
|
|
1543
|
-
FormComponent,
|
|
1544
|
-
AlertComponent,
|
|
1545
|
-
ExpressionsFormComponent,
|
|
1546
|
-
AccordionFormComponent,
|
|
1547
|
-
ModalFormComponent,
|
|
1548
|
-
TabFormComponent
|
|
1549
|
-
],
|
|
1550
|
-
providers: [
|
|
1551
|
-
{ provide: ErrorHandler, useClass: AppErrorHandler }
|
|
1552
|
-
]
|
|
1553
|
-
}]
|
|
1500
|
+
class DinoFormsModule {
|
|
1501
|
+
}
|
|
1502
|
+
/** @nocollapse */ DinoFormsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: DinoFormsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1503
|
+
/** @nocollapse */ DinoFormsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: DinoFormsModule, declarations: [FormComponent,
|
|
1504
|
+
AlertComponent,
|
|
1505
|
+
ExpressionsFormComponent,
|
|
1506
|
+
AccordionFormComponent,
|
|
1507
|
+
ModalFormComponent,
|
|
1508
|
+
TabFormComponent], imports: [CommonModule,
|
|
1509
|
+
FormsModule,
|
|
1510
|
+
ReactiveFormsModule,
|
|
1511
|
+
BrowserModule], exports: [FormComponent,
|
|
1512
|
+
AlertComponent,
|
|
1513
|
+
ExpressionsFormComponent,
|
|
1514
|
+
AccordionFormComponent,
|
|
1515
|
+
ModalFormComponent,
|
|
1516
|
+
TabFormComponent] });
|
|
1517
|
+
/** @nocollapse */ DinoFormsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: DinoFormsModule, providers: [
|
|
1518
|
+
{ provide: ErrorHandler, useClass: AppErrorHandler }
|
|
1519
|
+
], imports: [[
|
|
1520
|
+
CommonModule,
|
|
1521
|
+
FormsModule,
|
|
1522
|
+
ReactiveFormsModule,
|
|
1523
|
+
BrowserModule,
|
|
1524
|
+
]] });
|
|
1525
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: DinoFormsModule, decorators: [{
|
|
1526
|
+
type: NgModule,
|
|
1527
|
+
args: [{
|
|
1528
|
+
declarations: [
|
|
1529
|
+
FormComponent,
|
|
1530
|
+
AlertComponent,
|
|
1531
|
+
ExpressionsFormComponent,
|
|
1532
|
+
AccordionFormComponent,
|
|
1533
|
+
ModalFormComponent,
|
|
1534
|
+
TabFormComponent
|
|
1535
|
+
],
|
|
1536
|
+
imports: [
|
|
1537
|
+
CommonModule,
|
|
1538
|
+
FormsModule,
|
|
1539
|
+
ReactiveFormsModule,
|
|
1540
|
+
BrowserModule,
|
|
1541
|
+
],
|
|
1542
|
+
exports: [
|
|
1543
|
+
FormComponent,
|
|
1544
|
+
AlertComponent,
|
|
1545
|
+
ExpressionsFormComponent,
|
|
1546
|
+
AccordionFormComponent,
|
|
1547
|
+
ModalFormComponent,
|
|
1548
|
+
TabFormComponent
|
|
1549
|
+
],
|
|
1550
|
+
providers: [
|
|
1551
|
+
{ provide: ErrorHandler, useClass: AppErrorHandler }
|
|
1552
|
+
]
|
|
1553
|
+
}]
|
|
1554
1554
|
}] });
|
|
1555
1555
|
|
|
1556
|
-
/*
|
|
1557
|
-
* Public API Surface of dino-forms
|
|
1556
|
+
/*
|
|
1557
|
+
* Public API Surface of dino-forms
|
|
1558
1558
|
*/
|
|
1559
1559
|
|
|
1560
|
-
/**
|
|
1561
|
-
* Generated bundle index. Do not edit.
|
|
1560
|
+
/**
|
|
1561
|
+
* Generated bundle index. Do not edit.
|
|
1562
1562
|
*/
|
|
1563
1563
|
|
|
1564
1564
|
export { AccordionFormComponent, AlertComponent, DataService, DinoFormsModule, ExpressionsFormComponent, FormComponent, ModalFormComponent, TabFormComponent };
|