@vgip/meta-ui 1.5.6 → 1.5.8

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 (98) hide show
  1. package/esm2020/lib/fieldAbstract.mjs +6 -6
  2. package/esm2020/lib/fieldComposite/index.mjs +65 -0
  3. package/esm2020/lib/fieldList/index.mjs +68 -0
  4. package/esm2020/lib/fieldReference/index.mjs +823 -0
  5. package/esm2020/lib/fieldSelect/index.mjs +488 -0
  6. package/esm2020/lib/index.mjs +10 -18
  7. package/esm2020/lib/layout/index.mjs +151 -0
  8. package/esm2020/lib/metaField/index.mjs +139 -0
  9. package/esm2020/lib/refDialog/index.mjs +127 -0
  10. package/esm2020/lib/resource/index.mjs +480 -0
  11. package/esm2020/lib/resourceCard/index.mjs +42 -0
  12. package/esm2020/lib/services/metaReference/index.mjs +2 -3
  13. package/fesm2015/vgip-meta-ui-fieldAbstract-2d0882f1.mjs +382 -0
  14. package/fesm2015/vgip-meta-ui-fieldAbstract-2d0882f1.mjs.map +1 -0
  15. package/fesm2015/vgip-meta-ui-index-0068fb77.mjs +368 -0
  16. package/fesm2015/vgip-meta-ui-index-0068fb77.mjs.map +1 -0
  17. package/fesm2015/vgip-meta-ui-index-3488da98.mjs +130 -0
  18. package/fesm2015/vgip-meta-ui-index-3488da98.mjs.map +1 -0
  19. package/fesm2015/vgip-meta-ui-index-4d489d76.mjs +71 -0
  20. package/fesm2015/vgip-meta-ui-index-4d489d76.mjs.map +1 -0
  21. package/fesm2015/vgip-meta-ui-index-5615e618.mjs +95 -0
  22. package/fesm2015/vgip-meta-ui-index-5615e618.mjs.map +1 -0
  23. package/fesm2015/vgip-meta-ui-index-65c10356.mjs +57 -0
  24. package/fesm2015/vgip-meta-ui-index-65c10356.mjs.map +1 -0
  25. package/fesm2015/vgip-meta-ui-index-6a77fa96.mjs +74 -0
  26. package/fesm2015/vgip-meta-ui-index-6a77fa96.mjs.map +1 -0
  27. package/fesm2015/vgip-meta-ui-index-6bd006d4.mjs +496 -0
  28. package/fesm2015/vgip-meta-ui-index-6bd006d4.mjs.map +1 -0
  29. package/fesm2015/vgip-meta-ui-index-8f5be5a7.mjs +24 -0
  30. package/fesm2015/vgip-meta-ui-index-8f5be5a7.mjs.map +1 -0
  31. package/fesm2015/vgip-meta-ui-index-92be02c0.mjs +145 -0
  32. package/fesm2015/vgip-meta-ui-index-92be02c0.mjs.map +1 -0
  33. package/fesm2015/vgip-meta-ui-index-934aeabf.mjs +68 -0
  34. package/fesm2015/vgip-meta-ui-index-934aeabf.mjs.map +1 -0
  35. package/fesm2015/vgip-meta-ui-index-9b5ee0c4.mjs +88 -0
  36. package/fesm2015/vgip-meta-ui-index-9b5ee0c4.mjs.map +1 -0
  37. package/fesm2015/vgip-meta-ui-index-a308ba4f.mjs +856 -0
  38. package/fesm2015/vgip-meta-ui-index-a308ba4f.mjs.map +1 -0
  39. package/fesm2015/vgip-meta-ui-index-def34ca9.mjs +1882 -0
  40. package/fesm2015/vgip-meta-ui-index-def34ca9.mjs.map +1 -0
  41. package/fesm2015/vgip-meta-ui-index-fa0b1b8b.mjs +460 -0
  42. package/fesm2015/vgip-meta-ui-index-fa0b1b8b.mjs.map +1 -0
  43. package/fesm2015/vgip-meta-ui-metaModel.pipe-725f401c.mjs +28 -0
  44. package/fesm2015/vgip-meta-ui-metaModel.pipe-725f401c.mjs.map +1 -0
  45. package/fesm2015/vgip-meta-ui-relativeTimeBuilder-31791ce4.mjs +51 -0
  46. package/fesm2015/vgip-meta-ui-relativeTimeBuilder-31791ce4.mjs.map +1 -0
  47. package/fesm2015/vgip-meta-ui.mjs +40 -5083
  48. package/fesm2015/vgip-meta-ui.mjs.map +1 -1
  49. package/fesm2020/vgip-meta-ui-fieldAbstract-2d0882f1.mjs +382 -0
  50. package/fesm2020/vgip-meta-ui-fieldAbstract-2d0882f1.mjs.map +1 -0
  51. package/fesm2020/vgip-meta-ui-index-0068fb77.mjs +368 -0
  52. package/fesm2020/vgip-meta-ui-index-0068fb77.mjs.map +1 -0
  53. package/fesm2020/vgip-meta-ui-index-3488da98.mjs +130 -0
  54. package/fesm2020/vgip-meta-ui-index-3488da98.mjs.map +1 -0
  55. package/fesm2020/vgip-meta-ui-index-3907f4b1.mjs +1879 -0
  56. package/fesm2020/vgip-meta-ui-index-3907f4b1.mjs.map +1 -0
  57. package/fesm2020/vgip-meta-ui-index-3d8c2fcd.mjs +856 -0
  58. package/fesm2020/vgip-meta-ui-index-3d8c2fcd.mjs.map +1 -0
  59. package/fesm2020/vgip-meta-ui-index-5615e618.mjs +95 -0
  60. package/fesm2020/vgip-meta-ui-index-5615e618.mjs.map +1 -0
  61. package/fesm2020/vgip-meta-ui-index-65c10356.mjs +57 -0
  62. package/fesm2020/vgip-meta-ui-index-65c10356.mjs.map +1 -0
  63. package/fesm2020/vgip-meta-ui-index-6f96198b.mjs +70 -0
  64. package/fesm2020/vgip-meta-ui-index-6f96198b.mjs.map +1 -0
  65. package/fesm2020/vgip-meta-ui-index-710246ac.mjs +73 -0
  66. package/fesm2020/vgip-meta-ui-index-710246ac.mjs.map +1 -0
  67. package/fesm2020/vgip-meta-ui-index-8f5be5a7.mjs +24 -0
  68. package/fesm2020/vgip-meta-ui-index-8f5be5a7.mjs.map +1 -0
  69. package/fesm2020/vgip-meta-ui-index-934aeabf.mjs +68 -0
  70. package/fesm2020/vgip-meta-ui-index-934aeabf.mjs.map +1 -0
  71. package/fesm2020/vgip-meta-ui-index-9b5ee0c4.mjs +88 -0
  72. package/fesm2020/vgip-meta-ui-index-9b5ee0c4.mjs.map +1 -0
  73. package/fesm2020/vgip-meta-ui-index-e743527e.mjs +495 -0
  74. package/fesm2020/vgip-meta-ui-index-e743527e.mjs.map +1 -0
  75. package/fesm2020/vgip-meta-ui-index-e8e3b16a.mjs +142 -0
  76. package/fesm2020/vgip-meta-ui-index-e8e3b16a.mjs.map +1 -0
  77. package/fesm2020/vgip-meta-ui-index-fa0b1b8b.mjs +460 -0
  78. package/fesm2020/vgip-meta-ui-index-fa0b1b8b.mjs.map +1 -0
  79. package/fesm2020/vgip-meta-ui-metaModel.pipe-725f401c.mjs +28 -0
  80. package/fesm2020/vgip-meta-ui-metaModel.pipe-725f401c.mjs.map +1 -0
  81. package/fesm2020/vgip-meta-ui-relativeTimeBuilder-31791ce4.mjs +51 -0
  82. package/fesm2020/vgip-meta-ui-relativeTimeBuilder-31791ce4.mjs.map +1 -0
  83. package/fesm2020/vgip-meta-ui.mjs +39 -5083
  84. package/fesm2020/vgip-meta-ui.mjs.map +1 -1
  85. package/lib/fieldComposite/index.d.ts +12 -0
  86. package/lib/fieldList/index.d.ts +14 -0
  87. package/lib/fieldReference/index.d.ts +73 -0
  88. package/lib/fieldSelect/index.d.ts +48 -0
  89. package/lib/index.d.ts +31 -23
  90. package/lib/layout/index.d.ts +39 -0
  91. package/lib/metaField/index.d.ts +26 -0
  92. package/lib/refDialog/index.d.ts +33 -0
  93. package/lib/resource/index.d.ts +58 -0
  94. package/lib/resourceCard/index.d.ts +18 -0
  95. package/lib/services/metaReference/index.d.ts +1 -1
  96. package/package.json +1 -1
  97. package/esm2020/lib/field.mjs +0 -2325
  98. package/lib/field.d.ts +0 -292
@@ -0,0 +1,1879 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, Component, Input, Directive, EventEmitter, Output } from '@angular/core';
3
+ import { a as metaDark, m as metaLight } from './vgip-meta-ui-fieldAbstract-2d0882f1.mjs';
4
+ import * as i1$2 from '@angular/common';
5
+ import { M as MetaContextService, t as templateBuilder } from './vgip-meta-ui-index-3488da98.mjs';
6
+ import * as i1 from '@angular/common/http';
7
+ import { HttpParams, HttpHeaders } from '@angular/common/http';
8
+ import * as i2 from '@angular/forms';
9
+ import { Observable, Subject } from 'rxjs';
10
+ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
11
+ import * as i1$1 from '@angular/router';
12
+ import { M as MetaField } from './vgip-meta-ui-index-e8e3b16a.mjs';
13
+
14
+ const numberFieldNormalizer = (field) => {
15
+ const f = {
16
+ label: field.label,
17
+ name: field.name
18
+ };
19
+ f.type = field.name ? 'number' : 'missing name';
20
+ return f;
21
+ };
22
+
23
+ const optionsFieldNormalizer = (field) => {
24
+ const f = {
25
+ label: field.label,
26
+ name: field.name,
27
+ options: field.options || []
28
+ };
29
+ if (field.dependentPicklist && field.controllerName) {
30
+ const enabled = {};
31
+ enabled[field.controllerName] = true;
32
+ f.enabled = enabled;
33
+ }
34
+ if (field.picklist) {
35
+ for (const o of field.picklist) {
36
+ const opt = {
37
+ id: o.name || o.id,
38
+ label: o.label
39
+ };
40
+ if (field.for) {
41
+ opt.for = field.for;
42
+ }
43
+ if (o.validFor && field.controllerName) {
44
+ const validFor = {};
45
+ validFor[field.controllerName] = o.validFor;
46
+ opt.for = validFor;
47
+ }
48
+ f.options.push(opt);
49
+ if (o.defaultValue && !field.default) {
50
+ f.default = opt.id;
51
+ }
52
+ }
53
+ }
54
+ f.type = field.name ? 'select' : 'missing name';
55
+ if (field.type === 'multipicklist') {
56
+ f.multiple = true;
57
+ }
58
+ if (field.reference) {
59
+ f.reference = field.reference;
60
+ }
61
+ if (field.searchUrl || field.searchParams) {
62
+ f.search = {
63
+ url: field.searchUrl,
64
+ params: field.searchParams
65
+ };
66
+ }
67
+ else if (field.search) {
68
+ f.search = field.search;
69
+ }
70
+ return f;
71
+ };
72
+
73
+ const stringFieldNormalizer = (field) => {
74
+ const f = {
75
+ label: field.label,
76
+ name: field.name
77
+ };
78
+ f.type = field.name ? 'string' : 'missing name';
79
+ if (field.subtype) {
80
+ f.subtype = field.subtype;
81
+ }
82
+ if (field.picklist || field.options) {
83
+ f.suggestions = (field.picklist || field.options || []).map((s) => {
84
+ if (s.defaultValue) {
85
+ f.default = s.label || s.name || s.id || s;
86
+ }
87
+ return {
88
+ id: s.id,
89
+ label: s.label,
90
+ name: s.name
91
+ };
92
+ });
93
+ }
94
+ return f;
95
+ };
96
+
97
+ const booleanFieldNormalizer = (field) => {
98
+ const f = {
99
+ label: field.label,
100
+ name: field.name
101
+ };
102
+ if (field.subtype) {
103
+ f.subtype = field.subtype;
104
+ }
105
+ f.type = field.name ? 'boolean' : 'missing name';
106
+ return f;
107
+ };
108
+
109
+ /*
110
+ * @Author: Alexander.Vangelov@vonage.com
111
+ * @Date: 2021-03-22 17:09:52
112
+ * @Last Modified by: Alexander.Vangelov@vonage.com
113
+ * @Last Modified time: 2021-03-22 17:09:52
114
+ */
115
+ const textFieldNormalizer = (field) => {
116
+ const f = {
117
+ label: field.label,
118
+ name: field.name
119
+ };
120
+ f.type = field.name ? 'text' : 'missing name';
121
+ return f;
122
+ };
123
+
124
+ const datetimeFieldNormalizer = (field) => {
125
+ const f = {
126
+ label: field.label,
127
+ name: field.name
128
+ };
129
+ f.type = field.name ? (field.type || '').toLowerCase() : 'missing name';
130
+ return f;
131
+ };
132
+
133
+ const referenceFieldNormalizer = (field) => {
134
+ const f = {
135
+ type: field.name ? 'reference' : 'missing name',
136
+ label: field.label,
137
+ name: field.name
138
+ };
139
+ f.type = field.name ? 'reference' : 'missing name';
140
+ if (field.reference) {
141
+ if (field.reference instanceof Array && field.reference.length === 1) {
142
+ f.reference = field.reference[0];
143
+ }
144
+ else {
145
+ f.reference = field.reference;
146
+ }
147
+ }
148
+ else if (field.references) {
149
+ f.references = field.references;
150
+ }
151
+ if (field.acceptNew) {
152
+ f.acceptNew = field.acceptNew;
153
+ }
154
+ if (field.searchLabel) {
155
+ f.searchLabel = field.searchLabel;
156
+ }
157
+ if (field.searchUrl || field.searchParams) {
158
+ f.search = {
159
+ url: field.searchUrl,
160
+ params: field.searchParams
161
+ };
162
+ }
163
+ else if (field.search) {
164
+ f.search = field.search;
165
+ }
166
+ return f;
167
+ };
168
+
169
+ const radioFieldNormalizer = (field) => {
170
+ const f = {
171
+ label: field.label,
172
+ name: field.name,
173
+ options: field.options || []
174
+ };
175
+ f.type = field.name ? 'radio' : 'missing name';
176
+ if (field.picklist) {
177
+ for (const o of field.picklist) {
178
+ const opt = {
179
+ id: o.name || o.id,
180
+ label: o.label
181
+ };
182
+ if (field.for) {
183
+ opt.for = field.for;
184
+ }
185
+ if (o.validFor && field.controllerName) {
186
+ const validFor = {};
187
+ validFor[field.controllerName] = o.validFor;
188
+ opt.for = validFor;
189
+ }
190
+ f.options.push(opt);
191
+ if (o.defaultValue && !field.default) {
192
+ f.default = opt.id;
193
+ }
194
+ }
195
+ }
196
+ return f;
197
+ };
198
+
199
+ /*
200
+ * @Author: Alexander.Vangelov@vonage.com
201
+ * @Date: 2019-09-19 17:34:34
202
+ * @Last Modified by: Alexander.Vangelov@vonage.com
203
+ * @Last Modified time: 2021-03-22 17:11:01
204
+ */
205
+ const richtextFieldNormalizer = (field) => {
206
+ const f = {
207
+ label: field.label,
208
+ name: field.name
209
+ };
210
+ f.type = field.name ? 'richtext' : 'missing name';
211
+ return f;
212
+ };
213
+
214
+ /*
215
+ * @Author: Alexander.Vangelov@vonage.com
216
+ * @Date: 2021-03-22 17:09:12
217
+ * @Last Modified by: Alexander.Vangelov@vonage.com
218
+ * @Last Modified time: 2021-03-22 17:09:12
219
+ */
220
+ const uniqueNameFilter = (fields, uniqFieldNames, allowDuplicates = false) => {
221
+ if (fields instanceof Array) {
222
+ return allowDuplicates ? fields : fields.filter((f) => {
223
+ if (f.name) {
224
+ if (uniqFieldNames.indexOf(f.name) !== -1) {
225
+ return false;
226
+ }
227
+ uniqFieldNames.push(f.name);
228
+ }
229
+ return true;
230
+ });
231
+ }
232
+ else {
233
+ return fields;
234
+ }
235
+ };
236
+
237
+ /*
238
+ * @Author: Alexander.Vangelov@vonage.com
239
+ * @Date: 2019-09-19 17:34:34
240
+ * @Last Modified by: Alexander.Vangelov@vonage.com
241
+ * @Last Modified time: 2021-03-22 17:13:53
242
+ */
243
+ const fieldNormalizer = (field, uniqFieldNames) => {
244
+ if (!field) {
245
+ return;
246
+ }
247
+ let f = {
248
+ validations: {}
249
+ };
250
+ const fieldType = (field.type || '').toLowerCase();
251
+ if (['int', 'integer', 'number', 'double', 'float', 'bigdecimal', 'percent', 'currency'].indexOf(fieldType) !== -1) {
252
+ f = numberFieldNormalizer(field);
253
+ }
254
+ else if (['picklist', 'select', 'multipicklist', 'options'].indexOf(fieldType) !== -1) {
255
+ f = optionsFieldNormalizer(field);
256
+ }
257
+ else if (['string', null, undefined, '', 'email', 'phone', 'url', 'combobox'].indexOf(fieldType) !== -1) {
258
+ f = stringFieldNormalizer(field);
259
+ }
260
+ else if (['bool', 'boolean', 'checkbox', 'switch'].indexOf(fieldType) !== -1) {
261
+ f = booleanFieldNormalizer(field);
262
+ }
263
+ else if (['text', 'textarea'].indexOf(fieldType) !== -1) {
264
+ f = textFieldNormalizer(field);
265
+ }
266
+ else if (['richtext'].indexOf(fieldType) !== -1) {
267
+ f = richtextFieldNormalizer(field);
268
+ }
269
+ else if (['date', 'time', 'datetime', 'datetime-local'].indexOf(fieldType) !== -1) {
270
+ f = datetimeFieldNormalizer(field);
271
+ }
272
+ else if (['reference', 'references', 'multireference'].indexOf(fieldType) !== -1) {
273
+ f = referenceFieldNormalizer(field);
274
+ }
275
+ else if (['radio'].indexOf(fieldType) !== -1) {
276
+ f = radioFieldNormalizer(field);
277
+ }
278
+ else if (fieldType === 'composite') {
279
+ f = {
280
+ type: 'composite',
281
+ label: field.label,
282
+ name: field.name,
283
+ fields: uniqueNameFilter(field.fields || field.reference || [], uniqFieldNames, (typeof (field.name) !== 'undefined')).map((v) => fieldNormalizer(v, uniqFieldNames))
284
+ };
285
+ if (field.subtype) {
286
+ f.subtype = field.subtype;
287
+ }
288
+ }
289
+ else if (fieldType === 'list') {
290
+ const list = field.list || field.reference;
291
+ f = {
292
+ type: field.name ? 'list' : 'missing name',
293
+ label: field.label,
294
+ name: field.name,
295
+ list: fieldNormalizer(uniqueNameFilter(list, uniqFieldNames), field.name ? [] : uniqFieldNames)
296
+ };
297
+ if (field.selectable) {
298
+ f.selectable = field.selectable;
299
+ }
300
+ if (field.resourceType) {
301
+ f.resourceType = field.resourceType;
302
+ }
303
+ }
304
+ else {
305
+ f = {
306
+ label: field.label,
307
+ name: field.name,
308
+ type: `@v2 ${fieldType}`
309
+ };
310
+ }
311
+ if (field.validations) {
312
+ f.validations = field.validations;
313
+ }
314
+ if (field.auto) {
315
+ f.auto = field.auto;
316
+ }
317
+ if ((field.default || field.defaultValue) && !f.default) {
318
+ const d = field.default || field.defaultValue;
319
+ if (Array.isArray(d)) {
320
+ f.default = [];
321
+ for (const v of d) {
322
+ if (typeof (v) === 'object' && v !== null) {
323
+ const o = {
324
+ id: v.id || v.value || v.name || v.label,
325
+ label: v.label || 'N/A'
326
+ };
327
+ if (v.type) {
328
+ o.type = v.type;
329
+ }
330
+ if (!v.type && f.reference && f.reference.name) { // Bullhorn CAND PT bad metadata
331
+ o.type = f.reference.name;
332
+ }
333
+ f.default.push(o);
334
+ }
335
+ else {
336
+ f.default = v;
337
+ }
338
+ }
339
+ }
340
+ else if (typeof (d) === 'object' && d !== null) {
341
+ if (field.type === 'boolean' && typeof (d.value) === 'boolean') {
342
+ f.default = d.value;
343
+ }
344
+ else if (Object.keys(d).length) {
345
+ const id = d.id || d.value || d.name || d.label;
346
+ if (id) {
347
+ f.default = {
348
+ id: d.id || d.value || d.name || d.label,
349
+ label: d.label || 'N/A'
350
+ };
351
+ }
352
+ if (d.type) {
353
+ f.default.type = d.type;
354
+ }
355
+ }
356
+ }
357
+ else {
358
+ f.default = d;
359
+ }
360
+ }
361
+ if (field.visible || field.alwaysVisible) {
362
+ f.visible = field.visible || field.alwaysVisible;
363
+ }
364
+ if (field.hidden) {
365
+ f.hidden = field.hidden;
366
+ }
367
+ if (field.hint || field.helpText) {
368
+ f.hint = field.hint || field.helpText;
369
+ }
370
+ if (field.valueType) {
371
+ f.valueType = field.valueType;
372
+ }
373
+ if (field.multiple) {
374
+ f.multiple = field.multiple;
375
+ }
376
+ if (field.suggestions && field.suggestions.length) {
377
+ f.suggestions = field.suggestions;
378
+ }
379
+ if (field.updateable === false || field.updatable === false) {
380
+ if (!f.flags) {
381
+ f.flags = { updatable: false };
382
+ }
383
+ else {
384
+ f.flags.updatable = false;
385
+ }
386
+ }
387
+ if (field.createable === false || field.creatable === false) {
388
+ if (!f.flags) {
389
+ f.flags = { creatable: false };
390
+ }
391
+ else {
392
+ f.flags.creatable = false;
393
+ }
394
+ }
395
+ if (typeof (field.enabled) !== 'undefined') {
396
+ f.enabled = field.enabled;
397
+ }
398
+ if (typeof (field.disabled) !== 'undefined') {
399
+ f.disabled = field.disabled;
400
+ }
401
+ return f;
402
+ };
403
+
404
+ /*
405
+ * @Author: Alexander.Vangelov@vonage.com
406
+ * @Date: 2019-09-19 17:34:49
407
+ * @Last Modified by: Alexander.Vangelov@vonage.com
408
+ * @Last Modified time: 2023-02-10 09:44:59
409
+ */
410
+ const sortObj = (obj) => {
411
+ if (typeof (obj) !== 'object' || obj === null) {
412
+ return obj;
413
+ }
414
+ if (Array.isArray(obj)) {
415
+ return obj.map((e) => sortObj(e)).sort();
416
+ }
417
+ return Object.keys(obj).sort().reduce((sorted, k) => {
418
+ sorted[k] = sortObj(obj[k]);
419
+ return sorted;
420
+ }, {});
421
+ };
422
+ const metaNormalizer = (meta, integration, resourceType) => {
423
+ const uniqFieldNames = [];
424
+ const integrationCode = (integration || '').toUpperCase();
425
+ const metaV3 = {
426
+ integration,
427
+ resourceType,
428
+ availableLayouts: meta.availableLayouts,
429
+ layout: {
430
+ id: meta.layout.id,
431
+ name: meta.layout.name,
432
+ label: meta.layout.label,
433
+ version: '3.0.0',
434
+ sections: (meta.layout.sections || []).map((s) => {
435
+ const section = {
436
+ label: s.label,
437
+ fields: uniqueNameFilter(s.fields || [], uniqFieldNames).map((v) => fieldNormalizer(v, uniqFieldNames)) // VIST-424
438
+ };
439
+ if (s.visible || s.alwaysVisible) {
440
+ section.visible = s.visible || s.alwaysVisible;
441
+ }
442
+ return section;
443
+ })
444
+ }
445
+ };
446
+ if (meta.layout.origLayoutId) {
447
+ metaV3.layout.origLayoutId = meta.layout.origLayoutId;
448
+ }
449
+ if (meta.drafts) {
450
+ metaV3.drafts = meta.drafts;
451
+ }
452
+ if (meta.layout.children) {
453
+ metaV3.layout.children = meta.layout.children;
454
+ }
455
+ const fieldFixesByIntegration = (f) => {
456
+ if (f.type === 'boolean' && ((typeof (f.default) !== 'boolean') && f.default && !f.default.value)) {
457
+ delete f.default;
458
+ }
459
+ else if (f.type === 'reference') {
460
+ const references = (f.reference instanceof Array) ? f.reference : [f.reference];
461
+ for (const r of references) {
462
+ if (r && r.creatable === false && typeof (r.updatable) === 'undefined') {
463
+ r.updatable = false; // User missing updatable, may be other too
464
+ }
465
+ }
466
+ }
467
+ switch (integrationCode) {
468
+ case 'BULLHORN': {
469
+ if (resourceType === 'Appointment') {
470
+ if (['dateBegin', 'dateEnd'].indexOf(f.name) !== -1) {
471
+ if (!f.validations) {
472
+ f.validations = { step: 1800 };
473
+ }
474
+ else {
475
+ f.validations.step = 1800;
476
+ }
477
+ f.default = f.name === 'dateBegin' ? 'now' : '30.minutes';
478
+ if (!f.auto) {
479
+ f.auto = {};
480
+ }
481
+ f.auto[f.name === 'dateBegin' ? 'lt' : 'gt'] = {
482
+ against: f.name === 'dateBegin' ? 'dateEnd' : 'dateBegin',
483
+ offset: `${f.name === 'dateBegin' ? '-30' : '30'}.minutes`
484
+ };
485
+ }
486
+ }
487
+ if (f.name === 'comments') {
488
+ if (!f.validations) {
489
+ f.valudations = { required: true };
490
+ }
491
+ else {
492
+ f.validations.required = true;
493
+ }
494
+ if (resourceType === 'Note') {
495
+ f.type = 'richtext';
496
+ }
497
+ }
498
+ if (f.name === 'address.state') {
499
+ f.creatable = false;
500
+ f.updatable = false;
501
+ }
502
+ break;
503
+ }
504
+ case 'GOOGLE': {
505
+ if (f.name === 'contactId') {
506
+ f.label = 'Contact';
507
+ }
508
+ else if (['start', 'end'].indexOf(f.name) !== -1) {
509
+ if (!f.auto) {
510
+ f.auto = {};
511
+ }
512
+ f.auto[f.name === 'start' ? 'lt' : 'gt'] = {
513
+ against: f.name === 'start' ? 'end' : 'start',
514
+ offset: `${f.name === 'start' ? '-30' : '30'}.minutes`
515
+ };
516
+ }
517
+ break;
518
+ }
519
+ case 'OFFICE365': {
520
+ if (resourceType === 'Events') {
521
+ if (['start', 'end'].indexOf(f.name) !== -1) {
522
+ if (!f.validations) {
523
+ f.validations = { step: 1800 };
524
+ }
525
+ else {
526
+ f.validations.step = 1800;
527
+ }
528
+ f.default = f.name === 'start' ? 'now' : '30.minutes';
529
+ }
530
+ }
531
+ if (resourceType === 'Tasks' && f.name === 'checklist') {
532
+ f.creatable = false;
533
+ }
534
+ if (f.name === 'description' && resourceType !== 'Tasks') {
535
+ f.type = 'richtext';
536
+ }
537
+ else if (f.name === 'content') {
538
+ f.type = 'text';
539
+ }
540
+ break;
541
+ }
542
+ case 'SALESFORCE': {
543
+ if (resourceType === 'Task' && f.name === 'WhatId') {
544
+ f.disabled = {
545
+ 'WhoId.type': 'Lead' // eslint-disable-line @typescript-eslint/naming-convention
546
+ };
547
+ }
548
+ if (['Description', 'ParentId'].indexOf(f.name) !== -1) {
549
+ if (!f.visible) {
550
+ f.visible = true;
551
+ }
552
+ }
553
+ if (f.type === 'reference') {
554
+ const references = (f.reference instanceof Array) ? f.reference : [f.reference];
555
+ for (const r of references) {
556
+ if (r && ['Account'].indexOf(r.name) !== -1) { // force creatable
557
+ r.creatable = true;
558
+ r.updatable = true;
559
+ }
560
+ }
561
+ }
562
+ break;
563
+ }
564
+ case 'SUGAR': {
565
+ if (['description', 'parent_id', 'contact_id', 'contacts'].indexOf(f.name) !== -1) {
566
+ if (!f.visible) {
567
+ f.visible = true;
568
+ }
569
+ }
570
+ if (f.type === 'reference') {
571
+ const references = (f.reference instanceof Array) ? f.reference : [f.reference];
572
+ for (const r of references) {
573
+ if (r && ['Accounts', 'Contacts', 'Leads'].indexOf(r.name) !== -1) {
574
+ r.label = r.name.slice(0, -1); // Use singular labels
575
+ r.creatable = true;
576
+ r.updatable = true;
577
+ }
578
+ }
579
+ }
580
+ break;
581
+ }
582
+ case 'ZENDESK': {
583
+ if (resourceType === 'Ticket' && f.name === 'assignee') {
584
+ f.reference.updatable = false;
585
+ }
586
+ break;
587
+ }
588
+ case 'HUBSPOT': {
589
+ if (resourceType === 'LogCall' && f.name === 'body') {
590
+ f.type = 'richtext';
591
+ }
592
+ break;
593
+ }
594
+ case 'NETSUITE': {
595
+ if (f.name === 'company' && !f.auto) {
596
+ f.auto = {
597
+ search: {
598
+ params: {
599
+ contactId: 'contact.id'
600
+ },
601
+ url: '../Contact/${contactId}?expand=company',
602
+ extract: 'company'
603
+ }
604
+ };
605
+ }
606
+ break;
607
+ }
608
+ }
609
+ if (f.type === 'composite' && f.fields) {
610
+ for (const ff of f.fields) {
611
+ fieldFixesByIntegration(ff);
612
+ }
613
+ }
614
+ };
615
+ // common fixes for all integrations
616
+ if (metaV3.layout.sections.length) {
617
+ for (const s of (metaV3.layout.sections)) {
618
+ if (!s || !s.fields) {
619
+ break;
620
+ }
621
+ for (const f of s.fields) {
622
+ fieldFixesByIntegration(f);
623
+ }
624
+ }
625
+ }
626
+ // Google Gmail children enhancement
627
+ if (integrationCode === 'GOOGLE') {
628
+ if (resourceType === 'Mail') {
629
+ metaV3.layout.editable = false;
630
+ if (!metaV3.layout.children) {
631
+ metaV3.layout.children = [{
632
+ label: 'Comments',
633
+ name: 'comments',
634
+ reference: {
635
+ resourceType: 'Comment',
636
+ label: 'Comment',
637
+ editable: false
638
+ }
639
+ }];
640
+ }
641
+ }
642
+ else if (resourceType === 'Task') {
643
+ if (!metaV3.layout.children) {
644
+ metaV3.layout.children = [{
645
+ label: 'Subtasks',
646
+ name: 'subTasks',
647
+ reference: {
648
+ resourceType: 'Subtask',
649
+ label: 'Subtask'
650
+ }
651
+ }];
652
+ }
653
+ }
654
+ else if (resourceType === 'Comment') {
655
+ metaV3.layout.editable = false;
656
+ }
657
+ }
658
+ else if (integrationCode === 'ZENDESK') {
659
+ if (resourceType === 'Ticket') {
660
+ if (!metaV3.layout.children) {
661
+ metaV3.layout.children = [{
662
+ label: 'Comments',
663
+ name: 'comments',
664
+ reference: {
665
+ resourceType: 'Comment',
666
+ label: 'Comment',
667
+ editable: false
668
+ }
669
+ }];
670
+ }
671
+ }
672
+ else if (resourceType === 'Comment') {
673
+ metaV3.layout.editable = false;
674
+ }
675
+ }
676
+ else if (integrationCode === 'MSDYNAMICS' && !metaV3.fieldsMap) {
677
+ if (resourceType === 'phonecall') {
678
+ metaV3.fieldsMap = {
679
+ contactables: ['from', 'to'],
680
+ subject: 'subject',
681
+ phoneNumber: 'phonenumber',
682
+ };
683
+ }
684
+ else if (resourceType === 'contact') {
685
+ metaV3.fieldsMap = {
686
+ phoneNumber: 'telephone1',
687
+ firstName: 'firstname',
688
+ lastName: 'lastname'
689
+ };
690
+ }
691
+ else if (resourceType === 'account') {
692
+ metaV3.fieldsMap = {
693
+ phoneNumber: 'telephone1',
694
+ displayName: 'name'
695
+ };
696
+ }
697
+ }
698
+ else if (integrationCode === 'OFFICE365') {
699
+ if (resourceType === 'Conversations') {
700
+ metaV3.layout.editable = false;
701
+ metaV3.layout.children = [{
702
+ label: 'Comments',
703
+ name: 'comments',
704
+ reference: {
705
+ resourceType: 'Comment',
706
+ label: 'Comment',
707
+ editable: false
708
+ }
709
+ }];
710
+ }
711
+ else if (resourceType === 'Comment') {
712
+ metaV3.layout.editable = false;
713
+ }
714
+ }
715
+ else if (integrationCode === 'JOBDIVA') {
716
+ if (resourceType === 'CandidateNote' || resourceType === 'ContactNote') {
717
+ metaV3.layout.editable = false;
718
+ }
719
+ }
720
+ return sortObj(metaV3);
721
+ };
722
+
723
+ /*
724
+ * @Author: Alexander.Vangelov@vonage.com
725
+ * @Date: 2019-09-19 17:35:19
726
+ * @Last Modified by: Alexander.Vangelov@vonage.com
727
+ * @Last Modified time: 2019-11-22 14:57:07
728
+ */
729
+ class MetaHttpClient {
730
+ constructor(httpClient) {
731
+ this.httpClient = httpClient;
732
+ }
733
+ delete(url, queryParams = {}) {
734
+ const options = this.prepareOptions(queryParams);
735
+ return this.httpClient.delete(`${this.constructUrl(url)}`, options);
736
+ }
737
+ get(url, queryParams = {}) {
738
+ const options = this.prepareOptions(queryParams);
739
+ return this.httpClient.get(`${this.constructUrl(url)}`, options);
740
+ }
741
+ post(url, body, queryParams = {}) {
742
+ const options = this.prepareOptions(queryParams);
743
+ return this.httpClient.post(`${this.constructUrl(url)}`, body, options);
744
+ }
745
+ put(url, body, queryParams = {}) {
746
+ const options = this.prepareOptions(queryParams);
747
+ return this.httpClient.put(`${this.constructUrl(url)}`, body, options);
748
+ }
749
+ patch(url, body, queryParams = {}) {
750
+ const options = this.prepareOptions(queryParams);
751
+ return this.httpClient.patch(`${this.constructUrl(url)}`, body, options);
752
+ }
753
+ constructUrl(path) {
754
+ return /^http/.test(path) ? path : `${path}`;
755
+ }
756
+ prepareOptions(queryParams) {
757
+ Object.keys(queryParams).forEach(key => {
758
+ if (queryParams[key] == null || queryParams[key] === '') {
759
+ delete queryParams[key];
760
+ }
761
+ });
762
+ const params = new HttpParams({
763
+ fromObject: queryParams
764
+ });
765
+ const options = {
766
+ headers: new HttpHeaders({
767
+ Accept: 'application/json' // eslint-disable-line @typescript-eslint/naming-convention
768
+ }),
769
+ params
770
+ };
771
+ return options;
772
+ }
773
+ }
774
+ MetaHttpClient.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: MetaHttpClient, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
775
+ MetaHttpClient.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: MetaHttpClient, providedIn: 'root' });
776
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: MetaHttpClient, decorators: [{
777
+ type: Injectable,
778
+ args: [{
779
+ providedIn: 'root'
780
+ }]
781
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }]; } });
782
+
783
+ /*
784
+ * @Author: Alexander.Vangelov@vonage.com
785
+ * @Date: 2019-09-19 17:35:19
786
+ * @Last Modified by: Alexander.Vangelov@vonage.com
787
+ * @Last Modified time: 2020-08-10 22:35:31
788
+ */
789
+ const STORAGE_PARAMS_REGEXES = {
790
+ localStorage: /^localStorage\.(.*)/,
791
+ sessionStorage: /^sessionStorage\.(.*)/,
792
+ };
793
+ const INTEGRATION_URL_TEMPLATE = '/extensions/v2/accounts/${localStorage.vgis.accountId}/users/${localStorage.vgis.userId}/connectors/${integrationCode}';
794
+ const RESOURCE_URL_TEMPLATE = INTEGRATION_URL_TEMPLATE + '${parentsPath}/${resourceType}';
795
+ const NEW_RESOURCE_URL_TEMPLATE = INTEGRATION_URL_TEMPLATE + '${parentsPath}/resources/${resourceType}';
796
+ class IMetaParentConfig {
797
+ }
798
+ class IMetaResourceConfig {
799
+ }
800
+ class MetaResourceService {
801
+ constructor(httpClient) {
802
+ this.httpClient = httpClient;
803
+ }
804
+ setConfig(config) {
805
+ this.baseIntegrationUrl = INTEGRATION_URL_TEMPLATE.replace(/\${\s*([\w\.]+)\s*}/g, (m, value) => {
806
+ for (const storage of Object.keys(STORAGE_PARAMS_REGEXES)) {
807
+ const match = value.match(STORAGE_PARAMS_REGEXES[storage]);
808
+ if (match) {
809
+ return window[storage].getItem(match[1]) || window[storage].getItem(`cti.${match[1]}`);
810
+ }
811
+ }
812
+ return config[value];
813
+ });
814
+ this.baseResourceUrl = RESOURCE_URL_TEMPLATE.replace(/\${\s*([\w\.]+)\s*}/g, (m, value) => {
815
+ for (const storage of Object.keys(STORAGE_PARAMS_REGEXES)) {
816
+ const match = value.match(STORAGE_PARAMS_REGEXES[storage]);
817
+ if (match) {
818
+ return window[storage].getItem(match[1]) || window[storage].getItem(`cti.${match[1]}`);
819
+ }
820
+ }
821
+ if (value === 'parentsPath') {
822
+ let parentsPath = '';
823
+ if (config.parent) { // config.parent: { resourceType: '...', id: '...', parent: {...} }
824
+ let rootParent = config.parent;
825
+ while (rootParent) {
826
+ parentsPath += `/${rootParent.resourceType || rootParent.type}/${rootParent.externalId || rootParent.id}`;
827
+ rootParent = rootParent.parent;
828
+ }
829
+ }
830
+ return parentsPath;
831
+ }
832
+ else {
833
+ return config[value];
834
+ }
835
+ });
836
+ this.newResourceUrl = NEW_RESOURCE_URL_TEMPLATE.replace(/\${\s*([\w\.]+)\s*}/g, (m, value) => {
837
+ for (const storage of Object.keys(STORAGE_PARAMS_REGEXES)) {
838
+ const match = value.match(STORAGE_PARAMS_REGEXES[storage]);
839
+ if (match) {
840
+ return window[storage].getItem(match[1]);
841
+ }
842
+ }
843
+ if (value === 'parentsPath') {
844
+ let parentsPath = '';
845
+ if (config.parent) { // config.parent: { resourceType: '...', id: '...', parent: {...} }
846
+ let rootParent = config.parent;
847
+ while (rootParent) {
848
+ parentsPath += `/${rootParent.resourceType || rootParent.type}/${rootParent.externalId || rootParent.id}`;
849
+ rootParent = rootParent.parent;
850
+ }
851
+ }
852
+ return parentsPath;
853
+ }
854
+ else {
855
+ return config[value];
856
+ }
857
+ });
858
+ this.id = config.externalId;
859
+ }
860
+ new(config) {
861
+ const s = new MetaResourceService(this.httpClient);
862
+ s.setConfig(config);
863
+ return s;
864
+ }
865
+ searchIntegration(query, scope) {
866
+ let searchUrl = `${this.baseIntegrationUrl}/search?q=${encodeURIComponent(query)}`;
867
+ if (scope) {
868
+ searchUrl += `&scope=${encodeURIComponent(scope)}`;
869
+ }
870
+ return this.httpClient.get(searchUrl);
871
+ }
872
+ getMetadata(layoutId, refresh) {
873
+ let url = `${this.baseResourceUrl.replace('/v2/', '/v3/')}/metadata`;
874
+ url += `?t=${new Date().getTime()}`;
875
+ if (refresh) {
876
+ url += '&refresh=true';
877
+ }
878
+ if (layoutId) {
879
+ url += `&layoutId=${layoutId}`;
880
+ }
881
+ return this.httpClient.get(url);
882
+ }
883
+ getDetails(externalId, extraParams) {
884
+ let params = 'referenceDetails=true';
885
+ if (extraParams) {
886
+ for (const p in extraParams) {
887
+ if (extraParams[p]) {
888
+ params += `&${p}=${extraParams[p]}`;
889
+ }
890
+ }
891
+ }
892
+ return this.httpClient.get(`${this.baseResourceUrl}/${externalId}?${params}`);
893
+ }
894
+ getByPath(path) {
895
+ let fullPath = `${this.newResourceUrl}${path}`;
896
+ if (/^..\//.test(path)) {
897
+ fullPath = `${this.baseIntegrationUrl}${path.substring(2)}`;
898
+ }
899
+ return this.httpClient.get(fullPath);
900
+ }
901
+ save(payload) {
902
+ if (this.id) {
903
+ return this.httpClient.put(`${this.baseResourceUrl}/${this.id}`, payload);
904
+ }
905
+ else {
906
+ return this.httpClient.post(`${this.baseResourceUrl}`, payload);
907
+ }
908
+ }
909
+ }
910
+ MetaResourceService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: MetaResourceService, deps: [{ token: MetaHttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
911
+ MetaResourceService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: MetaResourceService, providedIn: 'root' });
912
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: MetaResourceService, decorators: [{
913
+ type: Injectable,
914
+ args: [{
915
+ providedIn: 'root'
916
+ }]
917
+ }], ctorParameters: function () { return [{ type: MetaHttpClient }]; } });
918
+
919
+ /*
920
+ * @Author: Alexander.Vangelov@vonage.com
921
+ * @Date: 2019-09-19 17:35:19
922
+ * @Last Modified by: Alexander.Vangelov@vonage.com
923
+ * @Last Modified time: 2020-05-03 21:31:16
924
+ */
925
+ class MetaMsgService {
926
+ constructor(metaContext) {
927
+ this.metaContext = metaContext;
928
+ this.msgCallbacks = {}; // message subscribers holder
929
+ this.msgListeneres = []; // ensure listener is registerd only once
930
+ this.workerMsgListener = (msg) => {
931
+ if (msg && msg.data && msg.data.action && msg.data.$state) {
932
+ const state = msg.data.$state;
933
+ const callback = this.msgCallbacks[state]; // original requester callback
934
+ if (callback) {
935
+ delete msg.data.$state;
936
+ callback(msg.data);
937
+ }
938
+ delete this.msgCallbacks[state]; // get rid of the listener callback when done
939
+ }
940
+ this.removeExpiredListeners(); // wipe out the expired listeners if any
941
+ };
942
+ }
943
+ sendMessage(provider, msg, callback, isLong = false) {
944
+ provider = (provider || '').toUpperCase();
945
+ const providerWorker = this.metaContext.workers[provider];
946
+ if (providerWorker) {
947
+ if (this.msgListeneres.indexOf(provider)) {
948
+ this.msgListeneres.push(provider);
949
+ providerWorker.addEventListener('message', this.workerMsgListener, false); // register a short time listener
950
+ }
951
+ let state; // message unique identifier
952
+ do {
953
+ state = new Date().getTime();
954
+ } while (!!this.msgCallbacks[state]);
955
+ this.msgCallbacks[state] = callback; // register message callback
956
+ msg.$state = state;
957
+ providerWorker.postMessage(msg);
958
+ setTimeout(() => {
959
+ this.cancelMsgListener(msg.action, state); // give up, worker does not replied on time
960
+ const listenerIndex = this.msgListeneres.indexOf(provider);
961
+ if (listenerIndex !== -1) {
962
+ this.msgListeneres.splice(listenerIndex, 1);
963
+ }
964
+ providerWorker.removeEventListener('message', this.workerMsgListener); // remove listener when done
965
+ }, isLong ? 60000 : 2000);
966
+ }
967
+ else {
968
+ callback({ action: msg.action, error: `Worker ${provider} is not registered` });
969
+ }
970
+ }
971
+ cancelMsgListener(action, storedState) {
972
+ const storedCallback = this.msgCallbacks[storedState];
973
+ if (storedCallback) {
974
+ storedCallback({ action, error: 'Timeout', state: storedState }); // always reply with something
975
+ }
976
+ delete this.msgCallbacks[storedState];
977
+ }
978
+ removeExpiredListeners() {
979
+ const now = new Date();
980
+ for (const state in this.msgCallbacks) { // cleanup expired listeners (< 1 min ago);
981
+ if (parseInt(state, 10) < now.setMinutes(now.getMinutes() - 1)) {
982
+ delete this.msgCallbacks[state];
983
+ }
984
+ }
985
+ }
986
+ }
987
+ MetaMsgService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: MetaMsgService, deps: [{ token: MetaContextService }], target: i0.ɵɵFactoryTarget.Injectable });
988
+ MetaMsgService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: MetaMsgService, providedIn: 'root' });
989
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: MetaMsgService, decorators: [{
990
+ type: Injectable,
991
+ args: [{
992
+ providedIn: 'root'
993
+ }]
994
+ }], ctorParameters: function () { return [{ type: MetaContextService }]; } });
995
+
996
+ /*
997
+ * @Author: Alexander.Vangelov@vonage.com
998
+ * @Date: 2023-02-08 12:41:56
999
+ * @Last Modified by: Alexander.Vangelov@vonage.com
1000
+ * @Last Modified time: 2023-02-08 14:04:46
1001
+ */
1002
+ const pad2Digit = (t) => t < 10 ? '0' + t : t;
1003
+ const resourceCardLabel = (r) => {
1004
+ // eslint-disable-next-line no-underscore-dangle
1005
+ if (r._vgis && r._vgis.connector === 'CLIO' && r._vgis.resourceType === 'PhoneCommunicationTimer') {
1006
+ const duration = r.quantity || 0; // in seconds
1007
+ let durationText = '00:00';
1008
+ if (duration > 0) {
1009
+ const hours = Math.floor(duration / 3600);
1010
+ const minutes = Math.floor((duration % 3600) / 60);
1011
+ const seconds = Math.round(duration % 60);
1012
+ const checkHours = hours ? pad2Digit(hours) + ':' : '';
1013
+ durationText = checkHours + pad2Digit(minutes) + ':' + pad2Digit(seconds);
1014
+ }
1015
+ return `⏱ ${durationText} | $${(Math.round(r.price) * 100) / 100} | ${r.non_billable ? 'Non-billable' : 'Billable'}`;
1016
+ }
1017
+ return r.Subject || r.subject || r.summary || r.title || r.CaseNumber || r.comment || r.body || r.name || r.topic || r.content || '...';
1018
+ };
1019
+
1020
+ /*
1021
+ * @Author: Alexander.Vangelov@vonage.com
1022
+ * @Date: 2019-09-19 17:35:19
1023
+ * @Last Modified by: Alexander.Vangelov@vonage.com
1024
+ * @Last Modified time: 2020-05-03 21:31:44
1025
+ */
1026
+ class MetaReferenceService {
1027
+ constructor(appRef, injector, router) {
1028
+ this.appRef = appRef;
1029
+ this.injector = injector;
1030
+ this.router = router;
1031
+ this.dialogs = [];
1032
+ this.router.events.subscribe((e) => {
1033
+ if (this.dialogs.length) {
1034
+ for (let d = (this.dialogs.length - 1); d >= 0; d--) {
1035
+ this.dialogs[d].onComplete();
1036
+ }
1037
+ }
1038
+ });
1039
+ }
1040
+ openDialog(componentRef, metaResource, integrationCode, reference, resource, preview, preferResourceType, theme) {
1041
+ const references = !(reference instanceof Array) ? [reference] : reference.filter((r) => r.creatable !== false);
1042
+ if (resource && resource.type) {
1043
+ if (!references.find((f) => (f.name || f.resourceType) === (resource.resourceType || resource.type))) {
1044
+ references.push({
1045
+ name: resource.resourceType || resource.type,
1046
+ resourceType: resource.resourceType || resource.type,
1047
+ label: resource.label || resource.resourceType || resource.type
1048
+ });
1049
+ }
1050
+ }
1051
+ const modalObservable = new Observable(observer => {
1052
+ this.appRef.attachView(componentRef.hostView);
1053
+ const refDialog = componentRef.instance;
1054
+ refDialog.integrationCode = integrationCode;
1055
+ refDialog.reference = references;
1056
+ refDialog.resource = resource;
1057
+ refDialog.metaResource = metaResource;
1058
+ refDialog.edit = !preview;
1059
+ refDialog.preferResourceType = preferResourceType;
1060
+ refDialog.theme = theme;
1061
+ const domElem = componentRef.hostView.rootNodes[0];
1062
+ const dialogIndex = this.dialogs.push(refDialog);
1063
+ if (dialogIndex > 1) {
1064
+ const modalPanel = domElem.querySelector('.Vlt-modal__panel');
1065
+ if (modalPanel) {
1066
+ modalPanel.style.marginLeft = `${(dialogIndex * 5)}px`;
1067
+ modalPanel.style.marginTop = `${(dialogIndex * 10)}px`;
1068
+ modalPanel.style.marginBottom = `${((dialogIndex - 1) * 8)}px`;
1069
+ }
1070
+ }
1071
+ document.body.appendChild(domElem);
1072
+ refDialog.onComplete = (result) => {
1073
+ if (result) {
1074
+ /* eslint-disable no-underscore-dangle */
1075
+ if (result._vgis) {
1076
+ observer.next({
1077
+ id: result._vgis.externalId || result._vgis.id,
1078
+ label: result._vgis.label,
1079
+ type: result._vgis.resourceType,
1080
+ raw: result
1081
+ });
1082
+ }
1083
+ else {
1084
+ console.log('onComplete non VGIS result', result);
1085
+ }
1086
+ /* eslint-enable no-underscore-dangle */
1087
+ }
1088
+ else {
1089
+ observer.next();
1090
+ }
1091
+ observer.complete();
1092
+ this.appRef.detachView(componentRef.hostView);
1093
+ componentRef.destroy();
1094
+ this.dialogs.splice(dialogIndex - 1, 1);
1095
+ };
1096
+ });
1097
+ return modalObservable;
1098
+ }
1099
+ }
1100
+ MetaReferenceService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: MetaReferenceService, deps: [{ token: i0.ApplicationRef }, { token: i0.Injector }, { token: i1$1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
1101
+ MetaReferenceService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: MetaReferenceService, providedIn: 'root' });
1102
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: MetaReferenceService, decorators: [{
1103
+ type: Injectable,
1104
+ args: [{
1105
+ providedIn: 'root'
1106
+ }]
1107
+ }], ctorParameters: function () { return [{ type: i0.ApplicationRef }, { type: i0.Injector }, { type: i1$1.Router }]; } });
1108
+
1109
+ class MetaLayout {
1110
+ constructor(viewContainerRef, ref, el, metaResource, referenceService) {
1111
+ // console.log('MetaLayout', this.meta);
1112
+ this.viewContainerRef = viewContainerRef;
1113
+ this.ref = ref;
1114
+ this.el = el;
1115
+ this.metaResource = metaResource;
1116
+ this.referenceService = referenceService;
1117
+ this.optionalFields = {};
1118
+ this.showAll = false;
1119
+ this.fieldsVisibilityChanged = new Subject();
1120
+ this.childResourceCardLabel = resourceCardLabel;
1121
+ }
1122
+ get isPersistedResource() {
1123
+ // eslint-disable-next-line no-underscore-dangle
1124
+ return this.resource && this.resource._vgis && (this.resource._vgis.externalId || this.resource._vgis.id);
1125
+ }
1126
+ ngOnInit() {
1127
+ this.integrationCode = this.meta.integrationCode || this.integration;
1128
+ this.resourceType = this.meta.resourceType || this.type;
1129
+ this.parentForm = this.el.nativeElement.closest('form');
1130
+ this.configureOptionalSections();
1131
+ this.fieldsVisibilityChanged.pipe(debounceTime(100), distinctUntilChanged()).subscribe((value) => {
1132
+ this.countOptionalFields();
1133
+ });
1134
+ setTimeout(() => {
1135
+ this.countOptionalFields();
1136
+ }, 0);
1137
+ if (this.parentForm) {
1138
+ this.parentForm.addEventListener('change', (e) => {
1139
+ setTimeout(() => {
1140
+ this.fieldsVisibilityChanged.next(JSON.stringify(this.resource));
1141
+ this.countOptionalFields();
1142
+ }, 0);
1143
+ });
1144
+ }
1145
+ if (this.theme !== 'inherit') {
1146
+ this.applyTheme();
1147
+ }
1148
+ }
1149
+ ngOnChanges(changes) {
1150
+ if (changes.meta) {
1151
+ this.configureOptionalSections();
1152
+ setTimeout(() => {
1153
+ this.countOptionalFields();
1154
+ }, 0);
1155
+ }
1156
+ else if (changes.theme) {
1157
+ this.theme = changes.theme.currentValue;
1158
+ this.applyTheme();
1159
+ }
1160
+ }
1161
+ countOptionalFields() {
1162
+ let count = 0;
1163
+ const countSectionFields = (s) => {
1164
+ for (const f of s.fields) {
1165
+ if (f.fields && f.fields.length && !f.visible) {
1166
+ countSectionFields(f);
1167
+ }
1168
+ else {
1169
+ if (f.$optional && !f.$hidden) {
1170
+ count++;
1171
+ }
1172
+ }
1173
+ }
1174
+ };
1175
+ for (const s of this.meta.sections) {
1176
+ const notOptionalAny = s.fields.find(f => !f.$optional);
1177
+ s.$optional = !notOptionalAny;
1178
+ if (!s.visible) {
1179
+ countSectionFields(s);
1180
+ }
1181
+ }
1182
+ this.optionalFieldsCount = count;
1183
+ }
1184
+ configureOptionalSections() {
1185
+ if (this.meta && this.meta.sections) {
1186
+ for (const s of this.meta.sections) {
1187
+ Object.defineProperty(s, '$optional', {
1188
+ value: true,
1189
+ writable: true,
1190
+ configurable: true,
1191
+ enumerable: false
1192
+ });
1193
+ }
1194
+ }
1195
+ }
1196
+ ngAfterContentChecked() {
1197
+ this.ref.detectChanges();
1198
+ }
1199
+ toggleOptionalFields() {
1200
+ this.showAll = !this.showAll;
1201
+ this.ngAfterContentChecked();
1202
+ }
1203
+ async openChild(childResource, childModel) {
1204
+ const metaRefDialog = await Promise.resolve().then(function () { return index; }).then(m => m.MetaRefDialog);
1205
+ childResource.reference.parent = this.resource._vgis; // eslint-disable-line no-underscore-dangle
1206
+ if (!this.refDialogComponent) {
1207
+ this.refDialogComponent = this.viewContainerRef.createComponent(metaRefDialog);
1208
+ }
1209
+ this.referenceService.openDialog(this.refDialogComponent, this.metaResource, this.integrationCode, childResource.reference, childModel, childModel && (childResource.reference.editable === false) // is preview mode
1210
+ ).subscribe((result) => {
1211
+ if (result && result.raw) {
1212
+ if (!this.resource[childResource.name]) {
1213
+ this.resource[childResource.name] = [];
1214
+ }
1215
+ if (childModel) {
1216
+ Object.assign(childModel, result.raw);
1217
+ }
1218
+ else {
1219
+ this.resource[childResource.name].push(result.raw);
1220
+ }
1221
+ }
1222
+ });
1223
+ }
1224
+ applyTheme() {
1225
+ const metaTheme = this.theme === 'dark' ? metaDark : metaLight;
1226
+ for (const key of Object.keys(metaTheme.properties)) {
1227
+ this.el.nativeElement.style.setProperty(key, metaTheme.properties[key]);
1228
+ }
1229
+ }
1230
+ }
1231
+ MetaLayout.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: MetaLayout, deps: [{ token: i0.ViewContainerRef }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: MetaResourceService }, { token: MetaReferenceService }], target: i0.ɵɵFactoryTarget.Component });
1232
+ MetaLayout.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.0", type: MetaLayout, selector: "vgip-meta-layout", inputs: { meta: "meta", resource: "resource", integration: "integration", type: "type", preview: "preview", theme: "theme" }, usesOnChanges: true, ngImport: i0, template: "<div *ngFor='let section of meta.sections' class='Vlt-section' [ngClass]=\"{ shown: showAll || section.visible || (!meta.oneTimeOptional && !section.$optional) || (meta.oneTimeOptional && !optionalFieldsCount) }\">\n\t<h5 *ngIf='section.label' class=\"Vlt-section__title\">{{section.label}}</h5>\n\t<div style='overflow: visible;' [ngClass]=\"{ 'for-preview': preview }\">\n\t\t<small *ngIf='section.description' class=\"Vlt-form__element__hint\">{{section.description}}</small>\n\t\t<div>\n\t\t\t<ng-container *ngFor='let field of section.fields'>\n\t\t\t\t<vgip-meta-field *ngIf='!field.$hidden && (showAll || section.visible || !field.$optional)' [meta]='field' [parent]='resource' [integrationCode]='integrationCode' [resourceType]='resourceType' [preview]='preview' [ngClass]=\"{ shown: !field.$invisible && (showAll || true) }\" theme='inherit' [attr.data-theme]='theme'></vgip-meta-field>\n\t\t\t</ng-container>\n\t\t</div>\n\t</div>\n</div>\n<div *ngIf='isPersistedResource && meta.children && preview'>\n\t<div *ngFor='let child of meta.children'>\n\t\t<h5 class='Vlt-children__title'>\n\t\t\t<svg class=\"Vlt-icon\"><use xlink:href=\"volta/volta-icons.svg#Vlt-icon-stack\" /></svg>&nbsp;\n\t\t\t{{child.label}} <span class='Vlt-grey'>({{(resource[child.name] || []).length}})</span>\n\t\t</h5>\n\t\t<div *ngFor=\"let c of resource[child.name]\" style='position: relative;'>\n\n\t\t\t<div class=\"Vlt-card Vlt-bg-white\">\n\t\t\t\t<div class=\"Vlt-card__content Vlt-btn-on-hover\">\n\t\t\t\t\t<h5>{{childResourceCardLabel(c)}}</h5>\n\t\t\t\t\t<div style='font-size: 12px; line-height: 16px;'>\n\t\t\t\t\t\tCreated: <span class='Vlt-black'>{{c._vgis.createdDate | date:'mediumDate'}}</span>\n\t\t\t\t\t\tEdited: <span class='Vlt-black'>{{c._vgis.modifiedDate | date:'medium'}}</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"Vlt-badge Vlt-badge--app Vlt-badge--purple Vlt-badge--small\">{{c._vgis.resourceType}}</div>\n\t\t\t\t\t<div class=\"Vlt-btn-group Vlt-btn-group--hover\">\n\t\t\t\t\t\t<a *ngIf='c._vgis.externalLink' attr.href='{{c._vgis.externalLink}}' target='_blank' rel='noopener' rel='noopener' class=\"Vlt-btn Vlt-btn--tertiary Vlt-btn--icon\" aria-label='Open external'><svg style='margin-left: 0; margin-right: 0;'><use xlink:href=\"volta/volta-icons.svg#Vlt-icon-open\"/></svg></a>\n\t\t\t\t\t\t<button type='button' (click)='openChild(child, c)' class=\"Vlt-btn Vlt-btn--tertiary Vlt-btn--icon\"><svg style='margin-left: 0; margin-right: 0;'><use attr.xlink:href=\"volta/volta-icons.svg#Vlt-icon-{{ child.reference.editable ? 'edit' : 'eye-negative' }}\"/></svg></button>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t\t<button style='width: 100%; margin-top: 0; max-width: 100%;' type='button' (click)='openChild(child)' class=\"Vlt-btn Vlt-btn--small Vlt-btn--secondary\" [disabled]='child.creatable === false'>\n\t\t\t<svg><use xlink:href=\"volta/volta-icons.svg#Vlt-icon-plus\"/></svg>{{child.reference.label}}\n\t\t</button>\n\t</div>\n</div>\n<div *ngIf='!(meta.oneTimeOptional && showAll)' [ngClass]='{ centered: !meta.oneTimeOptional }'>\n\t<button *ngIf='!preview && optionalFieldsCount' type='button' (click)='toggleOptionalFields()' class=\"Vlt-btn Vlt-btn--small Vlt-btn--link more-button\" style='margin: 0; margin-bottom: 10px;'>\n\t\t<svg><use attr.xlink:href=\"volta/volta-icons.svg#Vlt-icon-chevron-{{ showAll ? 'up' : 'down' }}\"/></svg>\n\t\t{{ showAll ? 'Hide' : 'Show' }} Optional Fields ({{optionalFieldsCount}})\n\t</button>\n</div>\n", styles: ["vgip-meta-field{display:none}vgip-meta-field.shown{display:initial}.Vlt-section__title{line-height:14px;padding:16px 16px 14px 3px;margin:-9px -1px 8px;background-color:var(--vgip-meta-resource-bg-color);color:var(--vgip-meta-resource-color);position:sticky;top:-9px;z-index:3;border-bottom:1px solid var(--vgip-meta-separator-color)}.Vlt-section{margin:0;padding-bottom:8px;display:none}.Vlt-section.shown{display:block}.Vlt-btn.vlt-add-child:hover{transform:scale(1.02)}.for-preview{margin-top:-6px}.Vlt-card{margin-bottom:16px;padding:16px}.Vlt-card .Vlt-btn-group.Vlt-btn-group--hover{right:-8px}button.more-button:focus{font-weight:700}.centered{text-align:center}.Vlt-btn--link{color:var(--vgip-meta-link-color)}.Vlt-btn--link:hover{color:var(--vgip-meta-link-hover-color)}.Vlt-btn--link svg{fill:var(--vgip-meta-link-color)}\n"], dependencies: [{ kind: "directive", type: i1$2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1$2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: MetaField, selector: "vgip-meta-field", inputs: ["meta", "parent", "integrationCode", "resourceType", "index", "preview", "theme"], outputs: ["onChange", "onLeave"] }, { kind: "pipe", type: i1$2.DatePipe, name: "date" }] });
1233
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: MetaLayout, decorators: [{
1234
+ type: Component,
1235
+ args: [{ selector: 'vgip-meta-layout', template: "<div *ngFor='let section of meta.sections' class='Vlt-section' [ngClass]=\"{ shown: showAll || section.visible || (!meta.oneTimeOptional && !section.$optional) || (meta.oneTimeOptional && !optionalFieldsCount) }\">\n\t<h5 *ngIf='section.label' class=\"Vlt-section__title\">{{section.label}}</h5>\n\t<div style='overflow: visible;' [ngClass]=\"{ 'for-preview': preview }\">\n\t\t<small *ngIf='section.description' class=\"Vlt-form__element__hint\">{{section.description}}</small>\n\t\t<div>\n\t\t\t<ng-container *ngFor='let field of section.fields'>\n\t\t\t\t<vgip-meta-field *ngIf='!field.$hidden && (showAll || section.visible || !field.$optional)' [meta]='field' [parent]='resource' [integrationCode]='integrationCode' [resourceType]='resourceType' [preview]='preview' [ngClass]=\"{ shown: !field.$invisible && (showAll || true) }\" theme='inherit' [attr.data-theme]='theme'></vgip-meta-field>\n\t\t\t</ng-container>\n\t\t</div>\n\t</div>\n</div>\n<div *ngIf='isPersistedResource && meta.children && preview'>\n\t<div *ngFor='let child of meta.children'>\n\t\t<h5 class='Vlt-children__title'>\n\t\t\t<svg class=\"Vlt-icon\"><use xlink:href=\"volta/volta-icons.svg#Vlt-icon-stack\" /></svg>&nbsp;\n\t\t\t{{child.label}} <span class='Vlt-grey'>({{(resource[child.name] || []).length}})</span>\n\t\t</h5>\n\t\t<div *ngFor=\"let c of resource[child.name]\" style='position: relative;'>\n\n\t\t\t<div class=\"Vlt-card Vlt-bg-white\">\n\t\t\t\t<div class=\"Vlt-card__content Vlt-btn-on-hover\">\n\t\t\t\t\t<h5>{{childResourceCardLabel(c)}}</h5>\n\t\t\t\t\t<div style='font-size: 12px; line-height: 16px;'>\n\t\t\t\t\t\tCreated: <span class='Vlt-black'>{{c._vgis.createdDate | date:'mediumDate'}}</span>\n\t\t\t\t\t\tEdited: <span class='Vlt-black'>{{c._vgis.modifiedDate | date:'medium'}}</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"Vlt-badge Vlt-badge--app Vlt-badge--purple Vlt-badge--small\">{{c._vgis.resourceType}}</div>\n\t\t\t\t\t<div class=\"Vlt-btn-group Vlt-btn-group--hover\">\n\t\t\t\t\t\t<a *ngIf='c._vgis.externalLink' attr.href='{{c._vgis.externalLink}}' target='_blank' rel='noopener' rel='noopener' class=\"Vlt-btn Vlt-btn--tertiary Vlt-btn--icon\" aria-label='Open external'><svg style='margin-left: 0; margin-right: 0;'><use xlink:href=\"volta/volta-icons.svg#Vlt-icon-open\"/></svg></a>\n\t\t\t\t\t\t<button type='button' (click)='openChild(child, c)' class=\"Vlt-btn Vlt-btn--tertiary Vlt-btn--icon\"><svg style='margin-left: 0; margin-right: 0;'><use attr.xlink:href=\"volta/volta-icons.svg#Vlt-icon-{{ child.reference.editable ? 'edit' : 'eye-negative' }}\"/></svg></button>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t\t<button style='width: 100%; margin-top: 0; max-width: 100%;' type='button' (click)='openChild(child)' class=\"Vlt-btn Vlt-btn--small Vlt-btn--secondary\" [disabled]='child.creatable === false'>\n\t\t\t<svg><use xlink:href=\"volta/volta-icons.svg#Vlt-icon-plus\"/></svg>{{child.reference.label}}\n\t\t</button>\n\t</div>\n</div>\n<div *ngIf='!(meta.oneTimeOptional && showAll)' [ngClass]='{ centered: !meta.oneTimeOptional }'>\n\t<button *ngIf='!preview && optionalFieldsCount' type='button' (click)='toggleOptionalFields()' class=\"Vlt-btn Vlt-btn--small Vlt-btn--link more-button\" style='margin: 0; margin-bottom: 10px;'>\n\t\t<svg><use attr.xlink:href=\"volta/volta-icons.svg#Vlt-icon-chevron-{{ showAll ? 'up' : 'down' }}\"/></svg>\n\t\t{{ showAll ? 'Hide' : 'Show' }} Optional Fields ({{optionalFieldsCount}})\n\t</button>\n</div>\n", styles: ["vgip-meta-field{display:none}vgip-meta-field.shown{display:initial}.Vlt-section__title{line-height:14px;padding:16px 16px 14px 3px;margin:-9px -1px 8px;background-color:var(--vgip-meta-resource-bg-color);color:var(--vgip-meta-resource-color);position:sticky;top:-9px;z-index:3;border-bottom:1px solid var(--vgip-meta-separator-color)}.Vlt-section{margin:0;padding-bottom:8px;display:none}.Vlt-section.shown{display:block}.Vlt-btn.vlt-add-child:hover{transform:scale(1.02)}.for-preview{margin-top:-6px}.Vlt-card{margin-bottom:16px;padding:16px}.Vlt-card .Vlt-btn-group.Vlt-btn-group--hover{right:-8px}button.more-button:focus{font-weight:700}.centered{text-align:center}.Vlt-btn--link{color:var(--vgip-meta-link-color)}.Vlt-btn--link:hover{color:var(--vgip-meta-link-hover-color)}.Vlt-btn--link svg{fill:var(--vgip-meta-link-color)}\n"] }]
1236
+ }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: MetaResourceService }, { type: MetaReferenceService }]; }, propDecorators: { meta: [{
1237
+ type: Input
1238
+ }], resource: [{
1239
+ type: Input
1240
+ }], integration: [{
1241
+ type: Input
1242
+ }], type: [{
1243
+ type: Input
1244
+ }], preview: [{
1245
+ type: Input
1246
+ }], theme: [{
1247
+ type: Input
1248
+ }] } });
1249
+
1250
+ /*
1251
+ * @Author: Alexander.Vangelov@vonage.com
1252
+ * @Date: 2021-02-11 17:25:09
1253
+ * @Last Modified by: Alexander.Vangelov@vonage.com
1254
+ * @Last Modified time: 2021-02-11 17:33:57
1255
+ */
1256
+ class MetaAutofocusDirective {
1257
+ constructor(elementRef) {
1258
+ this.elementRef = elementRef;
1259
+ }
1260
+ ngAfterContentInit() {
1261
+ if (this.vgipMetaFormAutofocus) {
1262
+ setTimeout(() => {
1263
+ const firstInput = this.elementRef.nativeElement.querySelector('.Vlt-form__element:not(.has-value) .main:not(.standalone):not([value])');
1264
+ if (firstInput) {
1265
+ firstInput.focus();
1266
+ }
1267
+ }, 300);
1268
+ }
1269
+ }
1270
+ }
1271
+ MetaAutofocusDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: MetaAutofocusDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
1272
+ MetaAutofocusDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.0", type: MetaAutofocusDirective, selector: "[vgipMetaFormAutofocus]", inputs: { vgipMetaFormAutofocus: "vgipMetaFormAutofocus" }, ngImport: i0 });
1273
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: MetaAutofocusDirective, decorators: [{
1274
+ type: Directive,
1275
+ args: [{
1276
+ // eslint-disable-next-line
1277
+ selector: '[vgipMetaFormAutofocus]'
1278
+ }]
1279
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { vgipMetaFormAutofocus: [{
1280
+ type: Input
1281
+ }] } });
1282
+
1283
+ class MetaResource {
1284
+ constructor(ref, el, metaResourceService, metaContext, metaMsgService) {
1285
+ this.ref = ref;
1286
+ this.el = el;
1287
+ this.metaResourceService = metaResourceService;
1288
+ this.metaContext = metaContext;
1289
+ this.metaMsgService = metaMsgService;
1290
+ this.done = new EventEmitter();
1291
+ this.edit = true;
1292
+ this.contactsSuggestionsDone = false;
1293
+ this.onMenuClickout = () => {
1294
+ delete this.resourceMenuVisible;
1295
+ document.removeEventListener('click', this.onMenuClickout);
1296
+ };
1297
+ }
1298
+ get niceFields() {
1299
+ if (!this.resource.niceFields
1300
+ && this.resource.meta
1301
+ && this.resource.meta.layout
1302
+ && this.resource.meta.layout.sections) {
1303
+ const extractSectionFields = (s) => {
1304
+ for (const f of s.fields) {
1305
+ if (f.name) {
1306
+ this.resource.niceFields[f.name] = f;
1307
+ }
1308
+ if (f.fields && f.fields.length) {
1309
+ extractSectionFields(f);
1310
+ }
1311
+ }
1312
+ };
1313
+ this.resource.niceFields = {};
1314
+ for (const s of this.resource.meta.layout.sections) {
1315
+ extractSectionFields(s);
1316
+ }
1317
+ }
1318
+ return this.resource.niceFields;
1319
+ }
1320
+ get fieldNames() {
1321
+ const names = Object.keys(this.niceFields);
1322
+ if (this.resource.meta.layout.children) {
1323
+ for (const child of this.resource.meta.layout.children) {
1324
+ names.push(child.name);
1325
+ }
1326
+ }
1327
+ return names;
1328
+ }
1329
+ ngOnInit() {
1330
+ this.integrationCode = (this.resource.integrationCode || '').toUpperCase();
1331
+ this.resourceType = this.resource.resourceType;
1332
+ this.service = (this.metaResourceServiceDelegated || this.metaResourceService).new(this.resource);
1333
+ if (!this.model) {
1334
+ this.model = {};
1335
+ }
1336
+ if (this.resource.activity && this.resource.ref.editable === false && !this.resource.externalId) {
1337
+ this.resource.externalId = 'MISSING_EXTERNAL_ID';
1338
+ }
1339
+ this.isPersistent = this.resource && this.resource.externalId;
1340
+ if (!this.resource.meta) {
1341
+ this.loadMetadata(this.resource.layoutId);
1342
+ }
1343
+ else {
1344
+ // if (this.isPersistent && (!this.isEditable || this.resources[ref.name].meta.layout.children)) {
1345
+ // this.edit = false;
1346
+ // }
1347
+ this.meta = this.resource.meta;
1348
+ this.currentLayoutId = this.meta.layout.id;
1349
+ this.getDetails();
1350
+ this.getFieldsMap();
1351
+ }
1352
+ if (this.theme !== 'inherit') {
1353
+ this.applyTheme();
1354
+ }
1355
+ }
1356
+ ngOnChanges(changes) {
1357
+ if (changes.theme) {
1358
+ this.theme = changes.theme.currentValue;
1359
+ if (this.theme !== 'inherit') {
1360
+ this.applyTheme();
1361
+ }
1362
+ }
1363
+ }
1364
+ editMode() {
1365
+ this.edit = true;
1366
+ }
1367
+ loadMetadata(layoutId, refresh = false) {
1368
+ const layoutStoreKey = `vgis.layout_${this.metaContext.vgipUserId}_${this.integrationCode}_${this.resource.resourceType}`;
1369
+ if (!layoutId) {
1370
+ layoutId = localStorage.getItem(layoutStoreKey);
1371
+ }
1372
+ this.busy = true;
1373
+ setTimeout(() => {
1374
+ this.metaLoading = true;
1375
+ }, 0);
1376
+ delete this.resource.niceFields;
1377
+ this.service.getMetadata(layoutId, refresh).subscribe({
1378
+ next: (meta) => {
1379
+ this.currentLayoutId = meta.layout.id;
1380
+ if (layoutId !== meta.layout.id && !this.isPersistent) {
1381
+ localStorage.removeItem(layoutStoreKey);
1382
+ }
1383
+ this.meta = metaNormalizer(meta, this.integrationCode, this.resource.resourceType);
1384
+ this.isEditable = this.meta.layout && this.meta.layout.editable !== false;
1385
+ this.resource.meta = this.meta;
1386
+ if (this.isPersistent && (!this.isEditable || this.meta.layout.children)) {
1387
+ this.edit = false;
1388
+ }
1389
+ delete this.busy;
1390
+ this.getDetails();
1391
+ this.getFieldsMap();
1392
+ },
1393
+ error: (metaError) => {
1394
+ delete this.busy;
1395
+ this.generalError = `Error loading resource metadata (${metaError.statusText})`;
1396
+ },
1397
+ complete: () => {
1398
+ delete this.metaLoading;
1399
+ this.forceUiUpdate();
1400
+ }
1401
+ });
1402
+ }
1403
+ changeLayout() {
1404
+ localStorage.setItem(`vgis.layout_${this.metaContext.vgipUserId}_${this.integrationCode}_${this.resource.resourceType}`, this.currentLayoutId);
1405
+ this.loadMetadata(this.currentLayoutId);
1406
+ }
1407
+ getDetails() {
1408
+ if (this.resource && (this.resource.externalId || this.resource.id)) {
1409
+ if (this.resource.parent && this.resource.activity // skip fetch
1410
+ && this.meta.layout.editable === false && !this.meta.layout.children) {
1411
+ for (const p in this.resource.activity) {
1412
+ if (this.resource.activity[p] && this.fieldNames.indexOf(p) !== -1) {
1413
+ this.model[p] = this.resource.activity[p];
1414
+ }
1415
+ }
1416
+ }
1417
+ else {
1418
+ this.busy = true;
1419
+ this.service.getDetails((this.resource.externalId || this.resource.id), {
1420
+ eventId: this.resource.eventId !== 'NO_EVENT' ? this.resource.eventId : null, layoutId: this.resource.layoutId
1421
+ }).subscribe({
1422
+ next: (resource) => {
1423
+ /* eslint-disable no-underscore-dangle */
1424
+ if (resource._vgis) {
1425
+ if (resource._vgis.eventId) {
1426
+ this.metaContext.vgipEventId = resource._vgis.eventId;
1427
+ }
1428
+ if (resource.layoutId && resource._vgis.layoutId !== this.currentLayoutId) {
1429
+ this.loadMetadata(resource._vgis.layoutId);
1430
+ }
1431
+ }
1432
+ /* eslint-enable no-underscore-dangle */
1433
+ for (const p in resource) {
1434
+ if (typeof (resource[p] !== 'undefined') && (this.fieldNames.indexOf(p) !== -1 || p === '_vgis')) {
1435
+ this.model[p] = resource[p];
1436
+ }
1437
+ }
1438
+ delete this.busy;
1439
+ },
1440
+ error: (resourceError) => {
1441
+ this.generalError = resourceError.error ? resourceError.error.message || resourceError.message : resourceError.message;
1442
+ delete this.busy;
1443
+ },
1444
+ complete: () => {
1445
+ this.forceUiUpdate();
1446
+ }
1447
+ });
1448
+ }
1449
+ }
1450
+ else {
1451
+ if (this.resource.ref && this.resource.ref.activity) { // reuse failed autoactivities data
1452
+ for (const p in this.resource.ref.activity) {
1453
+ if (this.resource.ref.activity && this.fieldNames.indexOf(p) !== -1) {
1454
+ this.model[p] = this.resource.ref.activity[p]; // VGIS-7215 (copy only valid fields)
1455
+ }
1456
+ }
1457
+ }
1458
+ this.performAutoFill();
1459
+ }
1460
+ }
1461
+ performAutoFill() {
1462
+ this.metaMsgService.sendMessage(this.integrationCode, {
1463
+ action: 'autoFill',
1464
+ integration: this.integrationCode,
1465
+ resourceType: this.resourceType,
1466
+ resource: JSON.parse(JSON.stringify(this.model)),
1467
+ fields: this.niceFields,
1468
+ event: this.metaContext.context,
1469
+ profile: this.metaContext.profiles[this.integrationCode]
1470
+ }, (response) => {
1471
+ if (!response.error) {
1472
+ for (const afp in response.autoFill) {
1473
+ if (!this.model[afp]) {
1474
+ this.model[afp] = response.autoFill[afp];
1475
+ }
1476
+ }
1477
+ }
1478
+ });
1479
+ }
1480
+ getFieldsMap() {
1481
+ if (this.meta.fieldsMap) {
1482
+ this.fieldsMap = this.meta.fieldsMap;
1483
+ this.markContactables();
1484
+ this.buildContactsSuggestions();
1485
+ if (!this.resource.externalId) {
1486
+ this.buildSubjectTemplate();
1487
+ this.execTransformer();
1488
+ }
1489
+ }
1490
+ else {
1491
+ this.metaMsgService.sendMessage(this.integrationCode, { action: 'fieldsMap', integration: this.integrationCode, resourceType: this.resourceType }, (response) => {
1492
+ if (!response.error) {
1493
+ this.fieldsMap = response.fieldsMap;
1494
+ this.markContactables();
1495
+ this.buildContactsSuggestions();
1496
+ if (!this.resource.externalId) {
1497
+ this.buildSubjectTemplate();
1498
+ this.execTransformer();
1499
+ }
1500
+ }
1501
+ else {
1502
+ console.log('No fields map', this.integrationCode, this.resourceType, response.error);
1503
+ }
1504
+ });
1505
+ }
1506
+ }
1507
+ openResourceMenu() {
1508
+ this.resourceMenuVisible = true;
1509
+ setTimeout(() => {
1510
+ document.addEventListener('click', this.onMenuClickout);
1511
+ }, 10);
1512
+ }
1513
+ close(result) {
1514
+ this.done.emit(result);
1515
+ }
1516
+ showParsedError(resourceForm, parsedError) {
1517
+ this.formErrors = parsedError.message || 'There is a problem with one or more fields';
1518
+ if (parsedError.errors && parsedError.errors.length) {
1519
+ this.formErrors += ` (${parsedError.errors.map(e => e.message).join(', ')})`;
1520
+ for (const pe of parsedError.errors) {
1521
+ if (resourceForm.controls[pe.field]) {
1522
+ resourceForm.controls[pe.field].setErrors({ invalid: true, custom: pe.message });
1523
+ }
1524
+ }
1525
+ setTimeout(() => {
1526
+ const firstInvalid = this.el.nativeElement.querySelector('.Vlt-form__element--error .main:not(.standalone)');
1527
+ if (firstInvalid) {
1528
+ firstInvalid.focus();
1529
+ }
1530
+ });
1531
+ }
1532
+ }
1533
+ submit(resourceForm) {
1534
+ delete this.formErrors;
1535
+ resourceForm.form.submitted = true;
1536
+ if (resourceForm.valid) {
1537
+ this.busy = true;
1538
+ if (this.metaContext.vgipEventId) {
1539
+ /* eslint-disable no-underscore-dangle */
1540
+ if (!this.model._vgis) {
1541
+ this.model._vgis = {
1542
+ connector: this.integrationCode,
1543
+ resourceType: this.resourceType
1544
+ };
1545
+ }
1546
+ this.model._vgis.layoutId = this.currentLayoutId;
1547
+ // eslint-disable-next-line max-len
1548
+ // this.model._vgis.timeZoneOffsetInMinutes = 0; // we are not providing timezone anymore (as V3), instead the 'time' and 'date' objects are converted so the UTC time/date is correct
1549
+ this.model._vgis.eventId = this.metaContext.vgipEventId;
1550
+ /* eslint-enable no-underscore-dangle */
1551
+ }
1552
+ this.service.save(this.model).subscribe((result) => {
1553
+ this.close(result);
1554
+ delete this.busy;
1555
+ }, (errorResult) => {
1556
+ if ((errorResult.status === 422 && errorResult.error && !errorResult.error.errors && errorResult.error.integrationError)
1557
+ || (errorResult.error && errorResult.error.errors && errorResult.error.errors.length && !errorResult.error.errors[0].field)
1558
+ // backend implemented error parsing but broken VGIS-7366
1559
+ ) {
1560
+ this.formErrors = 'There is a problem with one or more fields';
1561
+ try {
1562
+ this.metaMsgService.sendMessage(this.integrationCode, {
1563
+ action: 'parseErrorMessage',
1564
+ integrationCode: this.integrationCode,
1565
+ resourceType: errorResult.error.resourceType,
1566
+ rawError: errorResult.error.integrationError,
1567
+ profile: this.metaContext.profiles[this.integrationCode.toUpperCase()]
1568
+ }, (response) => {
1569
+ if (response.parsedError) {
1570
+ this.showParsedError(resourceForm, response.parsedError);
1571
+ }
1572
+ else {
1573
+ // eslint-disable-next-line no-underscore-dangle
1574
+ console.error('No error parser for', this.integrationCode, errorResult.error.integrationError);
1575
+ this.formErrors = errorResult.error;
1576
+ }
1577
+ });
1578
+ }
1579
+ catch (err) {
1580
+ console.log('....', err);
1581
+ }
1582
+ ;
1583
+ }
1584
+ else if (errorResult.status === 422) {
1585
+ this.showParsedError(resourceForm, errorResult.error);
1586
+ }
1587
+ else {
1588
+ this.formErrors = errorResult.error;
1589
+ }
1590
+ delete this.busy;
1591
+ });
1592
+ }
1593
+ else {
1594
+ this.formErrors = Object.keys(resourceForm.controls)
1595
+ .filter((c) => resourceForm.controls[c].invalid)
1596
+ .map((f) => (this.niceFields[f] ? (this.niceFields[f].label || f) : f)).join(', ');
1597
+ setTimeout(() => {
1598
+ const selector = `form[name="${this.resourceType}"] .Vlt-form__element--error .main:not(.standalone)`;
1599
+ const firstInvalid = this.el.nativeElement.querySelector(selector);
1600
+ if (firstInvalid) {
1601
+ firstInvalid.focus();
1602
+ }
1603
+ });
1604
+ }
1605
+ }
1606
+ clearFormErrors() {
1607
+ delete this.formErrors;
1608
+ }
1609
+ suggestFieldProperty(key, value) {
1610
+ if (key && value) {
1611
+ const fieldNames = this.fieldNames;
1612
+ if (this.model) {
1613
+ const nestMatch = key.match(/(\S+)\[\d\]\.(\S+)/);
1614
+ if (nestMatch && fieldNames.indexOf(nestMatch[1]) !== -1) {
1615
+ this.model[nestMatch[1]] = [];
1616
+ const nestKeys = {};
1617
+ nestKeys[nestMatch[2]] = value;
1618
+ this.model[nestMatch[1]].push(nestKeys);
1619
+ }
1620
+ else if (fieldNames.indexOf(key) !== -1) {
1621
+ this.model[key] = value;
1622
+ }
1623
+ }
1624
+ }
1625
+ }
1626
+ execTransformer() {
1627
+ if (this.metaContext && this.fieldsMap) {
1628
+ setTimeout(() => {
1629
+ this.suggestFieldProperty(this.fieldsMap.phoneNumber, this.metaContext.phoneNumber);
1630
+ if (this.fieldsMap.firstName || this.fieldsMap.lastName) {
1631
+ const names = (this.metaContext.displayName || '').split(' ');
1632
+ this.suggestFieldProperty(this.fieldsMap.firstName, names[0]);
1633
+ this.suggestFieldProperty(this.fieldsMap.lastName, names[1]);
1634
+ }
1635
+ else if (this.fieldsMap.displayName) {
1636
+ this.suggestFieldProperty(this.fieldsMap.displayName, this.metaContext.displayName);
1637
+ }
1638
+ }, 100);
1639
+ }
1640
+ }
1641
+ markContactables() {
1642
+ if (this.fieldsMap.contactables && this.fieldsMap.contactables.length) {
1643
+ for (const c of this.fieldsMap.contactables) {
1644
+ const field = this.niceFields[c];
1645
+ if (field) {
1646
+ Object.defineProperty(field, '$isContactable', {
1647
+ value: true,
1648
+ configurable: true,
1649
+ enumerable: false
1650
+ });
1651
+ }
1652
+ }
1653
+ }
1654
+ }
1655
+ buildSubjectTemplate() {
1656
+ if (!this.model[this.fieldsMap.subject] && this.fieldsMap.subject && this.niceFields[this.fieldsMap.subject]) {
1657
+ let subjectTemplate;
1658
+ if (this.niceFields[this.fieldsMap.subject].default) {
1659
+ subjectTemplate = this.niceFields[this.fieldsMap.subject].default.id || this.niceFields[this.fieldsMap.subject].default;
1660
+ }
1661
+ else if (this.metaContext.profiles[this.integrationCode]) {
1662
+ const profile = this.metaContext.profiles[this.integrationCode] || {};
1663
+ subjectTemplate = profile.defaultSubject ?
1664
+ profile.defaultSubject[((this.metaContext.context || 'CALL').type || '').toUpperCase()] :
1665
+ profile.activityDefaultSubjectTemplate;
1666
+ }
1667
+ if (subjectTemplate) {
1668
+ this.model[this.fieldsMap.subject] = templateBuilder(this.metaContext, subjectTemplate);
1669
+ }
1670
+ }
1671
+ }
1672
+ buildContactsSuggestions() {
1673
+ // let hasDefaultContact = false;
1674
+ if (this.metaContext.contactables[this.integrationCode] && this.meta.layout && this.meta.layout.sections) {
1675
+ for (const s of this.meta.layout.sections) {
1676
+ for (const f of (s.fields || [])) {
1677
+ if (f.type === 'reference') {
1678
+ const refTypes = (f.reference.length ? f.reference : [f.reference]).map(r => r.name);
1679
+ for (const c of this.metaContext.contactables[this.integrationCode]) {
1680
+ if (refTypes.indexOf(c.resourceType || c.type) !== -1) {
1681
+ if (!f.suggestions) {
1682
+ f.suggestions = [];
1683
+ }
1684
+ else {
1685
+ f.suggestions = f.suggestions.filter(sg => !sg.auto);
1686
+ }
1687
+ let tLabel = c.displayName || c.name;
1688
+ if (c.phoneNumbers) {
1689
+ tLabel += (' ✆' + c.phoneNumbers.map(p => p.phoneNumber).join(','));
1690
+ }
1691
+ f.suggestions.push({
1692
+ id: c.externalId || c.identifier || c.id,
1693
+ label: tLabel,
1694
+ type: c.resourceType || c.type,
1695
+ auto: true
1696
+ });
1697
+ }
1698
+ }
1699
+ if ((this.fieldsMap.contactables || []).indexOf(f.name) !== -1) { // evaluate usability?
1700
+ f.alwaysVisible = true;
1701
+ }
1702
+ // if (
1703
+ // !hasDefaultContact && this.metaContext.defaultContactables[this.integrationCode]
1704
+ // && refTypes.indexOf(this.metaContext.defaultContactables[this.integrationCode].type) !== -1
1705
+ // ) {
1706
+ // this.resource[f.name] = this.metaContext.defaultContactables[this.integrationCode];
1707
+ // hasDefaultContact = true;
1708
+ // } else if (!hasDefaultContact && this.fieldsMap.contactables && f.suggestions && f.suggestions.length === 1) {
1709
+ // if (this.fieldsMap.contactables.indexOf(f.name) !== -1 && !f.default) {
1710
+ // f.default = f.suggestions[0];
1711
+ // hasDefaultContact = true;
1712
+ // }
1713
+ // }
1714
+ }
1715
+ }
1716
+ }
1717
+ this.contactsSuggestionsDone = true;
1718
+ }
1719
+ }
1720
+ applyTheme() {
1721
+ const metaTheme = this.theme === 'dark' ? metaDark : metaLight;
1722
+ console.log('resource apply theme', this.theme);
1723
+ for (const key of Object.keys(metaTheme.properties)) {
1724
+ this.el.nativeElement.style.setProperty(key, metaTheme.properties[key]);
1725
+ }
1726
+ }
1727
+ forceUiUpdate() {
1728
+ // this.ref.detectChanges();
1729
+ const e = document.createEvent('Events');
1730
+ e.initEvent('click', true, false);
1731
+ this.el.nativeElement.dispatchEvent(e);
1732
+ }
1733
+ }
1734
+ MetaResource.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: MetaResource, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: MetaResourceService }, { token: MetaContextService }, { token: MetaMsgService }], target: i0.ɵɵFactoryTarget.Component });
1735
+ MetaResource.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.0", type: MetaResource, selector: "vgip-meta-resource", inputs: { resource: "resource", model: "model", metaResourceServiceDelegated: "metaResourceServiceDelegated", theme: "theme" }, outputs: { done: "done" }, usesOnChanges: true, ngImport: i0, template: "<div *ngIf='generalError' class=\"Vlt-callout Vlt-callout--critical\" style='overflow: auto; margin: 20px;'>\n\t<i></i>\n\t<div class=\"Vlt-callout__content\">\n\t\t<p>{{generalError}}</p>\n\t</div>\n</div>\n<div *ngIf='!meta' class=\"Vlt-progress\">\n\t<div class=\"Vlt-progress__bar\" [ngClass]=\"{ loading: metaLoading }\" role=\"progressbar\" aria-valuemin=\"0\" aria-valuetext=\"Loading Metadata\" aria-valuemax=\"100\"></div>\n</div>\n<form [vgipMetaFormAutofocus]='!resource || !resource.externalId' *ngIf='meta && !generalError' #resourceForm=\"ngForm\" [name]='resource.resourceType' (ngSubmit)='submit(resourceForm)' novalidate>\n\t<div class='form-content' style='overflow: hidden;'>\n\t\t<div [ngClass]=\"{ 'Vlt-callout--dismissed': !formErrors }\" class=\"Vlt-callout Vlt-callout--banner Vlt-callout--critical\">\n\t\t\t<i></i>\n\t\t\t<div class=\"Vlt-callout__content\" style=\"margin-top: auto;\">\n\t\t\t\t<p>There is a problem with one or more fields</p>\n\t\t\t\t<small style='font-weight: 600; font-size: 1.0em;' *ngIf='formErrors'>{{ formErrors.message || formErrors }}</small>\n\t\t\t</div>\n\t\t\t<button type='button' class=\"Vlt-callout__dismiss\" (click)='clearFormErrors()' aria-label=\"Dismiss\"></button>\n\t\t</div>\n\t\t<div class=\"Vlt-card__content\" style='min-height: 40px;'>\n\t\t\t<vgip-meta-layout *ngIf='edit' [meta]='meta.layout' [resource]='model' [preview]='false' [integration]='meta.integration' [type]='resource.resourceType' theme='inherit'></vgip-meta-layout>\n\t\t\t<vgip-meta-layout *ngIf='!edit' [meta]='meta.layout' [resource]='model' [preview]='true' [integration]='meta.integration' [type]='resource.resourceType' theme='inherit'></vgip-meta-layout>\n\t\t</div>\n\t</div>\n\t<div class=\"Vlt-card__footer\">\n\t\t<button class=\"Vlt-btn Vlt-btn--secondary Vlt-btn--app Vlt-btn--outline\" type='button' aria-label='Cancel' (click)='close()'>\n\t\t\t{{ edit ? 'Cancel' : 'Close' }}\n\t\t</button>\n\t\t<button *ngIf='edit' class=\"Vlt-btn Vlt-btn--app\" [ngClass]=\"{ 'Vlt-btn--primary': isPersistent, 'Vlt-btn--secondary': !isPersistent }\" type='submit'>\n\t\t\t{{ (resource && resource.externalId) ? 'Update' : 'Create' }}\n\t\t</button>\n\t\t<button (click)='editMode()' *ngIf='!edit && isEditable' [disabled]='!isEditable' class=\"Vlt-btn Vlt-btn--app Vlt-btn--primary\" type='button' aria-label='Edit'>\n\t\t\tEdit\n\t\t</button>\n\t\t<div style='margin-right: 8px; flex: 1;'>\n\t\t\t<div *ngIf='meta.availableLayouts && meta.availableLayouts.length' class=\"Vlt-form__element Vlt-form__element--big\" style='padding: 0; margin: -8px -18px -8px 0;'>\n\t\t\t\t<div class=\"Vlt-select\">\n\t\t\t\t\t<label style='all: inherit;'>\n\t\t\t\t\t\t<select style='border: 0; margin-top: 3px; background: transparent;' (change)='changeLayout()' [(ngModel)]='currentLayoutId' [ngModelOptions]='{ standalone: true }' [disabled]='isPersistent'>\n\t\t\t\t\t\t\t<option selected disabled>Select layout</option>\n\t\t\t\t\t\t\t<option *ngFor='let layout of meta.availableLayouts' [ngValue]='layout.id'>{{layout.name}}</option>\n\t\t\t\t\t\t</select>\n\t\t\t\t\t\t<label>Layout</label>\n\t\t\t\t\t</label>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t\t<div class=\"Vlt-dropdown resource-menu\" [ngClass]=\"{ 'Vlt-dropdown--expanded': resourceMenuVisible }\" style='margin-left: 2px;'>\n\t\t\t<div class=\"Vlt-dropdown__panel\" style='bottom: 40px; right: -4px; top: initial;'>\n\t\t\t\t<div class=\"Vlt-dropdown__panel__content\">\n\t\t\t\t\t<a class=\"Vlt-dropdown__link\" (click)='loadMetadata(currentLayoutId, true)'>\n\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t<svg class='Vlt-icon Vlt-icon--smaller'><use xlink:href=\"volta/volta-icons.svg#Vlt-icon-refresh\"/></svg>&nbsp;&nbsp;Refresh metadata\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</a>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div class=\"Vlt-dropdown__trigger\">\n\t\t\t\t<button type='button' (click)='openResourceMenu()' class=\"Vlt-btn Vlt-btn--link\" aria-label='Resource menu'>\n\t\t\t\t\t<svg class='Vlt-icon Vlt-icon--small' style='margin: 0;'><use xlink:href=\"volta/volta-icons.svg#Vlt-icon-more-v-negative\"/></svg>\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n</form>\n<div class='busy-mask' [ngClass]=\"{ active: busy }\">\n\t<div style='height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;'>\n\t\t<div class=\"Vlt-spinner\"></div>\n\t</div>\n</div>", styles: [":host{flex:1;display:flex;flex-direction:column;min-height:0;color:var(--vgip-meta-resource-color)}.Vlt-callout--banner{justify-content:initial;text-align:initial;overflow-y:auto}.Vlt-callout--banner.Vlt-callout--dismissed{padding:0}.Vlt-callout--banner:not(.Vlt-callout--dismissed){min-height:78px}.Vlt-spinner:before,.Vlt-spinner:after{border:6px solid #616266;border-color:#616266 transparent transparent}.Vlt-card__content{padding:8px 8px 8px 16px;display:flex;flex-direction:column;min-height:0;flex:1;overflow-y:scroll;overflow-x:hidden;background-color:var(--vgip-meta-resource-bg-color)}@media (hover: none){.Vlt-card__content{padding-right:16px}}.Vlt-card__content::-webkit-scrollbar{width:8px}.Vlt-card__content::-webkit-scrollbar-thumb{background-color:var(--vgip-meta-scrollbar-color);border:2px solid transparent;border-radius:6px;background-clip:content-box}.Vlt-card__footer{background:var(--vgip-meta-resource-bar-color);border-top:1px solid var(--vgip-meta-separator-color);display:flex;flex-direction:row;margin:16px -24px -24px;padding:8px 8px 8px 16px;box-shadow:0 0 4px #00000040;z-index:1}.Vlt-card__footer .Vlt-select select{color:var(--vgip-meta-input-color)}.Vlt-card__footer .Vlt-select select:disabled{background:initial;cursor:not-allowed}.Vlt-card__footer .Vlt-select:after{background-image:var(--vgip-meta-dropdown-icon)}.Vlt-card__footer .resource-menu .Vlt-icon:not(:hover){fill:var(--vgip-meta-input-label-color)}.Vlt-card__footer button.Vlt-btn--secondary{border:none;box-shadow:inset 0 0 0 1px var(--vgip-meta-button-border-color)}.Vlt-card__footer button.Vlt-btn--secondary:not([type=submit]){color:var(--vgip-meta-input-color)}.Vlt-card__footer button.Vlt-btn--secondary:hover{box-shadow:inset 0 0 0 1px var(--vgip-meta-input-accent-color)}.Vlt-card__footer button.Vlt-btn--secondary:hover[type=submit]{background-color:var(--vgip-meta-submit-hover-bg-color)}.Vlt-progress{margin:0;position:sticky}.Vlt-progress .Vlt-progress__bar{width:0;transition:width 5s}.Vlt-progress .Vlt-progress__bar.loading{width:100%}form{border-radius:6px;padding:24px;display:flex;flex-direction:column;min-height:0;flex:1}form .form-content{margin:-24px -24px -16px;padding-bottom:0;flex:1;display:flex;flex-direction:column}.busy-mask{position:absolute;inset:0;background:rgba(0,0,0,.32);opacity:1;z-index:898;display:none;border-bottom-left-radius:6px;border-bottom-right-radius:6px;margin:1px;cursor:progress}.busy-mask.active{display:block}\n"], dependencies: [{ kind: "directive", type: i1$2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1$2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i2.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: MetaLayout, selector: "vgip-meta-layout", inputs: ["meta", "resource", "integration", "type", "preview", "theme"] }, { kind: "directive", type: MetaAutofocusDirective, selector: "[vgipMetaFormAutofocus]", inputs: ["vgipMetaFormAutofocus"] }] });
1736
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: MetaResource, decorators: [{
1737
+ type: Component,
1738
+ args: [{ selector: 'vgip-meta-resource', template: "<div *ngIf='generalError' class=\"Vlt-callout Vlt-callout--critical\" style='overflow: auto; margin: 20px;'>\n\t<i></i>\n\t<div class=\"Vlt-callout__content\">\n\t\t<p>{{generalError}}</p>\n\t</div>\n</div>\n<div *ngIf='!meta' class=\"Vlt-progress\">\n\t<div class=\"Vlt-progress__bar\" [ngClass]=\"{ loading: metaLoading }\" role=\"progressbar\" aria-valuemin=\"0\" aria-valuetext=\"Loading Metadata\" aria-valuemax=\"100\"></div>\n</div>\n<form [vgipMetaFormAutofocus]='!resource || !resource.externalId' *ngIf='meta && !generalError' #resourceForm=\"ngForm\" [name]='resource.resourceType' (ngSubmit)='submit(resourceForm)' novalidate>\n\t<div class='form-content' style='overflow: hidden;'>\n\t\t<div [ngClass]=\"{ 'Vlt-callout--dismissed': !formErrors }\" class=\"Vlt-callout Vlt-callout--banner Vlt-callout--critical\">\n\t\t\t<i></i>\n\t\t\t<div class=\"Vlt-callout__content\" style=\"margin-top: auto;\">\n\t\t\t\t<p>There is a problem with one or more fields</p>\n\t\t\t\t<small style='font-weight: 600; font-size: 1.0em;' *ngIf='formErrors'>{{ formErrors.message || formErrors }}</small>\n\t\t\t</div>\n\t\t\t<button type='button' class=\"Vlt-callout__dismiss\" (click)='clearFormErrors()' aria-label=\"Dismiss\"></button>\n\t\t</div>\n\t\t<div class=\"Vlt-card__content\" style='min-height: 40px;'>\n\t\t\t<vgip-meta-layout *ngIf='edit' [meta]='meta.layout' [resource]='model' [preview]='false' [integration]='meta.integration' [type]='resource.resourceType' theme='inherit'></vgip-meta-layout>\n\t\t\t<vgip-meta-layout *ngIf='!edit' [meta]='meta.layout' [resource]='model' [preview]='true' [integration]='meta.integration' [type]='resource.resourceType' theme='inherit'></vgip-meta-layout>\n\t\t</div>\n\t</div>\n\t<div class=\"Vlt-card__footer\">\n\t\t<button class=\"Vlt-btn Vlt-btn--secondary Vlt-btn--app Vlt-btn--outline\" type='button' aria-label='Cancel' (click)='close()'>\n\t\t\t{{ edit ? 'Cancel' : 'Close' }}\n\t\t</button>\n\t\t<button *ngIf='edit' class=\"Vlt-btn Vlt-btn--app\" [ngClass]=\"{ 'Vlt-btn--primary': isPersistent, 'Vlt-btn--secondary': !isPersistent }\" type='submit'>\n\t\t\t{{ (resource && resource.externalId) ? 'Update' : 'Create' }}\n\t\t</button>\n\t\t<button (click)='editMode()' *ngIf='!edit && isEditable' [disabled]='!isEditable' class=\"Vlt-btn Vlt-btn--app Vlt-btn--primary\" type='button' aria-label='Edit'>\n\t\t\tEdit\n\t\t</button>\n\t\t<div style='margin-right: 8px; flex: 1;'>\n\t\t\t<div *ngIf='meta.availableLayouts && meta.availableLayouts.length' class=\"Vlt-form__element Vlt-form__element--big\" style='padding: 0; margin: -8px -18px -8px 0;'>\n\t\t\t\t<div class=\"Vlt-select\">\n\t\t\t\t\t<label style='all: inherit;'>\n\t\t\t\t\t\t<select style='border: 0; margin-top: 3px; background: transparent;' (change)='changeLayout()' [(ngModel)]='currentLayoutId' [ngModelOptions]='{ standalone: true }' [disabled]='isPersistent'>\n\t\t\t\t\t\t\t<option selected disabled>Select layout</option>\n\t\t\t\t\t\t\t<option *ngFor='let layout of meta.availableLayouts' [ngValue]='layout.id'>{{layout.name}}</option>\n\t\t\t\t\t\t</select>\n\t\t\t\t\t\t<label>Layout</label>\n\t\t\t\t\t</label>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t\t<div class=\"Vlt-dropdown resource-menu\" [ngClass]=\"{ 'Vlt-dropdown--expanded': resourceMenuVisible }\" style='margin-left: 2px;'>\n\t\t\t<div class=\"Vlt-dropdown__panel\" style='bottom: 40px; right: -4px; top: initial;'>\n\t\t\t\t<div class=\"Vlt-dropdown__panel__content\">\n\t\t\t\t\t<a class=\"Vlt-dropdown__link\" (click)='loadMetadata(currentLayoutId, true)'>\n\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t<svg class='Vlt-icon Vlt-icon--smaller'><use xlink:href=\"volta/volta-icons.svg#Vlt-icon-refresh\"/></svg>&nbsp;&nbsp;Refresh metadata\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</a>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div class=\"Vlt-dropdown__trigger\">\n\t\t\t\t<button type='button' (click)='openResourceMenu()' class=\"Vlt-btn Vlt-btn--link\" aria-label='Resource menu'>\n\t\t\t\t\t<svg class='Vlt-icon Vlt-icon--small' style='margin: 0;'><use xlink:href=\"volta/volta-icons.svg#Vlt-icon-more-v-negative\"/></svg>\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n</form>\n<div class='busy-mask' [ngClass]=\"{ active: busy }\">\n\t<div style='height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;'>\n\t\t<div class=\"Vlt-spinner\"></div>\n\t</div>\n</div>", styles: [":host{flex:1;display:flex;flex-direction:column;min-height:0;color:var(--vgip-meta-resource-color)}.Vlt-callout--banner{justify-content:initial;text-align:initial;overflow-y:auto}.Vlt-callout--banner.Vlt-callout--dismissed{padding:0}.Vlt-callout--banner:not(.Vlt-callout--dismissed){min-height:78px}.Vlt-spinner:before,.Vlt-spinner:after{border:6px solid #616266;border-color:#616266 transparent transparent}.Vlt-card__content{padding:8px 8px 8px 16px;display:flex;flex-direction:column;min-height:0;flex:1;overflow-y:scroll;overflow-x:hidden;background-color:var(--vgip-meta-resource-bg-color)}@media (hover: none){.Vlt-card__content{padding-right:16px}}.Vlt-card__content::-webkit-scrollbar{width:8px}.Vlt-card__content::-webkit-scrollbar-thumb{background-color:var(--vgip-meta-scrollbar-color);border:2px solid transparent;border-radius:6px;background-clip:content-box}.Vlt-card__footer{background:var(--vgip-meta-resource-bar-color);border-top:1px solid var(--vgip-meta-separator-color);display:flex;flex-direction:row;margin:16px -24px -24px;padding:8px 8px 8px 16px;box-shadow:0 0 4px #00000040;z-index:1}.Vlt-card__footer .Vlt-select select{color:var(--vgip-meta-input-color)}.Vlt-card__footer .Vlt-select select:disabled{background:initial;cursor:not-allowed}.Vlt-card__footer .Vlt-select:after{background-image:var(--vgip-meta-dropdown-icon)}.Vlt-card__footer .resource-menu .Vlt-icon:not(:hover){fill:var(--vgip-meta-input-label-color)}.Vlt-card__footer button.Vlt-btn--secondary{border:none;box-shadow:inset 0 0 0 1px var(--vgip-meta-button-border-color)}.Vlt-card__footer button.Vlt-btn--secondary:not([type=submit]){color:var(--vgip-meta-input-color)}.Vlt-card__footer button.Vlt-btn--secondary:hover{box-shadow:inset 0 0 0 1px var(--vgip-meta-input-accent-color)}.Vlt-card__footer button.Vlt-btn--secondary:hover[type=submit]{background-color:var(--vgip-meta-submit-hover-bg-color)}.Vlt-progress{margin:0;position:sticky}.Vlt-progress .Vlt-progress__bar{width:0;transition:width 5s}.Vlt-progress .Vlt-progress__bar.loading{width:100%}form{border-radius:6px;padding:24px;display:flex;flex-direction:column;min-height:0;flex:1}form .form-content{margin:-24px -24px -16px;padding-bottom:0;flex:1;display:flex;flex-direction:column}.busy-mask{position:absolute;inset:0;background:rgba(0,0,0,.32);opacity:1;z-index:898;display:none;border-bottom-left-radius:6px;border-bottom-right-radius:6px;margin:1px;cursor:progress}.busy-mask.active{display:block}\n"] }]
1739
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: MetaResourceService }, { type: MetaContextService }, { type: MetaMsgService }]; }, propDecorators: { resource: [{
1740
+ type: Input
1741
+ }], model: [{
1742
+ type: Input
1743
+ }], metaResourceServiceDelegated: [{
1744
+ type: Input
1745
+ }], theme: [{
1746
+ type: Input
1747
+ }], done: [{
1748
+ type: Output
1749
+ }] } });
1750
+
1751
+ class MetaRefDialog {
1752
+ constructor(el) {
1753
+ this.el = el;
1754
+ this.resources = {};
1755
+ this.models = {};
1756
+ this.services = {};
1757
+ this.keepOrder = (a, b) => a;
1758
+ this.keyEventListener = (event) => {
1759
+ if (event && event.key === 'Escape') {
1760
+ document.removeEventListener('keydown', this.keyEventListener);
1761
+ this.dismiss();
1762
+ }
1763
+ };
1764
+ }
1765
+ get isEditable() {
1766
+ return this.resources[this.currentResource].meta.layout.editable !== false;
1767
+ }
1768
+ get isPersistent() {
1769
+ return this.resource && (this.resource.externalId || this.resource.id);
1770
+ }
1771
+ ngOnInit() {
1772
+ let references = (this.reference instanceof Array) ? this.reference : [this.reference];
1773
+ /* eslint-disable no-underscore-dangle */
1774
+ if (this.resource && this.resource._vgis) {
1775
+ this.fullResource = this.resource;
1776
+ this.resource = this.resource._vgis;
1777
+ }
1778
+ /* eslint-enable no-underscore-dangle */
1779
+ if (this.resource) {
1780
+ references = references.filter((r) => {
1781
+ const resType = r.name || r.resourceType || '';
1782
+ // comparing case insensitive, because of Zendesk comment vs Comment
1783
+ return (resType.id || resType || '').toLowerCase() === (this.resource.resourceType || this.resource.type || '').toLowerCase();
1784
+ });
1785
+ }
1786
+ for (const ref of references) {
1787
+ if (!ref.name) {
1788
+ ref.name = ref.resourceType; // when the resource comes from resources API, not from metadata
1789
+ }
1790
+ if (!this.currentResource) {
1791
+ this.currentResource = ref.name;
1792
+ }
1793
+ if (ref.name === this.preferResourceType) {
1794
+ this.currentResource = this.preferResourceType;
1795
+ }
1796
+ const rs = {
1797
+ integrationCode: this.integrationCode,
1798
+ resourceType: ref.resourceType || ref.name,
1799
+ ref
1800
+ };
1801
+ if (this.resource) {
1802
+ rs.externalId = this.resource.id || this.resource.externalId;
1803
+ if (this.resource.eventId) {
1804
+ rs.eventId = this.resource.eventId;
1805
+ }
1806
+ if (this.fullResource) {
1807
+ rs.activity = this.fullResource;
1808
+ }
1809
+ if (this.resource.layoutId) {
1810
+ rs.layoutId = this.resource.layoutId;
1811
+ }
1812
+ }
1813
+ rs.parent = ref.parent;
1814
+ this.resources[ref.name] = rs;
1815
+ this.models[ref.name] = {};
1816
+ if (this.resource) {
1817
+ this.models[ref.name]._vgis = this.resource; // eslint-disable-line no-underscore-dangle
1818
+ }
1819
+ }
1820
+ this.modal = this.el.nativeElement.childNodes[0];
1821
+ this.modal.classList.remove('Vlt-modal--out');
1822
+ this.modal.classList.add('Vlt-modal_visible');
1823
+ document.addEventListener('keydown', this.keyEventListener);
1824
+ if (this.integrationCode === 'mocks') {
1825
+ this.integrationIcon = 'Brand-icon-vonage';
1826
+ }
1827
+ else {
1828
+ switch (this.integrationCode.toLowerCase()) {
1829
+ case 'office365':
1830
+ this.integrationIcon = 'Brand-icon-office-color';
1831
+ break;
1832
+ case 'sugar':
1833
+ this.integrationIcon = 'Brand-icon-sugarcrm-color';
1834
+ break;
1835
+ case 'msdynamics':
1836
+ this.integrationIcon = 'Brand-icon-dynamics-color';
1837
+ break;
1838
+ default:
1839
+ this.integrationIcon = `Brand-icon-${(this.integrationCode || '').toLowerCase()}-color`;
1840
+ }
1841
+ }
1842
+ this.applyTheme();
1843
+ }
1844
+ close() {
1845
+ this.modal.classList.remove('Vlt-modal_visible');
1846
+ this.modal.classList.add('Vlt-modal--out');
1847
+ }
1848
+ dismiss() {
1849
+ this.close();
1850
+ this.onComplete(null);
1851
+ }
1852
+ onResourceDone(result) {
1853
+ this.close();
1854
+ this.onComplete(result);
1855
+ }
1856
+ selectResource(resource) {
1857
+ this.currentResource = resource;
1858
+ }
1859
+ applyTheme() {
1860
+ const metaTheme = this.theme === 'dark' ? metaDark : metaLight;
1861
+ for (const key of Object.keys(metaTheme.properties)) {
1862
+ this.el.nativeElement.style.setProperty(key, metaTheme.properties[key]);
1863
+ }
1864
+ }
1865
+ }
1866
+ MetaRefDialog.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: MetaRefDialog, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1867
+ MetaRefDialog.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.0", type: MetaRefDialog, selector: "ng-component", ngImport: i0, template: "<div class='Vlt-modal Vlt-modal--large'>\n <div class=\"Vlt-modal__panel\">\n <div class=\"Vlt-tabs\">\n <div class='Vlt-tabs__header--background'>\n <div class=\"Vlt-tabs__header Vlt-tabs__header--shadow\">\n <svg class=\"Vlt-icon\" [ngStyle]=\"{fill: integrationIcon === 'Brand-icon-vonage' ? 'var(--vgip-meta-input-color)' : ''}\"><use attr.xlink:href=\"volta/volta-brand-icons.svg#{{integrationIcon}}\" /></svg>\n <div *ngFor='let r of resources | keyvalue: keepOrder' (click)='selectResource(r.key)' class=\"Vlt-tabs__link\" [ngClass]=\"{ 'Vlt-tabs__link_active': currentResource === r.key}\">\n {{r.key}}\n </div>\n <div class=\"Vlt-modal__dismiss\" (click)=\"dismiss()\">\n <svg class=\"Vlt-icon\"><use xlink:href=\"volta/volta-icons.svg#Vlt-icon-cross\" /></svg>\n </div>\n </div>\n </div>\n <div class=\"Vlt-tabs__content\" style='min-height: 90px;'>\n <ng-container *ngFor='let r of resources | keyvalue: keepOrder'>\n <div *ngIf='currentResource === r.key' class=\"Vlt-tabs__panel Vlt-tabs__panel_active\">\n <vgip-meta-resource [resource]='r.value' [model]='models[r.key]' [metaResourceServiceDelegated]='metaResource' (done)='onResourceDone($event)' theme='inherit' [attr.data-theme]='theme'></vgip-meta-resource>\n </div>\n </ng-container>\n </div>\n </div>\n </div>\n</div>\n", styles: [".Vlt-modal_visible{background:var(--vgip-meta-overlay-background)}.Vlt-modal__panel{padding:0;background:var(--vgip-meta-resource-bg-color);overflow:hidden}@media only screen and (max-width: 575px){.Vlt-modal__panel{height:100%;width:100%;max-height:none;border-bottom-left-radius:0;border-bottom-right-radius:0;margin:10px 6px 0}.Vlt-modal__panel ::ng-deep .busy-mask{min-height:calc(100vh - 58px)}}.Vlt-modal__panel .Vlt-tabs__header--background{border-top-left-radius:5px;border-top-right-radius:5px}.Vlt-modal__panel .Vlt-tabs__header{background:var(--vgip-meta-resource-bar-color);padding-left:52px;padding-right:45px;border-bottom:0;flex-wrap:wrap;min-height:52px;max-height:52px;align-items:center}.Vlt-modal__panel .Vlt-tabs__header>.Vlt-icon{position:absolute;left:14px}.Vlt-modal__panel .Vlt-tabs__header h5{margin-bottom:0;font-weight:initial}.Vlt-modal__panel .Vlt-tabs__header .Vlt-tabs__link{padding-top:4px;padding-bottom:2px;color:var(--vgip-meta-input-label-color);text-transform:capitalize}.Vlt-modal__panel .Vlt-tabs__header .Vlt-tabs__link_active{color:var(--vgip-meta-input-accent-color)}.Vlt-modal__panel .Vlt-tabs__header .Vlt-tabs__link_active:after{background:var(--vgip-meta-input-accent-color)}.Vlt-modal__panel .Vlt-tabs__header .Vlt-modal__dismiss{background-image:none;width:18px;height:18px;opacity:initial}.Vlt-modal__panel .Vlt-tabs__header .Vlt-modal__dismiss svg{width:16px;height:16px;fill:var(--vgip-meta-input-label-color)}.Vlt-modal__panel .Vlt-tabs__header .Vlt-modal__dismiss:hover svg{fill:var(--vgip-meta-input-accent-color)}.Vlt-modal__panel .Vlt-tabs__header::-webkit-scrollbar{width:8px}.Vlt-modal__panel .Vlt-tabs__header::-webkit-scrollbar-thumb{background-color:var(--vgip-meta-scrollbar-color);border:2px solid transparent;border-radius:6px;background-clip:content-box}.Vlt-modal__panel .Vlt-tabs__content{margin-top:0}.Vlt-modal__panel .Vlt-tabs__content .Vlt-tabs__link{font-size:1.8rem}.Vlt-modal__panel .Vlt-callout--banner{justify-content:initial;text-align:initial;overflow-y:auto}.Vlt-modal__panel .Vlt-callout--banner.Vlt-callout--dismissed{padding:0}.Vlt-modal__panel .Vlt-callout--banner:not(.Vlt-callout--dismissed){min-height:78px}.Vlt-modal__panel .Vlt-modal__cancel{z-index:899}.Vlt-modal__panel .Vlt-modal__dismiss{right:16px;top:14px}.Vlt-modal__panel .Vlt-card__footer button{margin-top:0;margin-bottom:0}.Vlt-modal__panel .Vlt-select select:disabled{background:initial;cursor:not-allowed}.Vlt-modal__panel ::ng-deep .form-content{min-height:0;max-height:calc(95vh - 172px)}@media only screen and (max-width: 575px){.Vlt-modal__panel ::ng-deep .form-content{min-height:calc(100vh - 113px)}}.resource-menu button{margin:0 -10px}.resource-menu button:not(:hover) .Vlt-icon{color:#616266;fill:#616266}.busy-mask{position:absolute;inset:0;background:rgba(0,0,0,.32);opacity:1;z-index:898;display:none;border-bottom-left-radius:6px;border-bottom-right-radius:6px;margin:1px;cursor:progress}.busy-mask.active{display:block}\n"], dependencies: [{ kind: "directive", type: i1$2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1$2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: MetaResource, selector: "vgip-meta-resource", inputs: ["resource", "model", "metaResourceServiceDelegated", "theme"], outputs: ["done"] }, { kind: "pipe", type: i1$2.KeyValuePipe, name: "keyvalue" }] });
1868
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: MetaRefDialog, decorators: [{
1869
+ type: Component,
1870
+ args: [{ template: "<div class='Vlt-modal Vlt-modal--large'>\n <div class=\"Vlt-modal__panel\">\n <div class=\"Vlt-tabs\">\n <div class='Vlt-tabs__header--background'>\n <div class=\"Vlt-tabs__header Vlt-tabs__header--shadow\">\n <svg class=\"Vlt-icon\" [ngStyle]=\"{fill: integrationIcon === 'Brand-icon-vonage' ? 'var(--vgip-meta-input-color)' : ''}\"><use attr.xlink:href=\"volta/volta-brand-icons.svg#{{integrationIcon}}\" /></svg>\n <div *ngFor='let r of resources | keyvalue: keepOrder' (click)='selectResource(r.key)' class=\"Vlt-tabs__link\" [ngClass]=\"{ 'Vlt-tabs__link_active': currentResource === r.key}\">\n {{r.key}}\n </div>\n <div class=\"Vlt-modal__dismiss\" (click)=\"dismiss()\">\n <svg class=\"Vlt-icon\"><use xlink:href=\"volta/volta-icons.svg#Vlt-icon-cross\" /></svg>\n </div>\n </div>\n </div>\n <div class=\"Vlt-tabs__content\" style='min-height: 90px;'>\n <ng-container *ngFor='let r of resources | keyvalue: keepOrder'>\n <div *ngIf='currentResource === r.key' class=\"Vlt-tabs__panel Vlt-tabs__panel_active\">\n <vgip-meta-resource [resource]='r.value' [model]='models[r.key]' [metaResourceServiceDelegated]='metaResource' (done)='onResourceDone($event)' theme='inherit' [attr.data-theme]='theme'></vgip-meta-resource>\n </div>\n </ng-container>\n </div>\n </div>\n </div>\n</div>\n", styles: [".Vlt-modal_visible{background:var(--vgip-meta-overlay-background)}.Vlt-modal__panel{padding:0;background:var(--vgip-meta-resource-bg-color);overflow:hidden}@media only screen and (max-width: 575px){.Vlt-modal__panel{height:100%;width:100%;max-height:none;border-bottom-left-radius:0;border-bottom-right-radius:0;margin:10px 6px 0}.Vlt-modal__panel ::ng-deep .busy-mask{min-height:calc(100vh - 58px)}}.Vlt-modal__panel .Vlt-tabs__header--background{border-top-left-radius:5px;border-top-right-radius:5px}.Vlt-modal__panel .Vlt-tabs__header{background:var(--vgip-meta-resource-bar-color);padding-left:52px;padding-right:45px;border-bottom:0;flex-wrap:wrap;min-height:52px;max-height:52px;align-items:center}.Vlt-modal__panel .Vlt-tabs__header>.Vlt-icon{position:absolute;left:14px}.Vlt-modal__panel .Vlt-tabs__header h5{margin-bottom:0;font-weight:initial}.Vlt-modal__panel .Vlt-tabs__header .Vlt-tabs__link{padding-top:4px;padding-bottom:2px;color:var(--vgip-meta-input-label-color);text-transform:capitalize}.Vlt-modal__panel .Vlt-tabs__header .Vlt-tabs__link_active{color:var(--vgip-meta-input-accent-color)}.Vlt-modal__panel .Vlt-tabs__header .Vlt-tabs__link_active:after{background:var(--vgip-meta-input-accent-color)}.Vlt-modal__panel .Vlt-tabs__header .Vlt-modal__dismiss{background-image:none;width:18px;height:18px;opacity:initial}.Vlt-modal__panel .Vlt-tabs__header .Vlt-modal__dismiss svg{width:16px;height:16px;fill:var(--vgip-meta-input-label-color)}.Vlt-modal__panel .Vlt-tabs__header .Vlt-modal__dismiss:hover svg{fill:var(--vgip-meta-input-accent-color)}.Vlt-modal__panel .Vlt-tabs__header::-webkit-scrollbar{width:8px}.Vlt-modal__panel .Vlt-tabs__header::-webkit-scrollbar-thumb{background-color:var(--vgip-meta-scrollbar-color);border:2px solid transparent;border-radius:6px;background-clip:content-box}.Vlt-modal__panel .Vlt-tabs__content{margin-top:0}.Vlt-modal__panel .Vlt-tabs__content .Vlt-tabs__link{font-size:1.8rem}.Vlt-modal__panel .Vlt-callout--banner{justify-content:initial;text-align:initial;overflow-y:auto}.Vlt-modal__panel .Vlt-callout--banner.Vlt-callout--dismissed{padding:0}.Vlt-modal__panel .Vlt-callout--banner:not(.Vlt-callout--dismissed){min-height:78px}.Vlt-modal__panel .Vlt-modal__cancel{z-index:899}.Vlt-modal__panel .Vlt-modal__dismiss{right:16px;top:14px}.Vlt-modal__panel .Vlt-card__footer button{margin-top:0;margin-bottom:0}.Vlt-modal__panel .Vlt-select select:disabled{background:initial;cursor:not-allowed}.Vlt-modal__panel ::ng-deep .form-content{min-height:0;max-height:calc(95vh - 172px)}@media only screen and (max-width: 575px){.Vlt-modal__panel ::ng-deep .form-content{min-height:calc(100vh - 113px)}}.resource-menu button{margin:0 -10px}.resource-menu button:not(:hover) .Vlt-icon{color:#616266;fill:#616266}.busy-mask{position:absolute;inset:0;background:rgba(0,0,0,.32);opacity:1;z-index:898;display:none;border-bottom-left-radius:6px;border-bottom-right-radius:6px;margin:1px;cursor:progress}.busy-mask.active{display:block}\n"] }]
1871
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
1872
+
1873
+ var index = /*#__PURE__*/Object.freeze({
1874
+ __proto__: null,
1875
+ MetaRefDialog: MetaRefDialog
1876
+ });
1877
+
1878
+ export { MetaRefDialog as M, MetaResourceService as a, MetaReferenceService as b, MetaLayout as c, MetaResource as d, MetaAutofocusDirective as e, MetaMsgService as f, MetaHttpClient as g, metaNormalizer as m };
1879
+ //# sourceMappingURL=vgip-meta-ui-index-3907f4b1.mjs.map