@vgip/meta-ui 1.7.0 → 1.7.2

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