@vgip/meta-ui 2.1.3 → 2.1.5

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 (111) hide show
  1. package/fesm2022/vgip-meta-ui.mjs +6092 -0
  2. package/fesm2022/vgip-meta-ui.mjs.map +1 -0
  3. package/index.d.ts +709 -0
  4. package/package.json +15 -3
  5. package/.eslintrc.json +0 -57
  6. package/karma.conf.js +0 -35
  7. package/ng-package.json +0 -10
  8. package/src/lib/common/fieldNormalizer/boolean.ts +0 -11
  9. package/src/lib/common/fieldNormalizer/datetime.ts +0 -8
  10. package/src/lib/common/fieldNormalizer/index.ts +0 -171
  11. package/src/lib/common/fieldNormalizer/number.ts +0 -13
  12. package/src/lib/common/fieldNormalizer/options.ts +0 -48
  13. package/src/lib/common/fieldNormalizer/radio.ts +0 -29
  14. package/src/lib/common/fieldNormalizer/reference.ts +0 -32
  15. package/src/lib/common/fieldNormalizer/richtext.ts +0 -15
  16. package/src/lib/common/fieldNormalizer/string.ts +0 -23
  17. package/src/lib/common/fieldNormalizer/text.ts +0 -17
  18. package/src/lib/common/fieldNormalizer/uniqueNameFilter.ts +0 -21
  19. package/src/lib/common/metaAutofocus.directive.ts +0 -31
  20. package/src/lib/common/metaContext.resolver.ts +0 -25
  21. package/src/lib/common/metaIcons.pipe.spec.ts +0 -15
  22. package/src/lib/common/metaIcons.pipe.ts +0 -29
  23. package/src/lib/common/metaModel.pipe.ts +0 -19
  24. package/src/lib/common/metaNormalizer.ts +0 -366
  25. package/src/lib/common/metaStripHtml.pipe.ts +0 -18
  26. package/src/lib/common/utils/colorThemes.ts +0 -86
  27. package/src/lib/common/utils/indexedDbStore/index.ts +0 -244
  28. package/src/lib/common/utils/indexedDbStore/indexedDbStore.spec.ts +0 -149
  29. package/src/lib/common/utils/relativeTimeBuilder.ts +0 -49
  30. package/src/lib/common/utils/resourceCardLabel.ts +0 -25
  31. package/src/lib/common/utils/smartProp.spec.ts +0 -24
  32. package/src/lib/common/utils/smartProp.ts +0 -28
  33. package/src/lib/common/utils/templateBuilder.ts +0 -99
  34. package/src/lib/field.scss +0 -207
  35. package/src/lib/fieldAbstract.ts +0 -327
  36. package/src/lib/fieldBoolean/index.ts +0 -55
  37. package/src/lib/fieldBoolean/style.scss +0 -22
  38. package/src/lib/fieldBoolean/test.spec.ts +0 -43
  39. package/src/lib/fieldBoolean/view.html +0 -30
  40. package/src/lib/fieldComposite/index.ts +0 -86
  41. package/src/lib/fieldComposite/style.scss +0 -6
  42. package/src/lib/fieldComposite/test.spec.ts +0 -43
  43. package/src/lib/fieldComposite/view.html +0 -9
  44. package/src/lib/fieldDatetime/index.ts +0 -359
  45. package/src/lib/fieldDatetime/style.scss +0 -81
  46. package/src/lib/fieldDatetime/test.spec.ts +0 -43
  47. package/src/lib/fieldDatetime/view.html +0 -26
  48. package/src/lib/fieldHidden/index.ts +0 -15
  49. package/src/lib/fieldHidden/view.html +0 -0
  50. package/src/lib/fieldInput/index.ts +0 -477
  51. package/src/lib/fieldInput/style.scss +0 -128
  52. package/src/lib/fieldInput/test.spec.ts +0 -43
  53. package/src/lib/fieldInput/view.html +0 -81
  54. package/src/lib/fieldList/index.ts +0 -73
  55. package/src/lib/fieldList/style.scss +0 -26
  56. package/src/lib/fieldList/test.spec.ts +0 -43
  57. package/src/lib/fieldList/view.html +0 -25
  58. package/src/lib/fieldRadio/index.ts +0 -93
  59. package/src/lib/fieldRadio/style.scss +0 -32
  60. package/src/lib/fieldRadio/test.spec.ts +0 -43
  61. package/src/lib/fieldRadio/view.html +0 -24
  62. package/src/lib/fieldReference/index.ts +0 -871
  63. package/src/lib/fieldReference/style.scss +0 -273
  64. package/src/lib/fieldReference/test.spec.ts +0 -44
  65. package/src/lib/fieldReference/view.html +0 -163
  66. package/src/lib/fieldRichtext/index.ts +0 -98
  67. package/src/lib/fieldRichtext/quill.scss +0 -6
  68. package/src/lib/fieldRichtext/style.scss +0 -87
  69. package/src/lib/fieldRichtext/test.spec.ts +0 -43
  70. package/src/lib/fieldRichtext/view.html +0 -17
  71. package/src/lib/fieldSelect/index.ts +0 -597
  72. package/src/lib/fieldSelect/style.scss +0 -165
  73. package/src/lib/fieldSelect/test.spec.ts +0 -44
  74. package/src/lib/fieldSelect/view.html +0 -128
  75. package/src/lib/fieldText/index.ts +0 -86
  76. package/src/lib/fieldText/style.scss +0 -24
  77. package/src/lib/fieldText/test.spec.ts +0 -43
  78. package/src/lib/fieldText/view.html +0 -23
  79. package/src/lib/fieldUnknown/index.ts +0 -15
  80. package/src/lib/fieldUnknown/test.spec.ts +0 -34
  81. package/src/lib/fieldUnknown/view.html +0 -9
  82. package/src/lib/index.ts +0 -127
  83. package/src/lib/layout/index.ts +0 -255
  84. package/src/lib/layout/style.scss +0 -67
  85. package/src/lib/layout/view.html +0 -45
  86. package/src/lib/metaField/index.ts +0 -133
  87. package/src/lib/metaField/test.spec.ts +0 -32
  88. package/src/lib/refDialog/index.ts +0 -157
  89. package/src/lib/refDialog/style.scss +0 -154
  90. package/src/lib/refDialog/view.html +0 -24
  91. package/src/lib/resource/index.ts +0 -559
  92. package/src/lib/resource/style.scss +0 -132
  93. package/src/lib/resource/view.html +0 -70
  94. package/src/lib/resourceCard/index.ts +0 -44
  95. package/src/lib/resourceCard/style.scss +0 -7
  96. package/src/lib/resourceCard/view.html +0 -14
  97. package/src/lib/services/metaContext/index.ts +0 -61
  98. package/src/lib/services/metaMsg/index.ts +0 -84
  99. package/src/lib/services/metaReference/index.ts +0 -98
  100. package/src/lib/services/metaResource/index.ts +0 -163
  101. package/src/lib/services/metaResource/metaHttpClient.ts +0 -76
  102. package/src/lib/services/metaResource/metaResource.spec.ts +0 -24
  103. package/src/lib/services/metaTracker/index.ts +0 -38
  104. package/src/lib/services/resourceDrafts/index.ts +0 -81
  105. package/src/lib/services/resourceDrafts/resourceDrafts.spec.ts +0 -24
  106. package/src/lib/styles.scss +0 -13
  107. package/src/public-api.ts +0 -5
  108. package/src/test.ts +0 -17
  109. package/tsconfig.lib.json +0 -25
  110. package/tsconfig.lib.prod.json +0 -9
  111. package/tsconfig.spec.json +0 -17
@@ -1,86 +0,0 @@
1
- import { Component, OnInit, DoCheck } from '@angular/core';
2
- import { FieldAbstract } from '../fieldAbstract';
3
-
4
- @Component({
5
- templateUrl: './view.html',
6
- styleUrls: ['./style.scss'],
7
- standalone: false
8
- })
9
- export class FieldComposite extends FieldAbstract implements OnInit, DoCheck {
10
- // @Input() meta: any;
11
- // @Input() parent: any;
12
- value: any;
13
- private invisible;
14
-
15
- get isRow() {
16
- return this.meta.subtype !== 'column';
17
- }
18
-
19
- get fields() {
20
- return (this.meta.fields || []).map((f) => {
21
- if (f.type === 'textarea') { // no textareas inside composite (use string)
22
- delete f.type;
23
- }
24
- return f;
25
- });
26
- }
27
-
28
- ngOnInit() {
29
- // super.ngOnInit()
30
- let nestedFieldsRegex: RegExp;
31
- if (this.meta.name) {
32
- this.scope += `${this.meta.name}_`;
33
- this.value = this.parent[this.meta.name] || {};
34
- nestedFieldsRegex = new RegExp(`^${this.meta.name}\\.(.*)`);
35
- Object.defineProperty(this.parent, this.meta.name, {
36
- set: (value) => {
37
- if (value) {
38
- for (const v of Object.keys(value)) {
39
- this.value[v] = value[v];
40
- }
41
- }
42
- },
43
- get: () => {
44
- if (JSON.stringify(this.value) !== '{}') {
45
- return this.value;
46
- }
47
- },
48
- enumerable: this.sendToServer,
49
- configurable: true
50
- });
51
- for (const f of this.meta.fields) {
52
- if (this.isRow) {
53
- if (f.type === 'text') {
54
- f.type = 'string';
55
- }
56
- }
57
- const nestedFieldMatch = (f.name || '').match(nestedFieldsRegex);
58
- if (nestedFieldMatch) {
59
- f.name = nestedFieldMatch[1]; // for VGIS V2 backward compatibility normalize name with dotted syntax
60
- }
61
- }
62
- } else {
63
- this.value = this.parent;
64
- }
65
- }
66
-
67
- ngDoCheck(): void {
68
- if (typeof (this.invisible) !== 'undefined') {
69
- if (this.invisible !== this.meta.$invisible) {
70
- if (this.meta.$invisible === false) {
71
- if (typeof (this.meta.name) !== 'undefined') {
72
- this.parent[this.meta.name] = this.value;
73
- }
74
- }
75
- this.invisible = this.meta.$invisible;
76
- }
77
- } else {
78
- this.invisible = this.meta.$invisible;
79
- }
80
- }
81
-
82
- onValueChange(): void {
83
- this.onChange.emit(this.value);
84
- }
85
-
86
- }
@@ -1,6 +0,0 @@
1
- div > vgip-meta-field {
2
- display: none;
3
- &.shown {
4
- display: initial;
5
- }
6
- }
@@ -1,43 +0,0 @@
1
- /*
2
- * @Author: Alexander.Vangelov@vonage.com
3
- * @Date: 2019-09-19 17:35:19
4
- * @Last Modified by: Alexander.Vangelov@vonage.com
5
- * @Last Modified time: 2022-01-19 08:55:10
6
- */
7
-
8
- import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
9
- import { NgForm } from '@angular/forms';
10
-
11
- import { MetaModule } from '..';
12
-
13
- import { FieldComposite } from '../fieldComposite';
14
-
15
- describe('FieldComposite', () => {
16
- let component: FieldComposite;
17
- let fixture: ComponentFixture<FieldComposite>;
18
-
19
- beforeEach(waitForAsync(() => {
20
- TestBed.configureTestingModule({
21
- declarations: [],
22
- imports: [
23
- MetaModule
24
- ],
25
- providers: [
26
- { provide: NgForm, useValue: new NgForm([], []) }
27
- ]
28
- })
29
- .compileComponents();
30
- }));
31
-
32
- beforeEach(() => {
33
- fixture = TestBed.createComponent(FieldComposite);
34
- component = fixture.componentInstance;
35
- component.parent = {};
36
- component.meta = { fields: [{ name: 'f2' }] };
37
- fixture.detectChanges();
38
- });
39
-
40
- it('should create', () => {
41
- expect(component).toBeTruthy();
42
- });
43
- });
@@ -1,9 +0,0 @@
1
- <div [ngClass]="{ 'Vlt-grid Vlt-grid--narrow': isRow }">
2
- <ng-container *ngFor='let field of fields'>
3
- <div style='margin: 0;' [ngClass]="{ 'Vlt-col': isRow, 'Vlt-col--1of3': isRow && fields.length > 3 }" *ngIf="!field.$invisible">
4
- <vgip-meta-field *ngIf='!meta.$invisible' [ngClass]="{ shown: !field.$invisible}" [index]='index' [scope]='scope' [meta]='field'
5
- [parent]='value' [integrationCode]='integrationCode' [resourceType]='resourceType' [preview]='preview' (onChange)='onValueChange()'
6
- theme='inherit'></vgip-meta-field>
7
- </div>
8
- </ng-container>
9
- </div>
@@ -1,359 +0,0 @@
1
- /*
2
- * @Author: Alexander.Vangelov@vonage.com
3
- * @Date: 2020-04-18 18:05:46
4
- * @Last Modified by: Alexander.Vangelov@vonage.com
5
- * @Last Modified time: 2020-04-18 21:09:16
6
- */
7
-
8
- import { Component, OnInit } from '@angular/core';
9
- import { ControlContainer, NgForm } from '@angular/forms';
10
-
11
- import { FieldAbstract } from '../fieldAbstract';
12
- import { relativeTimeBuilder } from '../common/utils/relativeTimeBuilder';
13
-
14
- @Component({
15
- templateUrl: './view.html',
16
- styleUrls: ['./style.scss'],
17
- viewProviders: [{ provide: ControlContainer, useExisting: NgForm }],
18
- standalone: false
19
- })
20
- export class FieldDatetime extends FieldAbstract implements OnInit {
21
- input: any;
22
- dropdown: any;
23
- activeSuggestionIndex: number;
24
- value: any;
25
- type: string;
26
- placeholder = 'dd/mm/yyyy';
27
-
28
- get suggestions() {
29
- return this.meta.suggestions || [];
30
- }
31
-
32
- ngOnInit() {
33
- this.validationAttributes = ['required', 'min', 'max', 'step'];
34
- this.type = this.meta.type;
35
- if (this.meta.type === 'datetime') {
36
- this.type = 'datetime-local';
37
- this.placeholder += ' --:-- --';
38
- } else if (this.meta.type === 'time') {
39
- this.placeholder = '--:-- --';
40
- }
41
- const origValue = this.parent[this.meta.name];
42
- Object.defineProperty(this.parent, this.meta.name, {
43
- set: (value) => {
44
- if (value) {
45
- if (['datetime', 'date', 'datetime-local'].indexOf(this.meta.type || this.meta.subtype) !== -1 && value) {
46
- try {
47
- let date: Date;
48
- if ((typeof (value) === 'number')) {
49
- date = new Date(parseInt(value as any, 10));
50
- if ('date' === (this.meta.type || this.meta.subtype)) {
51
- date = new Date(date.getTime() + (date.getTimezoneOffset() * 60000));
52
- }
53
- } else {
54
- if ('date' === (this.meta.type || this.meta.subtype)) {
55
- date = new Date(Date.parse(value));
56
- } else {
57
- date = new Date(Date.parse(`${value}Z`) + (new Date().getTimezoneOffset() * 60000));
58
- }
59
- }
60
- switch (this.meta.type || this.meta.subtype) {
61
- case 'datetime-local':
62
- case 'datetime': {
63
- this.model = `${date.getFullYear()}-${('00' + (date.getMonth() + 1)).slice(-2)}-${('00' + date.getDate()).slice(-2)}`;
64
- this.model += `T${('00' + date.getHours()).slice(-2)}:${('00' + date.getMinutes()).slice(-2)}`;
65
- break;
66
- }
67
- case 'date': {
68
- this.model = date.toISOString().split('T')[0];
69
- break;
70
- }
71
- }
72
- if (this.meta.valueType === 'isostring') {
73
- this.value = date.toISOString();
74
- } else if (this.meta.valueType === 'string') {
75
- if ((this.meta.type || this.meta.subtype) === 'date') {
76
- this.value = date.toISOString().split('T')[0];
77
- } else {
78
- this.value = date.toISOString();
79
- }
80
- } else {
81
- if ((this.meta.type || this.meta.subtype) === 'date') {
82
- date.setFullYear(date.getUTCFullYear());
83
- date.setMonth(date.getUTCMonth());
84
- date.setDate(date.getUTCDate());
85
- date.setMinutes(0);
86
- date.setHours(0);
87
- date.setSeconds(0);
88
- date.setMilliseconds(0);
89
- this.value = new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).getTime();
90
- } else {
91
- this.value = date.getTime();
92
- }
93
- }
94
- } catch (e) {
95
- console.error('Date parse error', e.message, `"${value}"`, `(${typeof (value)})`);
96
- }
97
- } else if ('time' === (this.meta.type || this.meta.subtype)) {
98
- try {
99
- let date: Date;
100
- if (typeof (value) === 'number') {
101
- date = new Date(parseInt(value as any, 10));
102
- if (value < 86400000) {
103
- date = new Date(date.getTime() + (date.getTimezoneOffset() * 60000));
104
- }
105
- } else {
106
- date = new Date(
107
- Date.parse(new Date().toISOString().replace(/T.*Z/, `T${value}Z`)) + (new Date().getTimezoneOffset() * 60000)
108
- );
109
- }
110
- this.model = date.toTimeString().split(' ')[0];
111
- if (this.meta.valueType === 'isostring') {
112
- this.value = date.toISOString();
113
- } else {
114
- date.setFullYear(1970);
115
- date.setMonth(0);
116
- date.setDate(1);
117
- date.setMilliseconds(0);
118
- if (this.meta.valueType === 'string') {
119
- this.value = new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toISOString().split('T')[1].substring(0,8);
120
- } else {
121
- this.value = new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).getTime();
122
- }
123
- }
124
- } catch (e) {
125
- console.error('Date parse error', e.message, `"${value}"`, `(${typeof (value)})`);
126
- }
127
- }
128
- } else {
129
- delete this.model;
130
- delete this.value;
131
- }
132
- this.meta.$optional = this.isOptional;
133
- },
134
- get: () => this.value,
135
- enumerable: this.sendToServer,
136
- configurable: true
137
- });
138
- if (typeof(origValue) !== 'undefined') {
139
- this.parent[this.meta.name] = origValue;
140
- }
141
- const d = this.meta.default || this.meta.defaultValue;
142
- if (d && typeof(this.model) === 'undefined') {
143
- const defaultValue = ((typeof (d) === 'string') || (typeof (d) === 'number')) ? d : (d.id || d.value);
144
- if (defaultValue || defaultValue === 0) {
145
- if (/^(date|time)/.test(this.meta.type || this.meta.subtype) && typeof(defaultValue) === 'string') {
146
- this.parent[this.meta.name] = relativeTimeBuilder(this.meta.type || this.meta.subtype, defaultValue, this.validations.step);
147
- } else {
148
- this.parent[this.meta.name] = defaultValue;
149
- }
150
- }
151
- }
152
- if (typeof(this.meta.auto) === 'object') {
153
- Object.keys(this.meta.auto || {}).filter(n => ['gt', 'lt'].indexOf(n) !== -1).map(v => this.setupLogicalValidation(v));
154
- }
155
- }
156
-
157
- onActivated(ev) {
158
- this.input = ev.srcElement;
159
- if (!this.dropdown) {
160
- this.dropdown = ev.srcElement.parentNode.parentNode;
161
- }
162
- this.showDropdown();
163
- }
164
-
165
- clear(ev?) {
166
- delete this.model;
167
- this.onModelChange(this.model);
168
- if (ev) {
169
- ev.preventDefault();
170
- ev.stopPropagation();
171
- return false;
172
- }
173
- }
174
-
175
- onBlur(ev) {
176
- let internalControl = false;
177
- if (ev.relatedTarget) {
178
- if (!this.elementRef.nativeElement.contains(ev.relatedTarget)) {
179
- this.dismissDropdown();
180
- } else {
181
- internalControl = true;
182
- }
183
- }
184
- if (this.keyListenerActive && !internalControl) {
185
- this.input.removeEventListener('keydown', this.keydown);
186
- setTimeout(() => {
187
- if (!this.keyListenerActive) {
188
- document.removeEventListener('click', this.clickout);
189
- }
190
- }, 400);
191
- delete this.keyListenerActive;
192
- }
193
- }
194
-
195
- onSuggestionSelect(ev, suggestion) {
196
- if (!suggestion) {
197
- return;
198
- }
199
- ev.preventDefault();
200
- ev.stopPropagation();
201
- this.focus();
202
- this.dismissDropdown();
203
- this.model = suggestion;
204
- this.onModelChange(suggestion);
205
- }
206
-
207
- dismissDropdown(event?) {
208
- if (event) {
209
- this.focus();
210
- }
211
- if (this.dropdown) {
212
- this.dropdown.classList.remove('Vlt-dropdown--expanded');
213
- }
214
- }
215
-
216
- private ensureDropdownIsVisible() {
217
- setTimeout(() => {
218
- const holder = this.dropdown.closest('.Vlt-card__content, .Vlt-modal__content');
219
- if (holder) {
220
- const el = this.elementRef.nativeElement.querySelector('.Vlt-dropdown__panel');
221
- const elRect = el.getBoundingClientRect();
222
- const holderRect = holder.getBoundingClientRect();
223
- if (holderRect.top + holderRect.height < elRect.top + elRect.height) {
224
- el.scrollIntoView({ block: 'end' });
225
- }
226
- }
227
- }, 400);
228
- }
229
-
230
- private showDropdown() {
231
- if (this.meta.suggestions?.length) {
232
- this.dropdown.classList.add('Vlt-dropdown--expanded');
233
- this.ensureDropdownIsVisible();
234
- }
235
- if (!this.keyListenerActive) {
236
- this.input.addEventListener('keydown', this.keydown);
237
- setTimeout(() => {
238
- document.addEventListener('click', this.clickout);
239
- }, 200);
240
- this.keyListenerActive = true;
241
- if (this.parent[this.meta.name]) {
242
- for (let suggestionIndex = 0; suggestionIndex < (this.meta.suggestions || []).length; suggestionIndex++) {
243
- if (this.meta.suggestions[suggestionIndex] === this.parent[this.meta.name]) {
244
- this.activeSuggestionIndex = suggestionIndex;
245
- }
246
- }
247
- }
248
- }
249
- }
250
-
251
- private clickout = (event) => {
252
- if (event.target.className === 'Vlt-dropdown__link' && this.elementRef.nativeElement.contains(event.target)) {
253
- this.focus();
254
- // this.dismissDropdown();
255
- // this.parent[this.meta.name] = event.target.textContent;
256
-
257
- } else if (event.target !== this.input && event.target.className !== 'Vlt-dropdown__title') {
258
- this.dismissDropdown();
259
- } else {
260
- this.focus();
261
- }
262
- };
263
-
264
- private keydown = (event) => {
265
- switch (event.key) {
266
- case 'ArrowDown': {
267
- if (['datetime', 'time', 'date', 'datetime-local'].indexOf(this.meta.type || this.meta.subtype) !== -1) {
268
- break;
269
- }
270
- this.showDropdown();
271
- event.preventDefault();
272
- if (typeof (this.activeSuggestionIndex) === 'undefined') {
273
- this.activeSuggestionIndex = 0;
274
- } else {
275
- this.activeSuggestionIndex++;
276
- if (this.activeSuggestionIndex >= this.suggestions.length) {
277
- this.activeSuggestionIndex = 0;
278
- }
279
- }
280
- break;
281
- }
282
- case 'ArrowUp': {
283
- if (['datetime', 'time', 'date', 'datetime-local'].indexOf(this.meta.type || this.meta.subtype) !== -1) {
284
- break;
285
- }
286
- this.showDropdown();
287
- event.preventDefault();
288
- if (typeof (this.activeSuggestionIndex) === 'undefined') {
289
- this.activeSuggestionIndex = this.suggestions.length - 1;
290
- } else {
291
- this.activeSuggestionIndex--;
292
- if (this.activeSuggestionIndex < 0) {
293
- this.activeSuggestionIndex = this.suggestions.length - 1;
294
- }
295
- }
296
- break;
297
- }
298
- case 'Space':
299
- case 'Enter': {
300
- if (typeof (this.activeSuggestionIndex) !== 'undefined') {
301
- event.preventDefault();
302
- event.stopPropagation();
303
- this.onSuggestionSelect(event, this.suggestions[this.activeSuggestionIndex]);
304
- delete this.activeSuggestionIndex;
305
- }
306
- break;
307
- }
308
- case 'Escape': {
309
- event.preventDefault();
310
- event.stopPropagation();
311
- this.dismissDropdown();
312
- break;
313
- }
314
- }
315
- };
316
-
317
-
318
- private autoSetValue(againstTimestamp, v, cfg) {
319
- const compareValue = relativeTimeBuilder(this.meta.type, cfg.offset, this.validations.step, againstTimestamp);
320
- if (this.model) {
321
- const currentValue = new Date(this.model).getTime();
322
- let isInvalid: boolean;
323
- if (v === 'gt') {
324
- isInvalid = compareValue > currentValue;
325
- } else if (v === 'lt') {
326
- isInvalid = currentValue > compareValue;
327
- }
328
- if (isInvalid) {
329
- this.parent[this.meta.name] = compareValue;
330
- }
331
- } else {
332
- this.parent[this.meta.name] = compareValue;
333
- }
334
- }
335
-
336
- private setupLogicalValidation(v: string) {
337
- const cfg = this.meta.auto[v];
338
- if (typeof(cfg.against) === 'string') {
339
- let againstValue = this.parent[cfg.against];
340
- try {
341
- let againstTimestamp = Date.parse(`${againstValue}Z`) + (new Date().getTimezoneOffset() * 60000);
342
- if (againstValue) {
343
- this.autoSetValue(againstTimestamp, v, cfg);
344
- }
345
- this.parentChangeSubject.subscribe((value) => {
346
- if (value && value.hasOwnProperty(cfg.against)) {
347
- againstValue = value[cfg.against];
348
- if (againstValue) {
349
- againstTimestamp = Date.parse(`${againstValue}Z`) + (new Date().getTimezoneOffset() * 60000);
350
- this.autoSetValue(againstTimestamp, v, cfg);
351
- }
352
- }
353
- });
354
- } catch (e) {
355
- if ((window as any).scDebug) console.error(e);
356
- }
357
- }
358
- }
359
- }
@@ -1,81 +0,0 @@
1
- .Vlt-form__element--big {
2
- &.Vlt-form__element--error {
3
- input.main, .Vlt-composite__append button {
4
- background: var(--vgip-meta-input-bg-color);
5
- border-color: #f25a6b;
6
- box-shadow: none;
7
- }
8
- }
9
- }
10
-
11
- @-moz-document url-prefix() {
12
- .Vlt-composite__append.right-actions {
13
- right: 10px !important;
14
- }
15
- }
16
-
17
- .Vlt-composite__append.right-actions {
18
- position: absolute;
19
- top: 5px;
20
- right: 10px;
21
- cursor: pointer;
22
- @media screen and (-webkit-min-device-pixel-ratio:0) and (min-resolution:.001dpcm) {
23
- right: 53px;
24
- }
25
- .Vlt-composite__append--icon {
26
- width: 36px;
27
- outline: none;
28
- position: initial;
29
- display: inline-block;
30
- svg {
31
- height: 14px;
32
- width: 14px;
33
- }
34
- }
35
- .Vlt-composite__append--icon:hover svg, .Vlt-composite__append--icon:focus svg {
36
- fill: #2c2d30;
37
- }
38
- }
39
-
40
- .vgip-disable .Vlt-composite__append{
41
- cursor: not-allowed;
42
- pointer-events: none;
43
- }
44
-
45
- :host-context {
46
- ::ng-deep {
47
- input::-webkit-calendar-picker-indicator {
48
- height: 48px;
49
- width: 51px;
50
- margin-top: -15px;
51
- margin-right: -15px;
52
- padding: 0 2px 0 0;
53
- cursor: pointer;
54
- color: transparent;
55
- background-origin: content-box;
56
- background-size: initial;
57
- background-repeat: no-repeat;
58
- background-position: center;
59
- opacity: 1;
60
- visibility: visible;
61
- background-image: var(--vgip-meta-date-icon)
62
- }
63
- input::-webkit-calendar-picker-indicator:hover {
64
- background-color: var(--vgip-meta-input-action-hover-bg-color);
65
- }
66
- input[type='time']::-webkit-calendar-picker-indicator {
67
- background-image: var(--vgip-meta-time-icon)
68
- }
69
- input[readonly]::-webkit-calendar-picker-indicator {
70
- visibility: visible;
71
- }
72
- input:enabled:read-write:-webkit-any(:focus,:hover)::-webkit-clear-button {
73
- opacity: 0;
74
- pointer-events: none;
75
- }
76
- input:enabled:read-write:-webkit-any(:focus,:hover)::-webkit-inner-spin-button {
77
- opacity: 0;
78
- pointer-events: none;
79
- }
80
- }
81
- }
@@ -1,43 +0,0 @@
1
- /*
2
- * @Author: Alexander.Vangelov@vonage.com
3
- * @Date: 2020-04-18 18:10:03
4
- * @Last Modified by: Alexander.Vangelov@vonage.com
5
- * @Last Modified time: 2020-04-18 18:10:03
6
- */
7
-
8
- import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
9
- import { NgForm } from '@angular/forms';
10
-
11
- import { MetaModule } from '..';
12
-
13
- import { FieldDatetime } from '.';
14
-
15
- describe('FieldDatetime', () => {
16
- let component: FieldDatetime;
17
- let fixture: ComponentFixture<FieldDatetime>;
18
-
19
- beforeEach(waitForAsync(() => {
20
- TestBed.configureTestingModule({
21
- declarations: [],
22
- imports: [
23
- MetaModule
24
- ],
25
- providers: [
26
- { provide: NgForm, useValue: new NgForm([], []) }
27
- ]
28
- })
29
- .compileComponents();
30
- }));
31
-
32
- beforeEach(() => {
33
- fixture = TestBed.createComponent(FieldDatetime);
34
- component = fixture.componentInstance;
35
- component.parent = {};
36
- component.meta = { name: 'f1' };
37
- fixture.detectChanges();
38
- });
39
-
40
- it('should create', () => {
41
- expect(component).toBeTruthy();
42
- });
43
- });
@@ -1,26 +0,0 @@
1
- <div class='vgip-meta-field-preview' *ngIf='preview && model'>
2
- <div class='vgip-meta-field-label' [title]='meta.label || meta.name'>{{meta.label || meta.name}}</div>
3
- <div class='vgip-meta-field-value __gu'>{{model}}</div>
4
- </div>
5
- <div *ngIf='!preview' class="Vlt-form__element Vlt-form__element--big" [ngClass]="{'Vlt-form__element--error': f.invalid && ((f | metaModel)._parent.submitted || (f | metaModel ).touched), 'has-value': f.value, active: keyListenerActive }">
6
- <div class="Vlt-input" [ngClass]="{'vgip-disable': disabled}">
7
- <label class='wrapper'>
8
- <input class='main model' [pattern]="validations.pattern ? validations.pattern.value || validations.pattern : null" [required]='validations.required' [minlength]='validations.minlength' [maxlength]='validations.maxlength' [min]='validations.min' [max]='validations.max' [step]='validations.step' [disabled]='disabled' [readonly]='readonly' [(ngModel)]='model' (ngModelChange)="onModelChange($event)" #f='ngModel' [name]='name' [type]="type" [placeholder]="placeholder" (click)='onActivated($event)' (focus)='onActivated($event)' (blur)='onBlur($event)'/>
9
- <label class='Vlt-truncate'>{{meta.label || meta.name}}<span *ngIf='validations.required' class='Vlt-red'>*</span></label> <!-- eslint-disable-line @angular-eslint/template/label-has-associated-control -->
10
- </label>
11
- <div class='Vlt-composite__append right-actions'>
12
- <a href='#' *ngIf='model' class="Vlt-composite__append--icon" (click)='clear($event)' tabindex='0'>
13
- <div class="Vlt-composite__icon">
14
- <svg><use xlink:href="volta/volta-icons.svg#Vlt-icon-cross"/></svg>
15
- </div>
16
- </a>
17
- </div>
18
- </div>
19
- <small *ngIf='f.invalid && ((f | metaModel)._parent.submitted || ((f | metaModel ).touched && keyListenerActive))' class="Vlt-form__element__error">
20
- <span *ngIf="f.errors.required">Required.&nbsp;</span>
21
- <span *ngIf="f.errors.min">Must be later than {{validations.min}}.&nbsp;</span>
22
- <span *ngIf="f.errors.max">Must be no later than {{validations}}.&nbsp;</span>
23
- <span *ngIf="f.errors.custom">{{f.errors.custom}}&nbsp;</span>
24
- </small>
25
- <small *ngIf='meta.hint' class="Vlt-form__element__hint">{{meta.hint}}</small>
26
- </div>
@@ -1,15 +0,0 @@
1
- /*
2
- * @Author: Alexander.Vangelov@vonage.com
3
- * @Date: 2019-09-19 17:35:19
4
- * @Last Modified by: Alexander.Vangelov@vonage.com
5
- * @Last Modified time: 2019-11-15 13:04:01
6
- */
7
-
8
- import { Component } from '@angular/core';
9
- import { FieldAbstract } from '../fieldAbstract';
10
-
11
- @Component({
12
- templateUrl: './view.html',
13
- standalone: false
14
- })
15
- export class FieldHidden extends FieldAbstract {}
File without changes