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