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,2295 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms'), require('rxjs'), require('rxjs/operators'), require('@angular/common/http'), require('@angular/platform-browser')) :
3
- typeof define === 'function' && define.amd ? define('dino-forms', ['exports', '@angular/core', '@angular/common', '@angular/forms', 'rxjs', 'rxjs/operators', '@angular/common/http', '@angular/platform-browser'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["dino-forms"] = {}, global.ng.core, global.ng.common, global.ng.forms, global.rxjs, global.rxjs.operators, global.ng.common.http, global.ng.platformBrowser));
5
- })(this, (function (exports, i0, i2, i2$1, rxjs, operators, i1, platformBrowser) { 'use strict';
6
-
7
- function _interopNamespace(e) {
8
- if (e && e.__esModule) return e;
9
- var n = Object.create(null);
10
- if (e) {
11
- Object.keys(e).forEach(function (k) {
12
- if (k !== 'default') {
13
- var d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: function () { return e[k]; }
17
- });
18
- }
19
- });
20
- }
21
- n["default"] = e;
22
- return Object.freeze(n);
23
- }
24
-
25
- var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
26
- var i2__namespace = /*#__PURE__*/_interopNamespace(i2);
27
- var i2__namespace$1 = /*#__PURE__*/_interopNamespace(i2$1);
28
- var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
29
-
30
- /*! *****************************************************************************
31
- Copyright (c) Microsoft Corporation.
32
-
33
- Permission to use, copy, modify, and/or distribute this software for any
34
- purpose with or without fee is hereby granted.
35
-
36
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
37
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
38
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
39
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
40
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
41
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
42
- PERFORMANCE OF THIS SOFTWARE.
43
- ***************************************************************************** */
44
- /* global Reflect, Promise */
45
- var extendStatics = function (d, b) {
46
- extendStatics = Object.setPrototypeOf ||
47
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
48
- function (d, b) { for (var p in b)
49
- if (Object.prototype.hasOwnProperty.call(b, p))
50
- d[p] = b[p]; };
51
- return extendStatics(d, b);
52
- };
53
- function __extends(d, b) {
54
- if (typeof b !== "function" && b !== null)
55
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
56
- extendStatics(d, b);
57
- function __() { this.constructor = d; }
58
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
59
- }
60
- var __assign = function () {
61
- __assign = Object.assign || function __assign(t) {
62
- for (var s, i = 1, n = arguments.length; i < n; i++) {
63
- s = arguments[i];
64
- for (var p in s)
65
- if (Object.prototype.hasOwnProperty.call(s, p))
66
- t[p] = s[p];
67
- }
68
- return t;
69
- };
70
- return __assign.apply(this, arguments);
71
- };
72
- function __rest(s, e) {
73
- var t = {};
74
- for (var p in s)
75
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
76
- t[p] = s[p];
77
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
78
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
79
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
80
- t[p[i]] = s[p[i]];
81
- }
82
- return t;
83
- }
84
- function __decorate(decorators, target, key, desc) {
85
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
86
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
87
- r = Reflect.decorate(decorators, target, key, desc);
88
- else
89
- for (var i = decorators.length - 1; i >= 0; i--)
90
- if (d = decorators[i])
91
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
92
- return c > 3 && r && Object.defineProperty(target, key, r), r;
93
- }
94
- function __param(paramIndex, decorator) {
95
- return function (target, key) { decorator(target, key, paramIndex); };
96
- }
97
- function __metadata(metadataKey, metadataValue) {
98
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
99
- return Reflect.metadata(metadataKey, metadataValue);
100
- }
101
- function __awaiter(thisArg, _arguments, P, generator) {
102
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
103
- return new (P || (P = Promise))(function (resolve, reject) {
104
- function fulfilled(value) { try {
105
- step(generator.next(value));
106
- }
107
- catch (e) {
108
- reject(e);
109
- } }
110
- function rejected(value) { try {
111
- step(generator["throw"](value));
112
- }
113
- catch (e) {
114
- reject(e);
115
- } }
116
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
117
- step((generator = generator.apply(thisArg, _arguments || [])).next());
118
- });
119
- }
120
- function __generator(thisArg, body) {
121
- var _ = { label: 0, sent: function () { if (t[0] & 1)
122
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
123
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
124
- function verb(n) { return function (v) { return step([n, v]); }; }
125
- function step(op) {
126
- if (f)
127
- throw new TypeError("Generator is already executing.");
128
- while (_)
129
- try {
130
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
131
- return t;
132
- if (y = 0, t)
133
- op = [op[0] & 2, t.value];
134
- switch (op[0]) {
135
- case 0:
136
- case 1:
137
- t = op;
138
- break;
139
- case 4:
140
- _.label++;
141
- return { value: op[1], done: false };
142
- case 5:
143
- _.label++;
144
- y = op[1];
145
- op = [0];
146
- continue;
147
- case 7:
148
- op = _.ops.pop();
149
- _.trys.pop();
150
- continue;
151
- default:
152
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
153
- _ = 0;
154
- continue;
155
- }
156
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
157
- _.label = op[1];
158
- break;
159
- }
160
- if (op[0] === 6 && _.label < t[1]) {
161
- _.label = t[1];
162
- t = op;
163
- break;
164
- }
165
- if (t && _.label < t[2]) {
166
- _.label = t[2];
167
- _.ops.push(op);
168
- break;
169
- }
170
- if (t[2])
171
- _.ops.pop();
172
- _.trys.pop();
173
- continue;
174
- }
175
- op = body.call(thisArg, _);
176
- }
177
- catch (e) {
178
- op = [6, e];
179
- y = 0;
180
- }
181
- finally {
182
- f = t = 0;
183
- }
184
- if (op[0] & 5)
185
- throw op[1];
186
- return { value: op[0] ? op[1] : void 0, done: true };
187
- }
188
- }
189
- var __createBinding = Object.create ? (function (o, m, k, k2) {
190
- if (k2 === undefined)
191
- k2 = k;
192
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
193
- }) : (function (o, m, k, k2) {
194
- if (k2 === undefined)
195
- k2 = k;
196
- o[k2] = m[k];
197
- });
198
- function __exportStar(m, o) {
199
- for (var p in m)
200
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
201
- __createBinding(o, m, p);
202
- }
203
- function __values(o) {
204
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
205
- if (m)
206
- return m.call(o);
207
- if (o && typeof o.length === "number")
208
- return {
209
- next: function () {
210
- if (o && i >= o.length)
211
- o = void 0;
212
- return { value: o && o[i++], done: !o };
213
- }
214
- };
215
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
216
- }
217
- function __read(o, n) {
218
- var m = typeof Symbol === "function" && o[Symbol.iterator];
219
- if (!m)
220
- return o;
221
- var i = m.call(o), r, ar = [], e;
222
- try {
223
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
224
- ar.push(r.value);
225
- }
226
- catch (error) {
227
- e = { error: error };
228
- }
229
- finally {
230
- try {
231
- if (r && !r.done && (m = i["return"]))
232
- m.call(i);
233
- }
234
- finally {
235
- if (e)
236
- throw e.error;
237
- }
238
- }
239
- return ar;
240
- }
241
- /** @deprecated */
242
- function __spread() {
243
- for (var ar = [], i = 0; i < arguments.length; i++)
244
- ar = ar.concat(__read(arguments[i]));
245
- return ar;
246
- }
247
- /** @deprecated */
248
- function __spreadArrays() {
249
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
250
- s += arguments[i].length;
251
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
252
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
253
- r[k] = a[j];
254
- return r;
255
- }
256
- function __spreadArray(to, from, pack) {
257
- if (pack || arguments.length === 2)
258
- for (var i = 0, l = from.length, ar; i < l; i++) {
259
- if (ar || !(i in from)) {
260
- if (!ar)
261
- ar = Array.prototype.slice.call(from, 0, i);
262
- ar[i] = from[i];
263
- }
264
- }
265
- return to.concat(ar || Array.prototype.slice.call(from));
266
- }
267
- function __await(v) {
268
- return this instanceof __await ? (this.v = v, this) : new __await(v);
269
- }
270
- function __asyncGenerator(thisArg, _arguments, generator) {
271
- if (!Symbol.asyncIterator)
272
- throw new TypeError("Symbol.asyncIterator is not defined.");
273
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
274
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
275
- function verb(n) { if (g[n])
276
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
277
- function resume(n, v) { try {
278
- step(g[n](v));
279
- }
280
- catch (e) {
281
- settle(q[0][3], e);
282
- } }
283
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
284
- function fulfill(value) { resume("next", value); }
285
- function reject(value) { resume("throw", value); }
286
- function settle(f, v) { if (f(v), q.shift(), q.length)
287
- resume(q[0][0], q[0][1]); }
288
- }
289
- function __asyncDelegator(o) {
290
- var i, p;
291
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
292
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
293
- }
294
- function __asyncValues(o) {
295
- if (!Symbol.asyncIterator)
296
- throw new TypeError("Symbol.asyncIterator is not defined.");
297
- var m = o[Symbol.asyncIterator], i;
298
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
299
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
300
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
301
- }
302
- function __makeTemplateObject(cooked, raw) {
303
- if (Object.defineProperty) {
304
- Object.defineProperty(cooked, "raw", { value: raw });
305
- }
306
- else {
307
- cooked.raw = raw;
308
- }
309
- return cooked;
310
- }
311
- ;
312
- var __setModuleDefault = Object.create ? (function (o, v) {
313
- Object.defineProperty(o, "default", { enumerable: true, value: v });
314
- }) : function (o, v) {
315
- o["default"] = v;
316
- };
317
- function __importStar(mod) {
318
- if (mod && mod.__esModule)
319
- return mod;
320
- var result = {};
321
- if (mod != null)
322
- for (var k in mod)
323
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
324
- __createBinding(result, mod, k);
325
- __setModuleDefault(result, mod);
326
- return result;
327
- }
328
- function __importDefault(mod) {
329
- return (mod && mod.__esModule) ? mod : { default: mod };
330
- }
331
- function __classPrivateFieldGet(receiver, state, kind, f) {
332
- if (kind === "a" && !f)
333
- throw new TypeError("Private accessor was defined without a getter");
334
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
335
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
336
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
337
- }
338
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
339
- if (kind === "m")
340
- throw new TypeError("Private method is not writable");
341
- if (kind === "a" && !f)
342
- throw new TypeError("Private accessor was defined without a setter");
343
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
344
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
345
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
346
- }
347
-
348
- var ObjectUtility = /** @class */ (function () {
349
- function ObjectUtility() {
350
- }
351
- ObjectUtility.isEmpty = function (value) {
352
- var e_1, _a;
353
- if (value == {} || value == undefined || value == null || value == "" || value == [])
354
- return true;
355
- if (this.isArray(value)) {
356
- try {
357
- for (var value_1 = __values(value), value_1_1 = value_1.next(); !value_1_1.done; value_1_1 = value_1.next()) {
358
- var element = value_1_1.value;
359
- if (!this.isEmpty(element))
360
- return false;
361
- }
362
- }
363
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
364
- finally {
365
- try {
366
- if (value_1_1 && !value_1_1.done && (_a = value_1.return)) _a.call(value_1);
367
- }
368
- finally { if (e_1) throw e_1.error; }
369
- }
370
- return true;
371
- }
372
- return false;
373
- };
374
- ObjectUtility.isArray = function (value) {
375
- return Array.isArray(value);
376
- };
377
- ObjectUtility.includes = function (array, value) {
378
- if (this.isEmpty(array))
379
- return false;
380
- return array.includes(value);
381
- };
382
- return ObjectUtility;
383
- }());
384
-
385
- var AlertComponent = /** @class */ (function () {
386
- function AlertComponent() {
387
- }
388
- AlertComponent.prototype.ngOnInit = function () {
389
- };
390
- AlertComponent.prototype.isEmpty = function (value) {
391
- return ObjectUtility.isEmpty(value);
392
- };
393
- return AlertComponent;
394
- }());
395
- /** @nocollapse */ AlertComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: AlertComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
396
- /** @nocollapse */ AlertComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: AlertComponent, selector: "df-alert", inputs: { form: "form", input: "input" }, ngImport: i0__namespace, 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__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
397
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: AlertComponent, decorators: [{
398
- type: i0.Component,
399
- args: [{
400
- selector: 'df-alert',
401
- templateUrl: './alert.component.html',
402
- styleUrls: ['./alert.component.scss']
403
- }]
404
- }], ctorParameters: function () { return []; }, propDecorators: { form: [{
405
- type: i0.Input
406
- }], input: [{
407
- type: i0.Input
408
- }] } });
409
-
410
- var Constants = /** @class */ (function () {
411
- function Constants() {
412
- }
413
- return Constants;
414
- }());
415
- Constants.EMPTY_SPACE = "";
416
- Constants.BLANK_SPACE = " ";
417
- Constants.VERTICAL_BAR = "|";
418
- Constants.BACK_SLASH = "/";
419
- Constants.LEFT_PARENTHESIS = "(";
420
- Constants.RIGHT_PARENTHESIS = ")";
421
- Constants.LEFT_CURLY_BRACE = "{";
422
- Constants.RIGHT_CURLY_BRACE = "}";
423
- Constants.CONTROL_PREFIX = "control::";
424
- Constants.MAX_LEVELS = 30;
425
- Constants.ALERT_TIMEOUT = 3000;
426
- Constants.START_LEVEL = "Level[";
427
- Constants.END_LEVEL = "]: ";
428
- Constants.VALIDATOR_SPLITTER = "::";
429
- Constants.AMPERSAND = "&";
430
- Constants.EQUAL = "=";
431
- Constants.QUESTION_MARK = "?";
432
- Constants.DFLEX = "d-flex";
433
- Constants.JUSTIFY_CONTENT = "justify-content-";
434
- Constants.END = "end";
435
- Constants.START = "start";
436
- Constants.CENTER = "center";
437
- Constants.MS4 = "ms-4";
438
- Constants.ME4 = "me-4";
439
- Constants.M4 = "m-4";
440
-
441
- var GenericInputType = /** @class */ (function () {
442
- function GenericInputType() {
443
- }
444
- return GenericInputType;
445
- }());
446
- GenericInputType.TEXT = "text";
447
- GenericInputType.NUMBER = "number";
448
- GenericInputType.DATE = "date";
449
- GenericInputType.PASSWORD = "password";
450
- GenericInputType.TEXTAREA = "textarea";
451
- GenericInputType.RADIO = "radio";
452
- GenericInputType.CHECKBOX = "checkbox";
453
- GenericInputType.COMBOBOX = "combobox";
454
- GenericInputType.BUTTON = "button";
455
- GenericInputType.SUBMIT = "submit";
456
- GenericInputType.RESET = "reset";
457
-
458
- var Validation = /** @class */ (function () {
459
- function Validation() {
460
- }
461
- return Validation;
462
- }());
463
- Validation.REQUIRED = "required";
464
- Validation.MINLENGTH = "minlength";
465
- Validation.MAXLENGTH = "maxlength";
466
- Validation.MIN = "min";
467
- Validation.MAX = "max";
468
- Validation.EMAIL = "email";
469
- Validation.PATTERN = "pattern";
470
-
471
- var FormValidators = /** @class */ (function () {
472
- function FormValidators() {
473
- }
474
- FormValidators.getValidators = function (validators) {
475
- var e_1, _a;
476
- var validatorObjects = null;
477
- if (!ObjectUtility.isEmpty(validators)) {
478
- validatorObjects = [];
479
- try {
480
- for (var validators_1 = __values(validators), validators_1_1 = validators_1.next(); !validators_1_1.done; validators_1_1 = validators_1.next()) {
481
- var validator = validators_1_1.value;
482
- var validatorObject = void 0;
483
- if (validator.indexOf(Constants.VALIDATOR_SPLITTER) > -1)
484
- validatorObject = this.getValidator(validator.split(Constants.VALIDATOR_SPLITTER)[0]);
485
- else
486
- validatorObject = this.getValidator(validator);
487
- if (!ObjectUtility.isEmpty(validatorObject))
488
- validatorObjects.push(validatorObject);
489
- }
490
- }
491
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
492
- finally {
493
- try {
494
- if (validators_1_1 && !validators_1_1.done && (_a = validators_1.return)) _a.call(validators_1);
495
- }
496
- finally { if (e_1) throw e_1.error; }
497
- }
498
- }
499
- return validatorObjects;
500
- };
501
- FormValidators.getValidator = function (validator) {
502
- if (validator === Validation.REQUIRED) {
503
- return i2$1.Validators.required;
504
- }
505
- else if (validator.indexOf(Validation.MINLENGTH) !== -1) {
506
- var values = validator.split(Constants.VERTICAL_BAR);
507
- return i2$1.Validators.minLength(Number(values[1]));
508
- }
509
- else if (validator.indexOf(Validation.MAXLENGTH) !== -1) {
510
- var values = validator.split(Constants.VERTICAL_BAR);
511
- return i2$1.Validators.maxLength(Number(values[1]));
512
- }
513
- else if (validator.indexOf(Validation.MIN) !== -1) {
514
- var values = validator.split(Constants.VERTICAL_BAR);
515
- return i2$1.Validators.min(Number(values[1]));
516
- }
517
- else if (validator.indexOf(Validation.MAX) !== -1) {
518
- var values = validator.split(Constants.VERTICAL_BAR);
519
- return i2$1.Validators.max(Number(values[1]));
520
- }
521
- else if (validator.indexOf(Validation.EMAIL) !== -1) {
522
- return i2$1.Validators.email;
523
- }
524
- else if (validator.indexOf(Validation.PATTERN) !== -1) {
525
- var values = validator.split(Constants.VERTICAL_BAR);
526
- return i2$1.Validators.pattern(values[1]);
527
- }
528
- };
529
- return FormValidators;
530
- }());
531
-
532
- var CustomValidator = /** @class */ (function () {
533
- function CustomValidator() {
534
- }
535
- CustomValidator.multipleCheckboxRequireOne = function (fa) {
536
- var valid = false;
537
- for (var x = 0; x < fa.length; ++x) {
538
- if (fa.at(x).value) {
539
- valid = true;
540
- break;
541
- }
542
- }
543
- return valid ? null : {
544
- multipleCheckboxRequireOne: true
545
- };
546
- };
547
- return CustomValidator;
548
- }());
549
-
550
- var FormsUtility = /** @class */ (function () {
551
- function FormsUtility() {
552
- }
553
- FormsUtility.updateCheckboxValue = function (form, formArrayName, controlName, checked, value) {
554
- var formArr = form.controls[formArrayName];
555
- if (!checked) {
556
- formArr.controls[controlName].setValue(null);
557
- }
558
- else {
559
- formArr.controls[controlName].setValue(value);
560
- }
561
- };
562
- FormsUtility.updateRadioValue = function (form, controlName, checked, optionId) {
563
- var control = form.controls[controlName];
564
- if (!checked) {
565
- control.setValue(Constants.EMPTY_SPACE);
566
- }
567
- else {
568
- control.setValue(optionId);
569
- }
570
- };
571
- FormsUtility.isCheckBoxChecked = function (form, controlName, optionId) {
572
- var checked = null;
573
- var formArr = form.controls[controlName];
574
- var formControl = formArr.controls[optionId];
575
- if (!ObjectUtility.isEmpty(formControl))
576
- checked = formControl.value;
577
- if (!ObjectUtility.isEmpty(checked))
578
- return checked;
579
- else
580
- return null;
581
- };
582
- FormsUtility.isRadioChecked = function (form, controlName, optionId) {
583
- var checked = null;
584
- var formControl = form.controls[controlName];
585
- if (!ObjectUtility.isEmpty(formControl))
586
- checked = formControl.value;
587
- if (!ObjectUtility.isEmpty(checked) && checked == optionId)
588
- return true;
589
- else
590
- return false;
591
- };
592
- FormsUtility.buildFromGroup = function (fields, disabled) {
593
- var e_1, _a, e_2, _b;
594
- var form = new i2$1.FormGroup({});
595
- if (!ObjectUtility.isEmpty(fields))
596
- try {
597
- for (var _c = __values(Array.from(fields)), _d = _c.next(); !_d.done; _d = _c.next()) {
598
- var group = _d.value;
599
- try {
600
- //console.log("group>",group);
601
- for (var _e = (e_2 = void 0, __values(group === null || group === void 0 ? void 0 : group.groupFields)), _f = _e.next(); !_f.done; _f = _e.next()) {
602
- var input = _f.value;
603
- if (input.id !== undefined) {
604
- if (input.type !== undefined && input.type === GenericInputType.CHECKBOX) {
605
- form.addControl(input.id, this.getCheckBoxFormArray(input));
606
- if (!ObjectUtility.isEmpty(input.value)) {
607
- form.controls[input.id].reset(input.value);
608
- form.controls[input.id].updateValueAndValidity();
609
- }
610
- if (input.disabled || disabled) {
611
- form.controls[input.id].disable();
612
- }
613
- }
614
- if (input.type !== undefined && (input.type === GenericInputType.RADIO ||
615
- input.type === GenericInputType.DATE ||
616
- input.type === GenericInputType.COMBOBOX)) {
617
- form.addControl(input.id, new i2$1.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));
618
- if (input.disabled || disabled) {
619
- form.controls[input.id].disable();
620
- }
621
- }
622
- else {
623
- form.addControl(input.id, new i2$1.FormControl((!ObjectUtility.isEmpty(input.value)) ? input.value : Constants.EMPTY_SPACE, (!input.hidden) ? FormValidators.getValidators(input.validators) : null));
624
- if (input.disabled || disabled) {
625
- form.controls[input.id].disable();
626
- }
627
- }
628
- }
629
- }
630
- }
631
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
632
- finally {
633
- try {
634
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
635
- }
636
- finally { if (e_2) throw e_2.error; }
637
- }
638
- }
639
- }
640
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
641
- finally {
642
- try {
643
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
644
- }
645
- finally { if (e_1) throw e_1.error; }
646
- }
647
- return form;
648
- };
649
- FormsUtility.getCheckBoxFormArray = function (input) {
650
- var fb = new i2$1.FormBuilder();
651
- return fb.array(input.options.map(function () { return fb.control(null, null); }), (!input.hidden) ? this.getCheckBoxValidator(input) : null);
652
- };
653
- FormsUtility.getCheckBoxValidator = function (input) {
654
- if (!input.hidden && (input.required || ObjectUtility.includes(input.validators, Validation.REQUIRED))) {
655
- return CustomValidator.multipleCheckboxRequireOne;
656
- }
657
- return null;
658
- };
659
- FormsUtility.includeRequired = function (validators) {
660
- var e_3, _a;
661
- if (!ObjectUtility.isEmpty(validators)) {
662
- try {
663
- for (var _b = __values(Array.from(validators)), _c = _b.next(); !_c.done; _c = _b.next()) {
664
- var validator = _c.value;
665
- if (validator === Validation.REQUIRED) {
666
- return true;
667
- }
668
- }
669
- }
670
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
671
- finally {
672
- try {
673
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
674
- }
675
- finally { if (e_3) throw e_3.error; }
676
- }
677
- }
678
- return false;
679
- };
680
- FormsUtility.resetForm = function (fields, form) {
681
- var e_4, _a, e_5, _b;
682
- if (!ObjectUtility.isEmpty(fields))
683
- try {
684
- for (var _c = __values(Array.from(fields)), _d = _c.next(); !_d.done; _d = _c.next()) {
685
- var group = _d.value;
686
- try {
687
- for (var _e = (e_5 = void 0, __values(group === null || group === void 0 ? void 0 : group.groupFields)), _f = _e.next(); !_f.done; _f = _e.next()) {
688
- var input = _f.value;
689
- if (!ObjectUtility.isEmpty(input.id)
690
- && !input.readonly
691
- && !input.disabled
692
- && !ObjectUtility.isEmpty(form.controls)
693
- && !ObjectUtility.isEmpty(form.controls[input.id])) {
694
- var control = form.controls[input.id];
695
- control.reset();
696
- }
697
- }
698
- }
699
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
700
- finally {
701
- try {
702
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
703
- }
704
- finally { if (e_5) throw e_5.error; }
705
- }
706
- }
707
- }
708
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
709
- finally {
710
- try {
711
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
712
- }
713
- finally { if (e_4) throw e_4.error; }
714
- }
715
- return form;
716
- };
717
- FormsUtility.setValidators = function (input, form, result) {
718
- if (!ObjectUtility.isEmpty(form.controls[input.id])) {
719
- if (result) {
720
- if (input.type === GenericInputType.CHECKBOX) {
721
- form.controls[input.id].setValidators(this.getCheckBoxValidator(input));
722
- }
723
- else if (input.type !== undefined && (input.type === GenericInputType.RADIO ||
724
- input.type === GenericInputType.DATE ||
725
- input.type === GenericInputType.COMBOBOX)) {
726
- form.controls[input.id].setValidators((!input.hidden && (input.required || ObjectUtility.includes(input.validators, Validation.REQUIRED))) ?
727
- FormValidators.getValidators([Validation.REQUIRED]) : null);
728
- }
729
- else {
730
- form.controls[input.id].setValidators((!input.hidden) ? FormValidators.getValidators(input.validators) : null);
731
- }
732
- }
733
- else {
734
- form.controls[input.id].setValidators(null);
735
- }
736
- form.controls[input.id].updateValueAndValidity();
737
- }
738
- };
739
- FormsUtility.getMargin = function (justify) {
740
- if ((justify === null || justify === void 0 ? void 0 : justify.toLocaleLowerCase()) === Constants.END)
741
- return Constants.MS4;
742
- if ((justify === null || justify === void 0 ? void 0 : justify.toLocaleLowerCase()) === Constants.START)
743
- return Constants.ME4;
744
- if ((justify === null || justify === void 0 ? void 0 : justify.toLocaleLowerCase()) === Constants.CENTER)
745
- return Constants.M4;
746
- };
747
- return FormsUtility;
748
- }());
749
-
750
- var FormComponent = /** @class */ (function () {
751
- function FormComponent() {
752
- this.form = new i2$1.FormGroup({});
753
- this.fileList = null;
754
- this.fileName = "";
755
- this.buttonsJustify = "end";
756
- this.onSubmit = new i0.EventEmitter();
757
- this.alert_timeout = Constants.ALERT_TIMEOUT;
758
- this.danger = { active: false, label: '' };
759
- this.warning = { active: false, label: '' };
760
- this.success = { active: false, label: '' };
761
- this.info = { active: false, label: '' };
762
- this.primary = { active: false, label: '' };
763
- this.secondary = { active: false, label: '' };
764
- }
765
- FormComponent.prototype.onClick = function (action) {
766
- var data = {
767
- action: action,
768
- formValues: this.form.value
769
- };
770
- this.onSubmit.emit(data);
771
- };
772
- FormComponent.prototype.onEnter = function () {
773
- this.onSubmit.emit(this.form.value);
774
- };
775
- FormComponent.prototype.ngOnInit = function () {
776
- this.buildFormGroup(this.formFields);
777
- this.buttonMargin = FormsUtility.getMargin(this.buttonsJustify);
778
- this.buttonsJustify = Constants.DFLEX + Constants.BLANK_SPACE + Constants.JUSTIFY_CONTENT + this.buttonsJustify;
779
- //console.log("form>",this.form);
780
- };
781
- FormComponent.prototype.buildFormGroup = function (fields) {
782
- this.form = FormsUtility.buildFromGroup(fields, this.disabled);
783
- };
784
- FormComponent.prototype.getForm = function () {
785
- return this.form;
786
- };
787
- FormComponent.prototype.getFormControls = function () {
788
- if (!ObjectUtility.isEmpty(this.form)) {
789
- return this.form.controls;
790
- }
791
- };
792
- FormComponent.prototype.getFormControl = function (controlName) {
793
- if (!ObjectUtility.isEmpty(this.form)
794
- && !ObjectUtility.isEmpty(this.form.controls)) {
795
- return this.form.controls[controlName];
796
- }
797
- };
798
- FormComponent.prototype.setFormControlValue = function (controlName, value) {
799
- if (!ObjectUtility.isEmpty(this.form)
800
- && !ObjectUtility.isEmpty(this.form.controls)
801
- && !ObjectUtility.isEmpty(this.form.controls)
802
- && !ObjectUtility.isEmpty(this.form.controls[controlName])) {
803
- this.form.controls[controlName].reset(value);
804
- this.form.controls[controlName].updateValueAndValidity();
805
- }
806
- };
807
- FormComponent.prototype.includeRequired = function (validators) {
808
- return FormsUtility.includeRequired(validators);
809
- };
810
- FormComponent.prototype.fileChange = function (event) {
811
- this.fileList = event.target.files;
812
- //console.log("fileList>",this.fileList);
813
- if (!ObjectUtility.isEmpty(this.fileList) && event.target.files.length > 0)
814
- this.fileName = this.fileList[0].name;
815
- else
816
- this.fileName = "";
817
- };
818
- FormComponent.prototype.onUploadClick = function (id) {
819
- var data = {
820
- action: 'uploadFile',
821
- fileList: this.fileList,
822
- fieldId: id
823
- };
824
- this.onSubmit.emit(data);
825
- };
826
- FormComponent.prototype.updateCheckboxValue = function (formArray, controlName, checked, value) {
827
- FormsUtility.updateCheckboxValue(this.form, formArray, controlName, checked, value);
828
- };
829
- FormComponent.prototype.updateRadioValue = function (inputId, checked, optionId) {
830
- FormsUtility.updateRadioValue(this.form, inputId, checked, optionId);
831
- };
832
- FormComponent.prototype.isCheckBoxChecked = function (controlName, optionId) {
833
- return FormsUtility.isCheckBoxChecked(this.form, controlName, optionId);
834
- };
835
- FormComponent.prototype.isRadioChecked = function (controlName, optionId) {
836
- return FormsUtility.isRadioChecked(this.form, controlName, optionId);
837
- };
838
- FormComponent.prototype.resetForm = function () {
839
- this.form = FormsUtility.resetForm(this.formFields, this.form);
840
- };
841
- FormComponent.prototype.isEmpty = function (value) {
842
- return ObjectUtility.isEmpty(value);
843
- };
844
- FormComponent.prototype.getDisabled = function () {
845
- return this.disabled;
846
- };
847
- FormComponent.prototype.setDisabled = function (disabled) {
848
- this.disabled = disabled;
849
- this.form = FormsUtility.buildFromGroup(this.formFields, this.disabled);
850
- };
851
- FormComponent.prototype.setDanger = function (label) {
852
- var _this = this;
853
- this.danger.active = true;
854
- this.danger.label = label;
855
- setTimeout(function () {
856
- _this.danger.active = false;
857
- }, this.alert_timeout);
858
- };
859
- FormComponent.prototype.setWarning = function (label) {
860
- var _this = this;
861
- this.warning.active = true;
862
- this.warning.label = label;
863
- setTimeout(function () {
864
- _this.warning.active = false;
865
- }, this.alert_timeout);
866
- };
867
- FormComponent.prototype.setSuccess = function (label) {
868
- var _this = this;
869
- this.success.active = true;
870
- this.success.label = label;
871
- setTimeout(function () {
872
- _this.success.active = false;
873
- }, this.alert_timeout);
874
- };
875
- FormComponent.prototype.setInfo = function (label) {
876
- var _this = this;
877
- this.info.active = true;
878
- this.info.label = label;
879
- setTimeout(function () {
880
- _this.info.active = false;
881
- }, this.alert_timeout);
882
- };
883
- FormComponent.prototype.setPrimary = function (label) {
884
- var _this = this;
885
- this.primary.active = true;
886
- this.primary.label = label;
887
- setTimeout(function () {
888
- _this.primary.active = false;
889
- }, this.alert_timeout);
890
- };
891
- FormComponent.prototype.setSecondary = function (label) {
892
- var _this = this;
893
- this.secondary.active = true;
894
- this.secondary.label = label;
895
- setTimeout(function () {
896
- _this.secondary.active = false;
897
- }, this.alert_timeout);
898
- };
899
- FormComponent.prototype.setAlertTimeout = function (timeout) {
900
- this.alert_timeout = timeout;
901
- };
902
- FormComponent.prototype.getIconClass = function (input) {
903
- return input.icon;
904
- };
905
- return FormComponent;
906
- }());
907
- /** @nocollapse */ FormComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: FormComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
908
- /** @nocollapse */ FormComponent.ɵcmp = i0__namespace.ɵɵ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__namespace, 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__namespace$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i2__namespace$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i2__namespace$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i2__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2__namespace.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i2__namespace.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i2__namespace$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__namespace$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i2__namespace$1.FormControlName, selector: "[formControlName]", inputs: ["disabled", "formControlName", "ngModel"], outputs: ["ngModelChange"] }, { type: i2__namespace$1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { type: i2__namespace$1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i2__namespace$1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i2__namespace$1.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }] });
909
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: FormComponent, decorators: [{
910
- type: i0.Component,
911
- args: [{
912
- selector: 'df-form',
913
- templateUrl: './form.component.html',
914
- styleUrls: ['./form.component.scss']
915
- }]
916
- }], ctorParameters: function () { return []; }, propDecorators: { formFields: [{
917
- type: i0.Input
918
- }], disabled: [{
919
- type: i0.Input
920
- }], buttons: [{
921
- type: i0.Input
922
- }], buttonsJustify: [{
923
- type: i0.Input
924
- }], onSubmit: [{
925
- type: i0.Output
926
- }] } });
927
-
928
- var ComparisonOperators = /** @class */ (function () {
929
- function ComparisonOperators() {
930
- }
931
- return ComparisonOperators;
932
- }());
933
- ComparisonOperators.EQUAL = '==';
934
- ComparisonOperators.NOT_EQUAL = '!=';
935
- ComparisonOperators.GREATER_THAN = '>';
936
- ComparisonOperators.GREATER_THAN_OR_EQUAL = '>=';
937
- ComparisonOperators.LESS_THAN = '<';
938
- ComparisonOperators.LESS_THAN_OR_EQUAL = '<=';
939
- ComparisonOperators.CONTAINS = ':contains:';
940
-
941
- var LogicalOperators = /** @class */ (function () {
942
- function LogicalOperators() {
943
- }
944
- return LogicalOperators;
945
- }());
946
- LogicalOperators.AND = '&&';
947
- LogicalOperators.OR = '||';
948
-
949
- var ExpressionsUtility = /** @class */ (function () {
950
- function ExpressionsUtility() {
951
- }
952
- ExpressionsUtility.getExpressionLogs = function () {
953
- return ExpressionsUtility.logs;
954
- };
955
- ExpressionsUtility.setLoggingFlag = function (flag) {
956
- ExpressionsUtility.expressionLoggingFlag = flag;
957
- };
958
- ExpressionsUtility.evaluateExpression = function (expression, form, level) {
959
- if (level <= 1)
960
- ExpressionsUtility.logs = Constants.EMPTY_SPACE;
961
- if (level > Constants.MAX_LEVELS)
962
- return false;
963
- if (this.expressionLoggingFlag)
964
- ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "Evaluating Expression> " + expression + " \n";
965
- if (!ObjectUtility.isEmpty(expression)) {
966
- if (expression.startsWith(Constants.LEFT_PARENTHESIS)
967
- && expression.endsWith(Constants.RIGHT_PARENTHESIS)) {
968
- expression = expression.substring(1, expression.length - 1);
969
- if (this.expressionLoggingFlag)
970
- ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "remove outer ( ) \n";
971
- return this.evaluateExpression(expression, form, level + 1);
972
- }
973
- else if (expression.startsWith(Constants.LEFT_CURLY_BRACE) && expression.endsWith(Constants.RIGHT_CURLY_BRACE)) {
974
- if (this.expressionLoggingFlag)
975
- ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "expression starts with { ends with } \n";
976
- if (expression.indexOf(Constants.LEFT_PARENTHESIS) > -1 && expression.indexOf(Constants.RIGHT_PARENTHESIS) > -1) {
977
- if (this.expressionLoggingFlag)
978
- ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "contains subexpressions \n";
979
- return this.traverseSubExpressions(expression, form, level);
980
- }
981
- else {
982
- if (this.expressionLoggingFlag)
983
- ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "does not contains subexpressions \n";
984
- if (expression.indexOf(LogicalOperators.AND) > -1 || expression.indexOf(LogicalOperators.OR) > -1) {
985
- if (this.expressionLoggingFlag)
986
- ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "contains && or || \n";
987
- var spliter = this.getSpliter(expression);
988
- var expressions = expression.split(spliter);
989
- if (this.expressionLoggingFlag)
990
- ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "Split expressions into> " + expressions + "\n";
991
- return this.validateArrayOfExpressions(expressions, spliter, form, level);
992
- }
993
- else {
994
- if (this.expressionLoggingFlag)
995
- ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "this is a clean expression. \n";
996
- return this.evaluateCleanExpression(expression, form, level);
997
- }
998
- }
999
- }
1000
- else if ((expression.startsWith(Constants.LEFT_PARENTHESIS) && !expression.endsWith(Constants.RIGHT_PARENTHESIS)) ||
1001
- (!expression.startsWith(Constants.LEFT_PARENTHESIS) && expression.endsWith(Constants.RIGHT_PARENTHESIS))) {
1002
- if (expression.startsWith(Constants.LEFT_PARENTHESIS) && !expression.endsWith(Constants.RIGHT_PARENTHESIS))
1003
- if (this.expressionLoggingFlag)
1004
- ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "expression starts with ( ends with } \n";
1005
- if (!expression.startsWith(Constants.LEFT_PARENTHESIS) && expression.endsWith(Constants.RIGHT_PARENTHESIS))
1006
- if (this.expressionLoggingFlag)
1007
- ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "expression starts with { ends with ) \n";
1008
- return this.traverseSubExpressions(expression, form, level);
1009
- }
1010
- else
1011
- return false;
1012
- }
1013
- else
1014
- return true;
1015
- };
1016
- ExpressionsUtility.traverseSubExpressions = function (expression, form, level) {
1017
- if (this.expressionLoggingFlag)
1018
- ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "Traverse expression> " + expression + "\n";
1019
- var operator = Constants.EMPTY_SPACE;
1020
- var lastOperator = Constants.EMPTY_SPACE;
1021
- var index = 0;
1022
- do {
1023
- operator = Constants.EMPTY_SPACE;
1024
- var subexpression = this.extractSubexpression(expression, level);
1025
- var result = this.evaluateExpression(subexpression, form, level + 1);
1026
- operator = expression.substring(subexpression.length, subexpression.length + 2);
1027
- if (this.expressionLoggingFlag)
1028
- ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "subExpression> " + subexpression + " >result> " + result + " >for operator> " + operator + "\n";
1029
- if (!result && (operator == LogicalOperators.AND || lastOperator == LogicalOperators.AND))
1030
- return false;
1031
- if (result && (operator == LogicalOperators.OR || lastOperator == LogicalOperators.OR))
1032
- return true;
1033
- expression = expression.substring(subexpression.length + 2, expression.length);
1034
- if (operator !== Constants.EMPTY_SPACE)
1035
- lastOperator = operator;
1036
- if (!ObjectUtility.isEmpty(expression)) {
1037
- if (this.expressionLoggingFlag)
1038
- ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "Rest of the expression> " + expression + " > lastOperator> " + lastOperator + "\n";
1039
- }
1040
- else {
1041
- if (this.expressionLoggingFlag)
1042
- ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "Rest of the expression is empty.\n";
1043
- }
1044
- } while (operator == LogicalOperators.AND || operator == LogicalOperators.OR);
1045
- if (lastOperator == LogicalOperators.AND)
1046
- return true;
1047
- if (lastOperator == LogicalOperators.OR)
1048
- return false;
1049
- };
1050
- ExpressionsUtility.extractSubexpression = function (expression, level) {
1051
- var ending;
1052
- var opening = 0;
1053
- if (expression.startsWith(Constants.LEFT_CURLY_BRACE))
1054
- ending = expression.indexOf(Constants.RIGHT_CURLY_BRACE);
1055
- else {
1056
- var index = 1;
1057
- var opening_1 = 1;
1058
- while (opening_1 > 0) {
1059
- var myChar = expression.charAt(index);
1060
- if (myChar == Constants.LEFT_PARENTHESIS) {
1061
- opening_1++;
1062
- }
1063
- if (myChar == Constants.RIGHT_PARENTHESIS) {
1064
- opening_1--;
1065
- }
1066
- if (index > (expression.length - 1)) {
1067
- break;
1068
- }
1069
- index++;
1070
- }
1071
- ending = index - 1;
1072
- }
1073
- return expression.substring(0, ending + 1);
1074
- };
1075
- ExpressionsUtility.getSpliter = function (expression) {
1076
- if (expression.indexOf(LogicalOperators.AND) > -1)
1077
- return LogicalOperators.AND;
1078
- else
1079
- return LogicalOperators.OR;
1080
- };
1081
- ExpressionsUtility.validateArrayOfExpressions = function (expressions, spliter, form, level) {
1082
- var e_1, _a;
1083
- try {
1084
- for (var expressions_1 = __values(expressions), expressions_1_1 = expressions_1.next(); !expressions_1_1.done; expressions_1_1 = expressions_1.next()) {
1085
- var expression = expressions_1_1.value;
1086
- var result = this.evaluateCleanExpression(expression, form, level);
1087
- if (spliter == LogicalOperators.AND && !result)
1088
- return false;
1089
- else if (spliter == LogicalOperators.OR && result)
1090
- return true;
1091
- }
1092
- }
1093
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1094
- finally {
1095
- try {
1096
- if (expressions_1_1 && !expressions_1_1.done && (_a = expressions_1.return)) _a.call(expressions_1);
1097
- }
1098
- finally { if (e_1) throw e_1.error; }
1099
- }
1100
- return (spliter == LogicalOperators.AND) ? true : false;
1101
- };
1102
- ExpressionsUtility.evaluateCleanExpression = function (expression, form, level) {
1103
- expression = expression.substring(1, expression.length - 1);
1104
- var operator = this.containsComparisonOperator(expression);
1105
- if (!ObjectUtility.isEmpty(operator)) {
1106
- var expressionResult = this.prepareExpressionWithOperator(expression, operator, form, level);
1107
- return expressionResult;
1108
- }
1109
- return false;
1110
- };
1111
- ExpressionsUtility.containsComparisonOperator = function (expressions) {
1112
- var i = 0;
1113
- while (i < this.listComparisonOperators.length) {
1114
- if (expressions.indexOf(this.listComparisonOperators[i]) > -1) {
1115
- return this.listComparisonOperators[i];
1116
- }
1117
- i++;
1118
- }
1119
- return null;
1120
- };
1121
- ExpressionsUtility.prepareExpressionWithOperator = function (expression, operator, form, level) {
1122
- if (!ObjectUtility.isEmpty(this.containsComparisonOperator(expression))
1123
- && expression.indexOf(operator) > -1) {
1124
- var values = expression.split(operator);
1125
- if (values.length > 1) {
1126
- for (var i = 0; i < values.length; i++) {
1127
- values[i] = this.getControlValue(values[i], form);
1128
- }
1129
- var evaluatedExpression = this.evaluateExpressionWithOperator(values, operator);
1130
- if (this.expressionLoggingFlag)
1131
- ExpressionsUtility.logs = ExpressionsUtility.logs + Constants.START_LEVEL + level + Constants.END_LEVEL + "evaluate clean Expression {}> " + expression + " >result> " + evaluatedExpression + "\n";
1132
- return evaluatedExpression;
1133
- }
1134
- else
1135
- return false;
1136
- }
1137
- else
1138
- return false;
1139
- };
1140
- ExpressionsUtility.getControlValue = function (value, form) {
1141
- if (value.indexOf(Constants.CONTROL_PREFIX) > -1) {
1142
- return this.getControlFromForm(value, form);
1143
- }
1144
- else
1145
- return value;
1146
- };
1147
- ExpressionsUtility.getControlFromForm = function (value, form) {
1148
- value = value.replace(Constants.CONTROL_PREFIX, Constants.EMPTY_SPACE);
1149
- if (!ObjectUtility.isEmpty(form)
1150
- && !ObjectUtility.isEmpty(form.controls)
1151
- && !ObjectUtility.isEmpty(form.controls[value]))
1152
- value = form.controls[value].value;
1153
- return value;
1154
- };
1155
- ExpressionsUtility.evaluateExpressionWithOperator = function (values, operator) {
1156
- if (!ObjectUtility.isEmpty(values)
1157
- && values.length > 1
1158
- && !ObjectUtility.isEmpty(operator)) {
1159
- switch (operator) {
1160
- case ComparisonOperators.EQUAL: {
1161
- if (values[0] == values[1])
1162
- return true;
1163
- break;
1164
- }
1165
- case ComparisonOperators.NOT_EQUAL: {
1166
- if (!(values[0] == values[1]))
1167
- return true;
1168
- break;
1169
- }
1170
- case ComparisonOperators.GREATER_THAN: {
1171
- if ((new Number(values[0])) > (new Number(values[1])))
1172
- return true;
1173
- break;
1174
- }
1175
- case ComparisonOperators.LESS_THAN: {
1176
- if ((new Number(values[0])) < (new Number(values[1])))
1177
- return true;
1178
- break;
1179
- }
1180
- case ComparisonOperators.GREATER_THAN_OR_EQUAL: {
1181
- if ((new Number(values[0])) >= (new Number(values[1])))
1182
- return true;
1183
- break;
1184
- }
1185
- case ComparisonOperators.LESS_THAN_OR_EQUAL: {
1186
- if ((new Number(values[0])) <= (new Number(values[1])))
1187
- return true;
1188
- break;
1189
- }
1190
- case ComparisonOperators.CONTAINS: {
1191
- if (Array.from(values[0]).includes(values[1]))
1192
- return true;
1193
- break;
1194
- }
1195
- default: return false;
1196
- }
1197
- }
1198
- return false;
1199
- };
1200
- return ExpressionsUtility;
1201
- }());
1202
- ExpressionsUtility.expressionLoggingFlag = false;
1203
- ExpressionsUtility.logs = Constants.EMPTY_SPACE;
1204
- ExpressionsUtility.listComparisonOperators = [
1205
- ComparisonOperators.NOT_EQUAL,
1206
- ComparisonOperators.GREATER_THAN_OR_EQUAL,
1207
- ComparisonOperators.LESS_THAN_OR_EQUAL,
1208
- ComparisonOperators.EQUAL,
1209
- ComparisonOperators.GREATER_THAN,
1210
- ComparisonOperators.LESS_THAN,
1211
- ComparisonOperators.CONTAINS
1212
- ];
1213
-
1214
- var ExpressionsFormComponent = /** @class */ (function () {
1215
- function ExpressionsFormComponent() {
1216
- this.form = new i2$1.FormGroup({});
1217
- this.activeMap = new Map();
1218
- this.fileList = null;
1219
- this.fileName = "";
1220
- this.buttonsJustify = "end";
1221
- this.onSubmit = new i0.EventEmitter();
1222
- this.onInit = new i0.EventEmitter();
1223
- this.alert_timeout = Constants.ALERT_TIMEOUT;
1224
- this.danger = { active: false, label: '' };
1225
- this.warning = { active: false, label: '' };
1226
- this.success = { active: false, label: '' };
1227
- this.info = { active: false, label: '' };
1228
- this.primary = { active: false, label: '' };
1229
- this.secondary = { active: false, label: '' };
1230
- }
1231
- ExpressionsFormComponent.prototype.onClick = function (action) {
1232
- var data = {
1233
- action: action,
1234
- formValues: this.form.value
1235
- };
1236
- this.onSubmit.emit(data);
1237
- };
1238
- ExpressionsFormComponent.prototype.onInitialiazation = function () {
1239
- this.onInit.emit(this.form);
1240
- };
1241
- ExpressionsFormComponent.prototype.onEnter = function () {
1242
- this.onSubmit.emit(this.form.value);
1243
- };
1244
- ExpressionsFormComponent.prototype.onChange = function (changeFieldId) {
1245
- var e_1, _a, e_2, _b, e_3, _c;
1246
- try {
1247
- for (var _d = __values(this.formFields), _e = _d.next(); !_e.done; _e = _d.next()) {
1248
- var group = _e.value;
1249
- try {
1250
- for (var _f = (e_2 = void 0, __values(group === null || group === void 0 ? void 0 : group.groupFields)), _g = _f.next(); !_g.done; _g = _f.next()) {
1251
- var input = _g.value;
1252
- if (!ObjectUtility.isEmpty(input.expression)
1253
- && !ObjectUtility.isEmpty(input.id)
1254
- && input.expression.indexOf(changeFieldId) > -1
1255
- && input.id.indexOf(changeFieldId) < 0) {
1256
- var validationResult = this.validateExpression(input);
1257
- this.activeMap.set(input.id, validationResult);
1258
- if (!validationResult) {
1259
- this.onChange(input.id);
1260
- }
1261
- }
1262
- }
1263
- }
1264
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1265
- finally {
1266
- try {
1267
- if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
1268
- }
1269
- finally { if (e_2) throw e_2.error; }
1270
- }
1271
- }
1272
- }
1273
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1274
- finally {
1275
- try {
1276
- if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
1277
- }
1278
- finally { if (e_1) throw e_1.error; }
1279
- }
1280
- if (!ObjectUtility.isEmpty(this.buttons))
1281
- try {
1282
- for (var _h = __values(this.buttons), _j = _h.next(); !_j.done; _j = _h.next()) {
1283
- var input = _j.value;
1284
- if (!ObjectUtility.isEmpty(input.expression)
1285
- && !ObjectUtility.isEmpty(input.id)
1286
- && input.expression.indexOf(changeFieldId) > -1
1287
- && input.id.indexOf(changeFieldId) < 0)
1288
- this.activeMap.set(input.id, this.validateExpression(input));
1289
- }
1290
- }
1291
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1292
- finally {
1293
- try {
1294
- if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
1295
- }
1296
- finally { if (e_3) throw e_3.error; }
1297
- }
1298
- };
1299
- ExpressionsFormComponent.prototype.ngOnInit = function () {
1300
- this.buildFormGroup(this.formFields);
1301
- this.onInitialiazation();
1302
- this.buttonMargin = FormsUtility.getMargin(this.buttonsJustify);
1303
- this.buttonsJustify = Constants.DFLEX + Constants.BLANK_SPACE + Constants.JUSTIFY_CONTENT + this.buttonsJustify;
1304
- };
1305
- ExpressionsFormComponent.prototype.runExpressionValidations = function () {
1306
- var e_4, _a, e_5, _b, e_6, _c;
1307
- try {
1308
- for (var _d = __values(this.formFields), _e = _d.next(); !_e.done; _e = _d.next()) {
1309
- var group = _e.value;
1310
- try {
1311
- for (var _f = (e_5 = void 0, __values(group.groupFields)), _g = _f.next(); !_g.done; _g = _f.next()) {
1312
- var input = _g.value;
1313
- this.activeMap.set(input.id, this.validateExpression(input));
1314
- }
1315
- }
1316
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
1317
- finally {
1318
- try {
1319
- if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
1320
- }
1321
- finally { if (e_5) throw e_5.error; }
1322
- }
1323
- }
1324
- }
1325
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
1326
- finally {
1327
- try {
1328
- if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
1329
- }
1330
- finally { if (e_4) throw e_4.error; }
1331
- }
1332
- if (!ObjectUtility.isEmpty(this.buttons))
1333
- try {
1334
- for (var _h = __values(this.buttons), _j = _h.next(); !_j.done; _j = _h.next()) {
1335
- var input = _j.value;
1336
- this.activeMap.set(input.id, this.validateExpression(input));
1337
- }
1338
- }
1339
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
1340
- finally {
1341
- try {
1342
- if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
1343
- }
1344
- finally { if (e_6) throw e_6.error; }
1345
- }
1346
- };
1347
- ExpressionsFormComponent.prototype.buildFormGroup = function (fields) {
1348
- this.form = FormsUtility.buildFromGroup(fields, this.disabled);
1349
- this.runExpressionValidations();
1350
- };
1351
- ExpressionsFormComponent.prototype.getForm = function () {
1352
- return this.form;
1353
- };
1354
- ExpressionsFormComponent.prototype.setFormValue = function (value) {
1355
- if (!ObjectUtility.isEmpty(this.form)) {
1356
- this.form.reset(value);
1357
- this.form.updateValueAndValidity();
1358
- this.runExpressionValidations();
1359
- }
1360
- };
1361
- ExpressionsFormComponent.prototype.getFormControls = function () {
1362
- if (!ObjectUtility.isEmpty(this.form)) {
1363
- return this.form.controls;
1364
- }
1365
- };
1366
- ExpressionsFormComponent.prototype.getFormControl = function (controlName) {
1367
- if (!ObjectUtility.isEmpty(this.form)
1368
- && !ObjectUtility.isEmpty(this.form.controls)) {
1369
- return this.form.controls[controlName];
1370
- }
1371
- };
1372
- ExpressionsFormComponent.prototype.setFormControlValue = function (controlName, value) {
1373
- if (!ObjectUtility.isEmpty(this.form)
1374
- && !ObjectUtility.isEmpty(this.form.controls)
1375
- && !ObjectUtility.isEmpty(this.form.controls)
1376
- && !ObjectUtility.isEmpty(this.form.controls[controlName])) {
1377
- this.form.controls[controlName].reset(value);
1378
- this.form.controls[controlName].updateValueAndValidity();
1379
- this.onChange(controlName);
1380
- }
1381
- };
1382
- ExpressionsFormComponent.prototype.includeRequired = function (validators) {
1383
- return FormsUtility.includeRequired(validators);
1384
- };
1385
- ExpressionsFormComponent.prototype.updateCheckboxValue = function (formArray, controlName, event, value) {
1386
- FormsUtility.updateCheckboxValue(this.form, formArray, controlName, event.target.checked, value);
1387
- this.onChange(event.target.name);
1388
- };
1389
- ExpressionsFormComponent.prototype.updateRadioValue = function (controlName, event, optionId) {
1390
- FormsUtility.updateRadioValue(this.form, controlName, event.target.checked, optionId);
1391
- this.onChange(event.target.name);
1392
- };
1393
- ExpressionsFormComponent.prototype.isCheckBoxChecked = function (controlName, optionId) {
1394
- return FormsUtility.isCheckBoxChecked(this.form, controlName, optionId);
1395
- };
1396
- ExpressionsFormComponent.prototype.isRadioChecked = function (controlName, optionId) {
1397
- return FormsUtility.isRadioChecked(this.form, controlName, optionId);
1398
- };
1399
- ExpressionsFormComponent.prototype.validateExpression = function (input) {
1400
- var result = ExpressionsUtility.evaluateExpression(input.expression, this.form, 1);
1401
- if (!result
1402
- && !ObjectUtility.isEmpty(this.form)
1403
- && !ObjectUtility.isEmpty(this.form.controls)
1404
- && !ObjectUtility.isEmpty(this.form.controls[input.id])) {
1405
- this.form.controls[input.id].reset();
1406
- this.form.controls[input.id].updateValueAndValidity();
1407
- }
1408
- FormsUtility.setValidators(input, this.form, result);
1409
- return result;
1410
- };
1411
- ExpressionsFormComponent.prototype.validateExpressionsInRow = function (row) {
1412
- var e_7, _a;
1413
- try {
1414
- for (var row_1 = __values(row), row_1_1 = row_1.next(); !row_1_1.done; row_1_1 = row_1.next()) {
1415
- var input = row_1_1.value;
1416
- if (this.activeMap.get(input.id))
1417
- return true;
1418
- }
1419
- }
1420
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
1421
- finally {
1422
- try {
1423
- if (row_1_1 && !row_1_1.done && (_a = row_1.return)) _a.call(row_1);
1424
- }
1425
- finally { if (e_7) throw e_7.error; }
1426
- }
1427
- return false;
1428
- };
1429
- ExpressionsFormComponent.prototype.resetForm = function () {
1430
- this.form = FormsUtility.resetForm(this.formFields, this.form);
1431
- this.runExpressionValidations();
1432
- };
1433
- ExpressionsFormComponent.prototype.getDisabled = function () {
1434
- return this.disabled;
1435
- };
1436
- ExpressionsFormComponent.prototype.setDisabled = function (disabled) {
1437
- this.disabled = disabled;
1438
- this.form = FormsUtility.buildFromGroup(this.formFields, this.disabled);
1439
- };
1440
- ExpressionsFormComponent.prototype.fileChange = function (event) {
1441
- this.fileList = event.target.files;
1442
- //console.log("fileList>",this.fileList);
1443
- if (!ObjectUtility.isEmpty(this.fileList) && event.target.files.length > 0)
1444
- this.fileName = this.fileList[0].name;
1445
- else
1446
- this.fileName = "";
1447
- };
1448
- ExpressionsFormComponent.prototype.onUploadClick = function (id) {
1449
- var data = {
1450
- action: 'uploadFile',
1451
- fileList: this.fileList,
1452
- fieldId: id
1453
- };
1454
- this.onSubmit.emit(data);
1455
- };
1456
- ExpressionsFormComponent.prototype.isEmpty = function (value) {
1457
- return ObjectUtility.isEmpty(value);
1458
- };
1459
- ExpressionsFormComponent.prototype.setDanger = function (label) {
1460
- var _this = this;
1461
- this.danger.active = true;
1462
- this.danger.label = label;
1463
- setTimeout(function () {
1464
- _this.danger.active = false;
1465
- }, this.alert_timeout);
1466
- };
1467
- ExpressionsFormComponent.prototype.setWarning = function (label) {
1468
- var _this = this;
1469
- this.warning.active = true;
1470
- this.warning.label = label;
1471
- setTimeout(function () {
1472
- _this.warning.active = false;
1473
- }, this.alert_timeout);
1474
- };
1475
- ExpressionsFormComponent.prototype.setSuccess = function (label) {
1476
- var _this = this;
1477
- this.success.active = true;
1478
- this.success.label = label;
1479
- setTimeout(function () {
1480
- _this.success.active = false;
1481
- }, this.alert_timeout);
1482
- };
1483
- ExpressionsFormComponent.prototype.setInfo = function (label) {
1484
- var _this = this;
1485
- this.info.active = true;
1486
- this.info.label = label;
1487
- setTimeout(function () {
1488
- _this.info.active = false;
1489
- }, this.alert_timeout);
1490
- };
1491
- ExpressionsFormComponent.prototype.setPrimary = function (label) {
1492
- var _this = this;
1493
- this.primary.active = true;
1494
- this.primary.label = label;
1495
- setTimeout(function () {
1496
- _this.primary.active = false;
1497
- }, this.alert_timeout);
1498
- };
1499
- ExpressionsFormComponent.prototype.setSecondary = function (label) {
1500
- var _this = this;
1501
- this.secondary.active = true;
1502
- this.secondary.label = label;
1503
- setTimeout(function () {
1504
- _this.secondary.active = false;
1505
- }, this.alert_timeout);
1506
- };
1507
- ExpressionsFormComponent.prototype.setAlertTimeout = function (timeout) {
1508
- this.alert_timeout = timeout;
1509
- };
1510
- return ExpressionsFormComponent;
1511
- }());
1512
- /** @nocollapse */ ExpressionsFormComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: ExpressionsFormComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
1513
- /** @nocollapse */ ExpressionsFormComponent.ɵcmp = i0__namespace.ɵɵ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__namespace, 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__namespace$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i2__namespace$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i2__namespace$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i2__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2__namespace.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i2__namespace.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i2__namespace$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__namespace$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i2__namespace$1.FormControlName, selector: "[formControlName]", inputs: ["disabled", "formControlName", "ngModel"], outputs: ["ngModelChange"] }, { type: i2__namespace$1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { type: i2__namespace$1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i2__namespace$1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i2__namespace$1.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }] });
1514
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: ExpressionsFormComponent, decorators: [{
1515
- type: i0.Component,
1516
- args: [{
1517
- selector: 'df-expressions-form',
1518
- templateUrl: './expressions-form.component.html',
1519
- styleUrls: ['./expressions-form.component.scss']
1520
- }]
1521
- }], ctorParameters: function () { return []; }, propDecorators: { formFields: [{
1522
- type: i0.Input
1523
- }], disabled: [{
1524
- type: i0.Input
1525
- }], buttons: [{
1526
- type: i0.Input
1527
- }], buttonsJustify: [{
1528
- type: i0.Input
1529
- }], onSubmit: [{
1530
- type: i0.Output
1531
- }], onInit: [{
1532
- type: i0.Output
1533
- }] } });
1534
-
1535
- var AccordionFormComponent = /** @class */ (function () {
1536
- function AccordionFormComponent() {
1537
- this.currentSection = 0;
1538
- this.initIndex = 0;
1539
- this.forms = [];
1540
- this.onSubmit = new i0.EventEmitter();
1541
- this.alert_timeout = Constants.ALERT_TIMEOUT;
1542
- this.danger = { active: false, label: '' };
1543
- this.warning = { active: false, label: '' };
1544
- this.success = { active: false, label: '' };
1545
- this.info = { active: false, label: '' };
1546
- this.primary = { active: false, label: '' };
1547
- this.secondary = { active: false, label: '' };
1548
- }
1549
- AccordionFormComponent.prototype.ngOnInit = function () {
1550
- };
1551
- AccordionFormComponent.prototype.onClick = function (action) {
1552
- var e_1, _a;
1553
- var formValues = [];
1554
- try {
1555
- for (var _b = __values(this.forms), _c = _b.next(); !_c.done; _c = _b.next()) {
1556
- var myform = _c.value;
1557
- formValues.push(myform.value);
1558
- }
1559
- }
1560
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1561
- finally {
1562
- try {
1563
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1564
- }
1565
- finally { if (e_1) throw e_1.error; }
1566
- }
1567
- var result = { action: action, formValues: formValues };
1568
- this.onSubmit.emit(result);
1569
- };
1570
- AccordionFormComponent.prototype.onSectionButtonClicked = function (event, index, sectionLabel) {
1571
- event['index'] = index;
1572
- event['sectionLabel'] = sectionLabel;
1573
- this.onSubmit.emit(event);
1574
- };
1575
- AccordionFormComponent.prototype.resetForms = function () {
1576
- var e_2, _a, e_3, _b, e_4, _c;
1577
- try {
1578
- for (var _d = __values(this.sections.entries()), _e = _d.next(); !_e.done; _e = _d.next()) {
1579
- var _f = __read(_e.value, 2), index = _f[0], section = _f[1];
1580
- try {
1581
- for (var _g = (e_3 = void 0, __values(section.sectionFields)), _h = _g.next(); !_h.done; _h = _g.next()) {
1582
- var rows = _h.value;
1583
- try {
1584
- for (var rows_1 = (e_4 = void 0, __values(rows)), rows_1_1 = rows_1.next(); !rows_1_1.done; rows_1_1 = rows_1.next()) {
1585
- var input = rows_1_1.value;
1586
- if (!ObjectUtility.isEmpty(input.id)
1587
- && !input.readonly
1588
- && !input.disabled) {
1589
- var form = this.forms[index].form;
1590
- var control = form.controls[input.id];
1591
- control.reset();
1592
- }
1593
- }
1594
- }
1595
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
1596
- finally {
1597
- try {
1598
- if (rows_1_1 && !rows_1_1.done && (_c = rows_1.return)) _c.call(rows_1);
1599
- }
1600
- finally { if (e_4) throw e_4.error; }
1601
- }
1602
- }
1603
- }
1604
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1605
- finally {
1606
- try {
1607
- if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
1608
- }
1609
- finally { if (e_3) throw e_3.error; }
1610
- }
1611
- }
1612
- }
1613
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1614
- finally {
1615
- try {
1616
- if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
1617
- }
1618
- finally { if (e_2) throw e_2.error; }
1619
- }
1620
- };
1621
- AccordionFormComponent.prototype.onStart = function (event) {
1622
- if (this.sections.length == this.forms.length) {
1623
- this.forms[this.initIndex] = event;
1624
- if (this.initIndex == (this.forms.length - 1))
1625
- this.initIndex = 0;
1626
- else
1627
- this.initIndex++;
1628
- }
1629
- else
1630
- this.forms.push(event);
1631
- };
1632
- AccordionFormComponent.prototype.getCurrentSection = function () {
1633
- return this.currentSection;
1634
- };
1635
- AccordionFormComponent.prototype.setCurrentSection = function (sectionNumber) {
1636
- this.currentSection = sectionNumber;
1637
- };
1638
- AccordionFormComponent.prototype.allFormsAreValid = function () {
1639
- if (!this.forms[this.currentSection].valid)
1640
- return false;
1641
- for (var i = 0; i < this.forms.length; i++) {
1642
- if (i != this.currentSection && !this.forms[i].valid)
1643
- return false;
1644
- }
1645
- return true;
1646
- };
1647
- AccordionFormComponent.prototype.getHeadingId = function (i) {
1648
- return this.accordionId + '-heading-' + i;
1649
- };
1650
- AccordionFormComponent.prototype.getCollapseId = function (i) {
1651
- return this.accordionId + '-collapse-' + i;
1652
- };
1653
- AccordionFormComponent.prototype.isEmpty = function (value) {
1654
- return ObjectUtility.isEmpty(value);
1655
- };
1656
- AccordionFormComponent.prototype.setDanger = function (label) {
1657
- var _this = this;
1658
- this.danger.active = true;
1659
- this.danger.label = label;
1660
- setTimeout(function () {
1661
- _this.danger.active = false;
1662
- }, this.alert_timeout);
1663
- };
1664
- AccordionFormComponent.prototype.setWarning = function (label) {
1665
- var _this = this;
1666
- this.warning.active = true;
1667
- this.warning.label = label;
1668
- setTimeout(function () {
1669
- _this.warning.active = false;
1670
- }, this.alert_timeout);
1671
- };
1672
- AccordionFormComponent.prototype.setSuccess = function (label) {
1673
- var _this = this;
1674
- this.success.active = true;
1675
- this.success.label = label;
1676
- setTimeout(function () {
1677
- _this.success.active = false;
1678
- }, this.alert_timeout);
1679
- };
1680
- AccordionFormComponent.prototype.setInfo = function (label) {
1681
- var _this = this;
1682
- this.info.active = true;
1683
- this.info.label = label;
1684
- setTimeout(function () {
1685
- _this.info.active = false;
1686
- }, this.alert_timeout);
1687
- };
1688
- AccordionFormComponent.prototype.setPrimary = function (label) {
1689
- var _this = this;
1690
- this.primary.active = true;
1691
- this.primary.label = label;
1692
- setTimeout(function () {
1693
- _this.primary.active = false;
1694
- }, this.alert_timeout);
1695
- };
1696
- AccordionFormComponent.prototype.setSecondary = function (label) {
1697
- var _this = this;
1698
- this.secondary.active = true;
1699
- this.secondary.label = label;
1700
- setTimeout(function () {
1701
- _this.secondary.active = false;
1702
- }, this.alert_timeout);
1703
- };
1704
- AccordionFormComponent.prototype.setAlertTimeout = function (timeout) {
1705
- this.alert_timeout = timeout;
1706
- };
1707
- return AccordionFormComponent;
1708
- }());
1709
- /** @nocollapse */ AccordionFormComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: AccordionFormComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
1710
- /** @nocollapse */ AccordionFormComponent.ɵcmp = i0__namespace.ɵɵ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__namespace, 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__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2__namespace.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i2__namespace.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }] });
1711
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: AccordionFormComponent, decorators: [{
1712
- type: i0.Component,
1713
- args: [{
1714
- selector: 'df-accordion-form',
1715
- templateUrl: './accordion-form.component.html',
1716
- styleUrls: ['./accordion-form.component.scss']
1717
- }]
1718
- }], ctorParameters: function () { return []; }, propDecorators: { sections: [{
1719
- type: i0.Input
1720
- }], accordionId: [{
1721
- type: i0.Input
1722
- }], buttons: [{
1723
- type: i0.Input
1724
- }], onSubmit: [{
1725
- type: i0.Output
1726
- }] } });
1727
-
1728
- var ModalFormComponent = /** @class */ (function () {
1729
- function ModalFormComponent() {
1730
- this.onSubmit = new i0.EventEmitter();
1731
- this.alert_timeout = Constants.ALERT_TIMEOUT;
1732
- this.danger = { active: false, label: '' };
1733
- this.warning = { active: false, label: '' };
1734
- this.success = { active: false, label: '' };
1735
- this.info = { active: false, label: '' };
1736
- this.primary = { active: false, label: '' };
1737
- this.secondary = { active: false, label: '' };
1738
- }
1739
- ModalFormComponent.prototype.ngOnInit = function () {
1740
- };
1741
- ModalFormComponent.prototype.onStart = function (event) {
1742
- this.form = event;
1743
- };
1744
- ModalFormComponent.prototype.getForm = function () {
1745
- if (!ObjectUtility.isEmpty(this.form))
1746
- return this.form;
1747
- };
1748
- ModalFormComponent.prototype.getFormControls = function () {
1749
- if (!ObjectUtility.isEmpty(this.form))
1750
- return this.form.controls;
1751
- };
1752
- ModalFormComponent.prototype.onClick = function (action) {
1753
- var data = {
1754
- action: action,
1755
- formValues: this.form.value
1756
- };
1757
- this.onSubmit.emit(data);
1758
- };
1759
- ModalFormComponent.prototype.isFormValid = function () {
1760
- return this.form.valid;
1761
- };
1762
- ModalFormComponent.prototype.resetForm = function () {
1763
- var e_1, _a, e_2, _b;
1764
- try {
1765
- for (var _c = __values(this.modal.fields), _d = _c.next(); !_d.done; _d = _c.next()) {
1766
- var row = _d.value;
1767
- try {
1768
- for (var row_1 = (e_2 = void 0, __values(row)), row_1_1 = row_1.next(); !row_1_1.done; row_1_1 = row_1.next()) {
1769
- var input = row_1_1.value;
1770
- if (!input.disabled
1771
- && !input.readonly) {
1772
- this.form.controls[input.id].reset();
1773
- }
1774
- }
1775
- }
1776
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1777
- finally {
1778
- try {
1779
- if (row_1_1 && !row_1_1.done && (_b = row_1.return)) _b.call(row_1);
1780
- }
1781
- finally { if (e_2) throw e_2.error; }
1782
- }
1783
- }
1784
- }
1785
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1786
- finally {
1787
- try {
1788
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
1789
- }
1790
- finally { if (e_1) throw e_1.error; }
1791
- }
1792
- };
1793
- ModalFormComponent.prototype.closeModal = function () {
1794
- this.closeModalElement.nativeElement.click();
1795
- };
1796
- ModalFormComponent.prototype.setDanger = function (label) {
1797
- var _this = this;
1798
- this.danger.active = true;
1799
- this.danger.label = label;
1800
- setTimeout(function () {
1801
- _this.danger.active = false;
1802
- }, this.alert_timeout);
1803
- };
1804
- ModalFormComponent.prototype.setWarning = function (label) {
1805
- var _this = this;
1806
- this.warning.active = true;
1807
- this.warning.label = label;
1808
- setTimeout(function () {
1809
- _this.warning.active = false;
1810
- }, this.alert_timeout);
1811
- };
1812
- ModalFormComponent.prototype.setSuccess = function (label) {
1813
- var _this = this;
1814
- this.success.active = true;
1815
- this.success.label = label;
1816
- setTimeout(function () {
1817
- _this.success.active = false;
1818
- }, this.alert_timeout);
1819
- };
1820
- ModalFormComponent.prototype.setInfo = function (label) {
1821
- var _this = this;
1822
- this.info.active = true;
1823
- this.info.label = label;
1824
- setTimeout(function () {
1825
- _this.info.active = false;
1826
- }, this.alert_timeout);
1827
- };
1828
- ModalFormComponent.prototype.setPrimary = function (label) {
1829
- var _this = this;
1830
- this.primary.active = true;
1831
- this.primary.label = label;
1832
- setTimeout(function () {
1833
- _this.primary.active = false;
1834
- }, this.alert_timeout);
1835
- };
1836
- ModalFormComponent.prototype.setSecondary = function (label) {
1837
- var _this = this;
1838
- this.secondary.active = true;
1839
- this.secondary.label = label;
1840
- setTimeout(function () {
1841
- _this.secondary.active = false;
1842
- }, this.alert_timeout);
1843
- };
1844
- ModalFormComponent.prototype.setAlertTimeout = function (timeout) {
1845
- this.alert_timeout = timeout;
1846
- };
1847
- return ModalFormComponent;
1848
- }());
1849
- /** @nocollapse */ ModalFormComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: ModalFormComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
1850
- /** @nocollapse */ ModalFormComponent.ɵcmp = i0__namespace.ɵɵ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__namespace, 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__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2__namespace.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i2__namespace.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }] });
1851
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: ModalFormComponent, decorators: [{
1852
- type: i0.Component,
1853
- args: [{
1854
- selector: 'df-modal-form',
1855
- templateUrl: './modal-form.component.html',
1856
- styleUrls: ['./modal-form.component.scss']
1857
- }]
1858
- }], ctorParameters: function () { return []; }, propDecorators: { modal: [{
1859
- type: i0.Input
1860
- }], buttons: [{
1861
- type: i0.Input
1862
- }], disabled: [{
1863
- type: i0.Input
1864
- }], onSubmit: [{
1865
- type: i0.Output
1866
- }], closeModalElement: [{
1867
- type: i0.ViewChild,
1868
- args: ['closeModalElement', {}]
1869
- }] } });
1870
-
1871
- var TabFormComponent = /** @class */ (function () {
1872
- function TabFormComponent() {
1873
- this.currentSection = 0;
1874
- this.initIndex = 0;
1875
- this.forms = [];
1876
- this.position = 'top';
1877
- this.onSubmit = new i0.EventEmitter();
1878
- this.alert_timeout = Constants.ALERT_TIMEOUT;
1879
- this.danger = { active: false, label: '' };
1880
- this.warning = { active: false, label: '' };
1881
- this.success = { active: false, label: '' };
1882
- this.info = { active: false, label: '' };
1883
- this.primary = { active: false, label: '' };
1884
- this.secondary = { active: false, label: '' };
1885
- }
1886
- TabFormComponent.prototype.ngOnInit = function () {
1887
- };
1888
- TabFormComponent.prototype.getNavType = function () {
1889
- if (!ObjectUtility.isEmpty(this.type)) {
1890
- if (this.type === 'pills') {
1891
- if (this.position === 'left' || this.position === 'right')
1892
- return 'nav nav-pills flex-column';
1893
- else
1894
- return 'nav nav-pills';
1895
- }
1896
- else
1897
- return 'nav nav-tabs';
1898
- }
1899
- else
1900
- return 'nav nav-tabs';
1901
- };
1902
- TabFormComponent.prototype.getMargin = function () {
1903
- if (!ObjectUtility.isEmpty(this.type) && this.type === 'pills') {
1904
- return 'margin-item';
1905
- }
1906
- };
1907
- TabFormComponent.prototype.onClick = function (action) {
1908
- var e_1, _a;
1909
- var formValues = [];
1910
- try {
1911
- for (var _b = __values(this.forms), _c = _b.next(); !_c.done; _c = _b.next()) {
1912
- var myform = _c.value;
1913
- formValues.push(myform.value);
1914
- }
1915
- }
1916
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1917
- finally {
1918
- try {
1919
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1920
- }
1921
- finally { if (e_1) throw e_1.error; }
1922
- }
1923
- var result = { action: action, formValues: formValues };
1924
- this.onSubmit.emit(result);
1925
- };
1926
- TabFormComponent.prototype.onSectionButtonClicked = function (event, index, sectionLabel) {
1927
- event['index'] = index;
1928
- event['sectionLabel'] = sectionLabel;
1929
- this.onSubmit.emit(event);
1930
- };
1931
- TabFormComponent.prototype.getForms = function () {
1932
- return this.forms;
1933
- };
1934
- TabFormComponent.prototype.resetForms = function () {
1935
- var e_2, _a, e_3, _b, e_4, _c;
1936
- try {
1937
- for (var _d = __values(this.sections.entries()), _e = _d.next(); !_e.done; _e = _d.next()) {
1938
- var _f = __read(_e.value, 2), index = _f[0], section = _f[1];
1939
- try {
1940
- for (var _g = (e_3 = void 0, __values(section.sectionFields)), _h = _g.next(); !_h.done; _h = _g.next()) {
1941
- var rows = _h.value;
1942
- try {
1943
- for (var rows_1 = (e_4 = void 0, __values(rows)), rows_1_1 = rows_1.next(); !rows_1_1.done; rows_1_1 = rows_1.next()) {
1944
- var input = rows_1_1.value;
1945
- if (!ObjectUtility.isEmpty(input.id)
1946
- && !input.readonly
1947
- && !input.disabled) {
1948
- var form = this.forms[index].form;
1949
- var control = form.controls[input.id];
1950
- control.reset();
1951
- }
1952
- }
1953
- }
1954
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
1955
- finally {
1956
- try {
1957
- if (rows_1_1 && !rows_1_1.done && (_c = rows_1.return)) _c.call(rows_1);
1958
- }
1959
- finally { if (e_4) throw e_4.error; }
1960
- }
1961
- }
1962
- }
1963
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1964
- finally {
1965
- try {
1966
- if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
1967
- }
1968
- finally { if (e_3) throw e_3.error; }
1969
- }
1970
- }
1971
- }
1972
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1973
- finally {
1974
- try {
1975
- if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
1976
- }
1977
- finally { if (e_2) throw e_2.error; }
1978
- }
1979
- };
1980
- TabFormComponent.prototype.getCurrentSection = function () {
1981
- return this.currentSection;
1982
- };
1983
- TabFormComponent.prototype.onStart = function (event) {
1984
- if (this.sections.length == this.forms.length) {
1985
- this.forms[this.initIndex] = event;
1986
- if (this.initIndex == (this.forms.length - 1))
1987
- this.initIndex = 0;
1988
- else
1989
- this.initIndex++;
1990
- }
1991
- else
1992
- this.forms.push(event);
1993
- };
1994
- TabFormComponent.prototype.setCurrentSection = function (sectionNumber) {
1995
- this.currentSection = sectionNumber;
1996
- };
1997
- TabFormComponent.prototype.allFormsAreValid = function () {
1998
- if (!this.forms[this.currentSection].valid)
1999
- return false;
2000
- for (var i = 0; i < this.forms.length; i++) {
2001
- if (i != this.currentSection && !this.forms[i].valid)
2002
- return false;
2003
- }
2004
- return true;
2005
- };
2006
- TabFormComponent.prototype.getCols = function (type, position, column) {
2007
- if (type == 'pills') {
2008
- if (position == 'left') {
2009
- if (column == 1) {
2010
- return 'col-3 mycol';
2011
- }
2012
- else if (column == 2)
2013
- return 'col-9 mycol';
2014
- }
2015
- else if (position == 'right') {
2016
- if (column == 2) {
2017
- return 'col-9 mycol';
2018
- }
2019
- else if (column == 3)
2020
- return 'col-3 mycol';
2021
- }
2022
- else {
2023
- if (column == 2)
2024
- return 'col-12 mycol';
2025
- }
2026
- }
2027
- else {
2028
- if (column == 2)
2029
- return 'col-12 mycol';
2030
- }
2031
- };
2032
- TabFormComponent.prototype.isEmpty = function (value) {
2033
- return ObjectUtility.isEmpty(value);
2034
- };
2035
- TabFormComponent.prototype.setDanger = function (label) {
2036
- var _this = this;
2037
- this.danger.active = true;
2038
- this.danger.label = label;
2039
- setTimeout(function () {
2040
- _this.danger.active = false;
2041
- }, this.alert_timeout);
2042
- };
2043
- TabFormComponent.prototype.setWarning = function (label) {
2044
- var _this = this;
2045
- this.warning.active = true;
2046
- this.warning.label = label;
2047
- setTimeout(function () {
2048
- _this.warning.active = false;
2049
- }, this.alert_timeout);
2050
- };
2051
- TabFormComponent.prototype.setSuccess = function (label) {
2052
- var _this = this;
2053
- this.success.active = true;
2054
- this.success.label = label;
2055
- setTimeout(function () {
2056
- _this.success.active = false;
2057
- }, this.alert_timeout);
2058
- };
2059
- TabFormComponent.prototype.setInfo = function (label) {
2060
- var _this = this;
2061
- this.info.active = true;
2062
- this.info.label = label;
2063
- setTimeout(function () {
2064
- _this.info.active = false;
2065
- }, this.alert_timeout);
2066
- };
2067
- TabFormComponent.prototype.setPrimary = function (label) {
2068
- var _this = this;
2069
- this.primary.active = true;
2070
- this.primary.label = label;
2071
- setTimeout(function () {
2072
- _this.primary.active = false;
2073
- }, this.alert_timeout);
2074
- };
2075
- TabFormComponent.prototype.setSecondary = function (label) {
2076
- var _this = this;
2077
- this.secondary.active = true;
2078
- this.secondary.label = label;
2079
- setTimeout(function () {
2080
- _this.secondary.active = false;
2081
- }, this.alert_timeout);
2082
- };
2083
- TabFormComponent.prototype.setAlertTimeout = function (timeout) {
2084
- this.alert_timeout = timeout;
2085
- };
2086
- return TabFormComponent;
2087
- }());
2088
- /** @nocollapse */ TabFormComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: TabFormComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
2089
- /** @nocollapse */ TabFormComponent.ɵcmp = i0__namespace.ɵɵ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__namespace, 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__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2__namespace.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i2__namespace.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }] });
2090
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: TabFormComponent, decorators: [{
2091
- type: i0.Component,
2092
- args: [{
2093
- selector: 'df-tab-form',
2094
- templateUrl: './tab-form.component.html',
2095
- styleUrls: ['./tab-form.component.scss']
2096
- }]
2097
- }], ctorParameters: function () { return []; }, propDecorators: { sections: [{
2098
- type: i0.Input
2099
- }], buttons: [{
2100
- type: i0.Input
2101
- }], type: [{
2102
- type: i0.Input
2103
- }], tabsId: [{
2104
- type: i0.Input
2105
- }], position: [{
2106
- type: i0.Input
2107
- }], onSubmit: [{
2108
- type: i0.Output
2109
- }], myForm: [{
2110
- type: i0.ViewChild,
2111
- args: ['myForm', {}]
2112
- }] } });
2113
-
2114
- var AppError = /** @class */ (function () {
2115
- function AppError(originalError) {
2116
- this.originalError = originalError;
2117
- }
2118
- return AppError;
2119
- }());
2120
-
2121
- var InvalidUserError = /** @class */ (function (_super) {
2122
- __extends(InvalidUserError, _super);
2123
- function InvalidUserError() {
2124
- return _super !== null && _super.apply(this, arguments) || this;
2125
- }
2126
- return InvalidUserError;
2127
- }(AppError));
2128
-
2129
- var BadRequestError = /** @class */ (function (_super) {
2130
- __extends(BadRequestError, _super);
2131
- function BadRequestError() {
2132
- return _super !== null && _super.apply(this, arguments) || this;
2133
- }
2134
- return BadRequestError;
2135
- }(AppError));
2136
-
2137
- var NotFoundError = /** @class */ (function (_super) {
2138
- __extends(NotFoundError, _super);
2139
- function NotFoundError() {
2140
- return _super !== null && _super.apply(this, arguments) || this;
2141
- }
2142
- return NotFoundError;
2143
- }(AppError));
2144
-
2145
- //Angular Core
2146
- var DataService = /** @class */ (function () {
2147
- function DataService(_url, http) {
2148
- this._url = _url;
2149
- this.http = http;
2150
- }
2151
- DataService.prototype.getAll = function () {
2152
- return this.http.get(this._url)
2153
- .pipe(operators.map(function (response) { return response; })).pipe(operators.catchError(this.handleError));
2154
- };
2155
- DataService.prototype.getByParam = function (params) {
2156
- var param = Constants.QUESTION_MARK;
2157
- params.forEach(function (element) {
2158
- param = param + element.key + Constants.EQUAL + element.value + Constants.AMPERSAND;
2159
- });
2160
- return this.http.get(this._url + param)
2161
- .pipe(operators.map(function (response) { return response; })).pipe(operators.catchError(this.handleError));
2162
- };
2163
- DataService.prototype.create = function (resource) {
2164
- return this.http.post(this._url, JSON.stringify(resource))
2165
- .pipe(operators.map(function (response) { return response; })).pipe(operators.catchError(this.handleError));
2166
- };
2167
- DataService.prototype.update = function (resource) {
2168
- return this.http.patch(this._url + Constants.BACK_SLASH + resource.id, JSON.stringify({ isRead: true }))
2169
- .pipe(operators.map(function (response) { return response; })).pipe(operators.catchError(this.handleError));
2170
- };
2171
- DataService.prototype.delete = function (id) {
2172
- return this.http.delete(this._url + Constants.BACK_SLASH + id)
2173
- .pipe(operators.map(function (response) { return response; })).pipe(operators.catchError(this.handleError));
2174
- };
2175
- DataService.prototype.getId = function (id) {
2176
- return this.http.get(this._url + Constants.BACK_SLASH + id)
2177
- .pipe(operators.map(function (response) { return response; })).pipe(operators.catchError(this.handleError));
2178
- };
2179
- DataService.prototype.getObject = function (resource) {
2180
- return this.http.post(this._url, resource)
2181
- .pipe(operators.map(function (response) { return response; })).pipe(operators.catchError(this.handleError));
2182
- };
2183
- DataService.prototype.handleError = function (error) {
2184
- console.log('DataService.handleError.error', error);
2185
- if (error.status === 404)
2186
- return rxjs.throwError(new NotFoundError());
2187
- if (error.status === 400)
2188
- return rxjs.throwError(new BadRequestError());
2189
- if (error.status === 401)
2190
- return rxjs.throwError(new InvalidUserError());
2191
- return rxjs.throwError(new AppError(error));
2192
- };
2193
- return DataService;
2194
- }());
2195
- /** @nocollapse */ DataService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: DataService, deps: [{ token: String }, { token: i1__namespace.HttpClient }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2196
- /** @nocollapse */ DataService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: DataService });
2197
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: DataService, decorators: [{
2198
- type: i0.Injectable
2199
- }], ctorParameters: function () {
2200
- return [{ type: undefined, decorators: [{
2201
- type: i0.Inject,
2202
- args: [String]
2203
- }] }, { type: i1__namespace.HttpClient }];
2204
- } });
2205
-
2206
- var AppErrorHandler = /** @class */ (function () {
2207
- function AppErrorHandler() {
2208
- }
2209
- AppErrorHandler.prototype.handleError = function (error) {
2210
- alert('An unexpected error occured.');
2211
- console.log(error);
2212
- };
2213
- return AppErrorHandler;
2214
- }());
2215
-
2216
- var DinoFormsModule = /** @class */ (function () {
2217
- function DinoFormsModule() {
2218
- }
2219
- return DinoFormsModule;
2220
- }());
2221
- /** @nocollapse */ DinoFormsModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: DinoFormsModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
2222
- /** @nocollapse */ DinoFormsModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: DinoFormsModule, declarations: [FormComponent,
2223
- AlertComponent,
2224
- ExpressionsFormComponent,
2225
- AccordionFormComponent,
2226
- ModalFormComponent,
2227
- TabFormComponent], imports: [i2.CommonModule,
2228
- i2$1.FormsModule,
2229
- i2$1.ReactiveFormsModule,
2230
- platformBrowser.BrowserModule], exports: [FormComponent,
2231
- AlertComponent,
2232
- ExpressionsFormComponent,
2233
- AccordionFormComponent,
2234
- ModalFormComponent,
2235
- TabFormComponent] });
2236
- /** @nocollapse */ DinoFormsModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: DinoFormsModule, providers: [
2237
- { provide: i0.ErrorHandler, useClass: AppErrorHandler }
2238
- ], imports: [[
2239
- i2.CommonModule,
2240
- i2$1.FormsModule,
2241
- i2$1.ReactiveFormsModule,
2242
- platformBrowser.BrowserModule,
2243
- ]] });
2244
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: DinoFormsModule, decorators: [{
2245
- type: i0.NgModule,
2246
- args: [{
2247
- declarations: [
2248
- FormComponent,
2249
- AlertComponent,
2250
- ExpressionsFormComponent,
2251
- AccordionFormComponent,
2252
- ModalFormComponent,
2253
- TabFormComponent
2254
- ],
2255
- imports: [
2256
- i2.CommonModule,
2257
- i2$1.FormsModule,
2258
- i2$1.ReactiveFormsModule,
2259
- platformBrowser.BrowserModule,
2260
- ],
2261
- exports: [
2262
- FormComponent,
2263
- AlertComponent,
2264
- ExpressionsFormComponent,
2265
- AccordionFormComponent,
2266
- ModalFormComponent,
2267
- TabFormComponent
2268
- ],
2269
- providers: [
2270
- { provide: i0.ErrorHandler, useClass: AppErrorHandler }
2271
- ]
2272
- }]
2273
- }] });
2274
-
2275
- /*
2276
- * Public API Surface of dino-forms
2277
- */
2278
-
2279
- /**
2280
- * Generated bundle index. Do not edit.
2281
- */
2282
-
2283
- exports.AccordionFormComponent = AccordionFormComponent;
2284
- exports.AlertComponent = AlertComponent;
2285
- exports.DataService = DataService;
2286
- exports.DinoFormsModule = DinoFormsModule;
2287
- exports.ExpressionsFormComponent = ExpressionsFormComponent;
2288
- exports.FormComponent = FormComponent;
2289
- exports.ModalFormComponent = ModalFormComponent;
2290
- exports.TabFormComponent = TabFormComponent;
2291
-
2292
- Object.defineProperty(exports, '__esModule', { value: true });
2293
-
2294
- }));
2295
- //# sourceMappingURL=dino-forms.umd.js.map