@vgip/meta-ui 2.0.0 → 2.1.0

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