@vgip/meta-ui 1.5.6 → 1.5.7

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