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