@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.
- package/fesm2022/vgip-meta-ui.mjs +6092 -0
- package/fesm2022/vgip-meta-ui.mjs.map +1 -0
- package/index.d.ts +709 -0
- package/package.json +15 -3
- package/.eslintrc.json +0 -57
- package/karma.conf.js +0 -35
- package/ng-package.json +0 -10
- package/src/lib/common/fieldNormalizer/boolean.ts +0 -11
- package/src/lib/common/fieldNormalizer/datetime.ts +0 -8
- package/src/lib/common/fieldNormalizer/index.ts +0 -171
- package/src/lib/common/fieldNormalizer/number.ts +0 -13
- package/src/lib/common/fieldNormalizer/options.ts +0 -48
- package/src/lib/common/fieldNormalizer/radio.ts +0 -29
- package/src/lib/common/fieldNormalizer/reference.ts +0 -32
- package/src/lib/common/fieldNormalizer/richtext.ts +0 -15
- package/src/lib/common/fieldNormalizer/string.ts +0 -23
- package/src/lib/common/fieldNormalizer/text.ts +0 -17
- package/src/lib/common/fieldNormalizer/uniqueNameFilter.ts +0 -21
- package/src/lib/common/metaAutofocus.directive.ts +0 -31
- package/src/lib/common/metaContext.resolver.ts +0 -25
- package/src/lib/common/metaIcons.pipe.spec.ts +0 -15
- package/src/lib/common/metaIcons.pipe.ts +0 -29
- package/src/lib/common/metaModel.pipe.ts +0 -19
- package/src/lib/common/metaNormalizer.ts +0 -366
- package/src/lib/common/metaStripHtml.pipe.ts +0 -18
- package/src/lib/common/utils/colorThemes.ts +0 -86
- package/src/lib/common/utils/indexedDbStore/index.ts +0 -244
- package/src/lib/common/utils/indexedDbStore/indexedDbStore.spec.ts +0 -149
- package/src/lib/common/utils/relativeTimeBuilder.ts +0 -49
- package/src/lib/common/utils/resourceCardLabel.ts +0 -25
- package/src/lib/common/utils/smartProp.spec.ts +0 -24
- package/src/lib/common/utils/smartProp.ts +0 -28
- package/src/lib/common/utils/templateBuilder.ts +0 -99
- package/src/lib/field.scss +0 -207
- package/src/lib/fieldAbstract.ts +0 -327
- package/src/lib/fieldBoolean/index.ts +0 -55
- package/src/lib/fieldBoolean/style.scss +0 -22
- package/src/lib/fieldBoolean/test.spec.ts +0 -43
- package/src/lib/fieldBoolean/view.html +0 -30
- package/src/lib/fieldComposite/index.ts +0 -86
- package/src/lib/fieldComposite/style.scss +0 -6
- package/src/lib/fieldComposite/test.spec.ts +0 -43
- package/src/lib/fieldComposite/view.html +0 -9
- package/src/lib/fieldDatetime/index.ts +0 -359
- package/src/lib/fieldDatetime/style.scss +0 -81
- package/src/lib/fieldDatetime/test.spec.ts +0 -43
- package/src/lib/fieldDatetime/view.html +0 -26
- package/src/lib/fieldHidden/index.ts +0 -15
- package/src/lib/fieldHidden/view.html +0 -0
- package/src/lib/fieldInput/index.ts +0 -477
- package/src/lib/fieldInput/style.scss +0 -128
- package/src/lib/fieldInput/test.spec.ts +0 -43
- package/src/lib/fieldInput/view.html +0 -81
- package/src/lib/fieldList/index.ts +0 -73
- package/src/lib/fieldList/style.scss +0 -26
- package/src/lib/fieldList/test.spec.ts +0 -43
- package/src/lib/fieldList/view.html +0 -25
- package/src/lib/fieldRadio/index.ts +0 -93
- package/src/lib/fieldRadio/style.scss +0 -32
- package/src/lib/fieldRadio/test.spec.ts +0 -43
- package/src/lib/fieldRadio/view.html +0 -24
- package/src/lib/fieldReference/index.ts +0 -871
- package/src/lib/fieldReference/style.scss +0 -273
- package/src/lib/fieldReference/test.spec.ts +0 -44
- package/src/lib/fieldReference/view.html +0 -163
- package/src/lib/fieldRichtext/index.ts +0 -98
- package/src/lib/fieldRichtext/quill.scss +0 -6
- package/src/lib/fieldRichtext/style.scss +0 -87
- package/src/lib/fieldRichtext/test.spec.ts +0 -43
- package/src/lib/fieldRichtext/view.html +0 -17
- package/src/lib/fieldSelect/index.ts +0 -597
- package/src/lib/fieldSelect/style.scss +0 -165
- package/src/lib/fieldSelect/test.spec.ts +0 -44
- package/src/lib/fieldSelect/view.html +0 -128
- package/src/lib/fieldText/index.ts +0 -86
- package/src/lib/fieldText/style.scss +0 -24
- package/src/lib/fieldText/test.spec.ts +0 -43
- package/src/lib/fieldText/view.html +0 -23
- package/src/lib/fieldUnknown/index.ts +0 -15
- package/src/lib/fieldUnknown/test.spec.ts +0 -34
- package/src/lib/fieldUnknown/view.html +0 -9
- package/src/lib/index.ts +0 -127
- package/src/lib/layout/index.ts +0 -255
- package/src/lib/layout/style.scss +0 -67
- package/src/lib/layout/view.html +0 -45
- package/src/lib/metaField/index.ts +0 -133
- package/src/lib/metaField/test.spec.ts +0 -32
- package/src/lib/refDialog/index.ts +0 -157
- package/src/lib/refDialog/style.scss +0 -154
- package/src/lib/refDialog/view.html +0 -24
- package/src/lib/resource/index.ts +0 -559
- package/src/lib/resource/style.scss +0 -132
- package/src/lib/resource/view.html +0 -70
- package/src/lib/resourceCard/index.ts +0 -44
- package/src/lib/resourceCard/style.scss +0 -7
- package/src/lib/resourceCard/view.html +0 -14
- package/src/lib/services/metaContext/index.ts +0 -61
- package/src/lib/services/metaMsg/index.ts +0 -84
- package/src/lib/services/metaReference/index.ts +0 -98
- package/src/lib/services/metaResource/index.ts +0 -163
- package/src/lib/services/metaResource/metaHttpClient.ts +0 -76
- package/src/lib/services/metaResource/metaResource.spec.ts +0 -24
- package/src/lib/services/metaTracker/index.ts +0 -38
- package/src/lib/services/resourceDrafts/index.ts +0 -81
- package/src/lib/services/resourceDrafts/resourceDrafts.spec.ts +0 -24
- package/src/lib/styles.scss +0 -13
- package/src/public-api.ts +0 -5
- package/src/test.ts +0 -17
- package/tsconfig.lib.json +0 -25
- package/tsconfig.lib.prod.json +0 -9
- package/tsconfig.spec.json +0 -17
|
@@ -1,81 +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'>
|
|
4
|
-
<a *ngIf="isPhoneNumber; else elseBlock" href='#' (click)="click2dial($event)" class="Vlt-text-link" aria-label='Dial'>
|
|
5
|
-
<svg class="Vlt-icon Vlt-icon--smaller" style="margin-top: -3px;">
|
|
6
|
-
<use xlink:href="volta/volta-icons.svg#Vlt-icon-phone-full" />
|
|
7
|
-
</svg>
|
|
8
|
-
{{model}}
|
|
9
|
-
</a>
|
|
10
|
-
<ng-template #elseBlock>{{model}}</ng-template>
|
|
11
|
-
</div>
|
|
12
|
-
</div>
|
|
13
|
-
<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), 'multiple': multiple, 'has-value': f.value, active: keyListenerActive }">
|
|
14
|
-
<div *ngIf='multiple' class='items-container'>
|
|
15
|
-
<div *ngIf='model' class='badges-container keep-focus' (click)='focus()'> <!-- eslint-disable-line -->
|
|
16
|
-
<div *ngFor='let item of model' class="Vlt-badge Vlt-badge--transparent Vlt-badge--app Vlt-badge--large keep-focus">
|
|
17
|
-
{{item}}
|
|
18
|
-
<button class="Vlt-badge__dismiss keep-focus" (click)='remove($event, item)'></button> <!-- eslint-disable-line @angular-eslint/template/elements-content -->
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
22
|
-
<div class="Vlt-input Vlt-dropdown" style='display: block;' [ngClass]="{'vgip-disable': disabled}">
|
|
23
|
-
<label class='wrapper'>
|
|
24
|
-
<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]="multiple ? 'hidden' : (logicalSubtype || meta.subtype || 'text')" placeholder=" " (click)='onActivated($event)' (focus)='onActivated($event)' (blur)='onBlur($event)'/>
|
|
25
|
-
<input *ngIf='multiple' class='main' [pattern]="validations.pattern ? validations.pattern.value || validations.pattern : null" [minlength]='validations.minlength' [maxlength]='validations.maxlength' [min]='validations.min' [max]='validations.max' [(ngModel)]='addText' [ngModelOptions]="{ standalone: true }" [type]="logicalSubtype || meta.subtype || 'text'" [disabled]='disabled' [readonly]='readonly' placeholder="+Add" (keydown.enter)='onAdd($event)' (click)='onActivated($event)' (focus)='onActivated($event)' (blur)='onBlur($event)'/>
|
|
26
|
-
<label class='Vlt-truncate'>{{meta.label || meta.name}}<span *ngIf='validations.required' class='Vlt-red'>*</span> <span class='Vlt-black' *ngIf='model && multiple'>({{model.length}})</span></label> <!-- eslint-disable-line @angular-eslint/template/label-has-associated-control -->
|
|
27
|
-
</label>
|
|
28
|
-
<div class='Vlt-composite__append right-actions'>
|
|
29
|
-
<a href='#' *ngIf='model && showClear' class="Vlt-composite__append--icon" (click)='clear($event)'>
|
|
30
|
-
<div class="Vlt-composite__icon">
|
|
31
|
-
<svg><use xlink:href="volta/volta-icons.svg#Vlt-icon-cross"/></svg>
|
|
32
|
-
</div>
|
|
33
|
-
</a>
|
|
34
|
-
</div>
|
|
35
|
-
<!-- <div *ngIf="!meta.subtype || meta.subtype == 'text'" class="Vlt-composite__append Vlt-composite__append--icon" style='bottom: 7px; right: 10px; padding: 3px; width: initial; height: initial; cursor: pointer;'>
|
|
36
|
-
<div *ngIf="!meta.type || meta.type === 'string'" class="Vlt-composite__icon" (click)='textToSpeech()'>
|
|
37
|
-
<svg><use xlink:href="volta/volta-icons.svg#Vlt-icon-microphone"/></svg>
|
|
38
|
-
</div>
|
|
39
|
-
</div> -->
|
|
40
|
-
<div *ngIf="suggestions.length" class="Vlt-dropdown__panel">
|
|
41
|
-
<div class="Vlt-dropdown__panel__content Vlt-dropdown__panel__content--scroll-area suggestions">
|
|
42
|
-
<!-- <div class="Vlt-dropdown__title" style='padding-left: 13px;'>
|
|
43
|
-
Suggestions
|
|
44
|
-
<div class="Vlt-dropdown__close Vlt-white" (click)='dismissDropdown($event)'>
|
|
45
|
-
<svg class='Vlt-icon Vlt-icon--small'><use xlink:href="volta/volta-icons.svg#Vlt-icon-cross"/></svg>
|
|
46
|
-
</div>
|
|
47
|
-
</div> -->
|
|
48
|
-
<div class="Vlt-dropdown__block"></div>
|
|
49
|
-
<div *ngIf='dropdown' class="Vlt-dropdown__scroll">
|
|
50
|
-
<a href='#' [ngClass]="{ 'Vlt-dropdown__link--selected': (activeSuggestionIndex === i) }" (click)='onSuggestionSelect($event, suggestion)' *ngFor='let suggestion of suggestions; let i = index' class="Vlt-dropdown__link" style='padding: 0;'>
|
|
51
|
-
<div *ngIf='multiple' class="Vlt-checkbox" style='width: 100%;'>
|
|
52
|
-
<label [title]='suggestion.label || suggestion'>
|
|
53
|
-
<span class="Vlt-checkbox__button">
|
|
54
|
-
<input type="checkbox" [checked]='model && model.indexOf(suggestion) !== -1'/>
|
|
55
|
-
<span class="Vlt-checkbox__icon"></span>
|
|
56
|
-
</span>
|
|
57
|
-
{{suggestion.label || suggestion}}
|
|
58
|
-
</label>
|
|
59
|
-
</div>
|
|
60
|
-
<div *ngIf='!multiple' style='padding: 12px 20px;'>
|
|
61
|
-
{{suggestion.label || suggestion}}
|
|
62
|
-
</div>
|
|
63
|
-
</a>
|
|
64
|
-
</div>
|
|
65
|
-
<div *ngIf='!multiple' class="Vlt-dropdown__block"></div>
|
|
66
|
-
<div *ngIf='multiple' class="Vlt-dropdown__block Vlt-dropdown__block--nowrap" style='padding: 8px 16px 16px;'>
|
|
67
|
-
<button (click)='clear($event)' type='button' class="Vlt-btn Vlt-btn--secondary Vlt-btn--app Vlt-btn--small Vlt-btn--outline">Clear all</button>
|
|
68
|
-
<button (click)='dismissDropdown($event)' type='button' class="Vlt-btn Vlt-btn--secondary Vlt-btn--app Vlt-btn--small">Done</button>
|
|
69
|
-
</div>
|
|
70
|
-
</div>
|
|
71
|
-
</div>
|
|
72
|
-
</div>
|
|
73
|
-
<small *ngIf='f.invalid && ((f | metaModel)._parent.submitted || ((f | metaModel ).touched && keyListenerActive))' class="Vlt-form__element__error">
|
|
74
|
-
<span *ngIf="f.errors.required">Required. </span>
|
|
75
|
-
<span *ngIf="f.errors.minlength">Must be longer than {{validations.minlength}} characters. </span>
|
|
76
|
-
<span *ngIf="f.errors.maxlength">Must be lest than {{validations.maxlength}} characters. </span>
|
|
77
|
-
<span *ngIf="f.errors.pattern">{{ validations.pattern.text || "Should match '"+validations.pattern+"' pattern." }}. </span>
|
|
78
|
-
<span *ngIf="f.errors.custom">{{f.errors.custom}} </span>
|
|
79
|
-
</small>
|
|
80
|
-
<small *ngIf='meta.hint' class="Vlt-form__element__hint">{{meta.hint}}</small>
|
|
81
|
-
</div>
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { Component, OnInit } from '@angular/core';
|
|
2
|
-
import { FieldAbstract } from '../fieldAbstract';
|
|
3
|
-
import { ControlContainer, NgForm } from '@angular/forms';
|
|
4
|
-
|
|
5
|
-
@Component({
|
|
6
|
-
templateUrl: './view.html',
|
|
7
|
-
styleUrls: ['./style.scss'],
|
|
8
|
-
viewProviders: [{ provide: ControlContainer, useExisting: NgForm }],
|
|
9
|
-
standalone: false
|
|
10
|
-
})
|
|
11
|
-
export class FieldList extends FieldAbstract implements OnInit {
|
|
12
|
-
items: Array<any> = [];
|
|
13
|
-
value: any;
|
|
14
|
-
|
|
15
|
-
get list() {
|
|
16
|
-
return this.meta.list || this.meta.reference;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
get cloneList() {
|
|
20
|
-
return JSON.parse(JSON.stringify(this.list));
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
ngOnInit() {
|
|
24
|
-
this.scope += (typeof(this.index) === 'undefined') ? `${this.meta.name}_` : `${this.meta.name}[${this.index}]_`;
|
|
25
|
-
const origValue = this.parent[this.meta.name];
|
|
26
|
-
Object.defineProperty(this.parent, this.meta.name, {
|
|
27
|
-
set: (value) => {
|
|
28
|
-
this.model = [];
|
|
29
|
-
if (value && value.length) {
|
|
30
|
-
for (const i of value) {
|
|
31
|
-
if (this.model.indexOf(i) === -1) {
|
|
32
|
-
this.model.push(i);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
this.value = this.model;
|
|
37
|
-
this.meta.$optional = this.isOptional;
|
|
38
|
-
},
|
|
39
|
-
get: () => this.value,
|
|
40
|
-
enumerable: true,
|
|
41
|
-
configurable: true
|
|
42
|
-
});
|
|
43
|
-
if (origValue) {
|
|
44
|
-
this.parent[this.meta.name] = origValue;
|
|
45
|
-
}
|
|
46
|
-
if (!this.model && this.validations.min) {
|
|
47
|
-
for (let i = 0; i < this.validations.min; i++) {
|
|
48
|
-
this.add();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
add() {
|
|
54
|
-
if (!this.model) {
|
|
55
|
-
this.model = [];
|
|
56
|
-
}
|
|
57
|
-
if (!this.validations.max || (this.validations.max > this.model.length)) {
|
|
58
|
-
this.model.push({});
|
|
59
|
-
this.value = this.model;
|
|
60
|
-
}
|
|
61
|
-
this.onChange.emit(this.model);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
remove(itemIndex) {
|
|
65
|
-
this.model.splice(itemIndex, 1);
|
|
66
|
-
this.value = this.model;
|
|
67
|
-
this.onChange.emit(this.model);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
onChildChange() {
|
|
71
|
-
this.onChange.emit(this.model);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
.Vlt-btn--link:not([disabled]) {
|
|
2
|
-
svg {
|
|
3
|
-
fill: #e84545;
|
|
4
|
-
}
|
|
5
|
-
&:hover svg {
|
|
6
|
-
fill: #de1c1c;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
.item-add-button {
|
|
10
|
-
background-color: var(--vgip-meta-input-action-hover-bg-color);
|
|
11
|
-
color: var(--vgip-meta-input-color);
|
|
12
|
-
svg {
|
|
13
|
-
fill: var(--vgip-meta-input-color);
|
|
14
|
-
}
|
|
15
|
-
&:hover {
|
|
16
|
-
transform: scale(1.02);
|
|
17
|
-
box-shadow: inset 0 0 0 1px var(--vgip-meta-input-active-border-color);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.item-remove-button {
|
|
22
|
-
border: 0;
|
|
23
|
-
&:disabled {
|
|
24
|
-
cursor: not-allowed;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -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:54: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 { FieldList } from '../fieldList';
|
|
14
|
-
|
|
15
|
-
describe('FieldList', () => {
|
|
16
|
-
let component: FieldList;
|
|
17
|
-
let fixture: ComponentFixture<FieldList>;
|
|
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(FieldList);
|
|
34
|
-
component = fixture.componentInstance;
|
|
35
|
-
component.parent = {};
|
|
36
|
-
component.meta = { name: 'f1', list: [ { name: 'f2' }] };
|
|
37
|
-
fixture.detectChanges();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('should create', () => {
|
|
41
|
-
expect(component).toBeTruthy();
|
|
42
|
-
});
|
|
43
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
<div *ngIf='true' class="Vlt-form__element" [ngClass]="{ 'Vlt-form__element--error': (f | metaModel)._parent.submitted && f.invalid }">
|
|
2
|
-
<label class="Vlt-label">{{meta.label || meta.name}} ({{(model || []).length}})<span *ngIf='validations.required' class='Vlt-red'>*</span></label> <!-- eslint-disable-line @angular-eslint/template/label-has-associated-control -->
|
|
3
|
-
<small style='margin-bottom: 4px;' *ngIf='meta.hint' class="Vlt-form__element__hint">{{meta.hint}}</small>
|
|
4
|
-
<input class='model' type='hidden' [required]='validations.required' [(ngModel)]='model' #f='ngModel' [name]='name' />
|
|
5
|
-
<ng-container *ngIf='model'>
|
|
6
|
-
<div *ngFor='let item of model; let i = index;' style='display: flex; border-bottom: 1px solid var(--vgip-meta-separator-color);'>
|
|
7
|
-
<vgip-meta-field style='flex: 1;' [index]='i' [scope]='scope' [meta]='cloneList' [parent]='item' [integrationCode]='integrationCode' [resourceType]='meta.resourceType || resourceType' theme='inherit' [preview]='preview' (onChange)='onChildChange()'></vgip-meta-field>
|
|
8
|
-
<vgip-meta-field *ngIf='meta.selectable' [meta]="{ name: meta.selectable.name, label: ' ', type: 'radio', options: [ { id: meta.selectable.value, label: meta.selectable.label } ] }" [parent]='item' [integrationCode]='integrationCode' theme='inherit' style='margin-left: 12px; margin-top: 12px; margin-right: -12px;' (onChange)='onChildChange()'></vgip-meta-field>
|
|
9
|
-
<div *ngIf='!preview' style='padding-left: 12px; margin-top: 3px;'>
|
|
10
|
-
<button type='button' (click)='remove(i)' class="Vlt-btn Vlt-btn--link item-remove-button" [disabled]='model.length === (validations.min || 0)' aria-label='Remove'>
|
|
11
|
-
<svg><use xlink:href="volta/volta-icons.svg#Vlt-icon-bin"/></svg>
|
|
12
|
-
</button>
|
|
13
|
-
</div>
|
|
14
|
-
</div>
|
|
15
|
-
</ng-container>
|
|
16
|
-
<button *ngIf='!preview && (!validations.max || !model || model.length < validations.max)' style='width: 100%;' type='button' (click)='add()' class="Vlt-btn Vlt-btn--small Vlt-btn--tertiary Vlt-btn--app Vlt-btn--no-focus item-add-button" [disabled]='validations.max && model && model.length === validations.max'>
|
|
17
|
-
<svg><use xlink:href="volta/volta-icons.svg#Vlt-icon-plus"/></svg>{{list.label}}
|
|
18
|
-
</button>
|
|
19
|
-
<small *ngIf='(f | metaModel)._parent.submitted && f.invalid' class="Vlt-form__element__error">
|
|
20
|
-
<span *ngIf="f.errors.required">Required</span>
|
|
21
|
-
<span *ngIf="f.errors.maxlength">Length can not exceed {{validations.maxlength}} characters</span>
|
|
22
|
-
<span *ngIf="f.errors.custom">{{f.errors.custom}} </span>
|
|
23
|
-
</small>
|
|
24
|
-
<small *ngIf='meta.helpText' class="Vlt-form__element__hint">{{meta.helpText}}</small>
|
|
25
|
-
</div>
|
|
@@ -1,93 +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: 2020-03-26 12:56:38
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { Component, OnInit } from '@angular/core';
|
|
9
|
-
import { ControlContainer, NgForm } from '@angular/forms';
|
|
10
|
-
|
|
11
|
-
import { FieldAbstract } from '../fieldAbstract';
|
|
12
|
-
|
|
13
|
-
@Component({
|
|
14
|
-
templateUrl: './view.html',
|
|
15
|
-
styleUrls: ['./style.scss'],
|
|
16
|
-
viewProviders: [{ provide: ControlContainer, useExisting: NgForm }],
|
|
17
|
-
standalone: false
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
export class FieldRadio extends FieldAbstract implements OnInit {
|
|
21
|
-
// @Input() meta: any;
|
|
22
|
-
value: any;
|
|
23
|
-
|
|
24
|
-
get options() {
|
|
25
|
-
return this.meta.options || this.meta.picklist;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
ngOnInit() {
|
|
29
|
-
this.validationAttributes = ['required'];
|
|
30
|
-
const origValue = this.parent[this.meta.name];
|
|
31
|
-
Object.defineProperty(this.parent, this.meta.name, {
|
|
32
|
-
set: (value) => {
|
|
33
|
-
if (value) {
|
|
34
|
-
for (const o of this.options) {
|
|
35
|
-
if ((value.id || value) === (o.id || o.value || o.name || o)) {
|
|
36
|
-
this.model = o;
|
|
37
|
-
this.value = this.modelToValue(o, this.meta.valueType);
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
42
|
-
delete this.model;
|
|
43
|
-
delete this.value;
|
|
44
|
-
}
|
|
45
|
-
this.meta.$optional = this.isOptional;
|
|
46
|
-
},
|
|
47
|
-
get: () => this.value,
|
|
48
|
-
enumerable: this.sendToServer,
|
|
49
|
-
configurable: true
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
if (origValue) {
|
|
53
|
-
this.parent[this.meta.name] = origValue;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (this.default && !this.model) {
|
|
57
|
-
setTimeout(() => {
|
|
58
|
-
this.parent[this.meta.name] = this.meta.valueType === 'object' ? this.default : (this.default.id || this.default);
|
|
59
|
-
setTimeout(() => {
|
|
60
|
-
this.onModelChange(this.model);
|
|
61
|
-
}, 0);
|
|
62
|
-
}, 0);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
onOptionChange(model) {
|
|
67
|
-
this.model = model;
|
|
68
|
-
this.onModelChange(this.model);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
onActivated(ev) {
|
|
72
|
-
if (!this.keyListenerActive) {
|
|
73
|
-
ev.srcElement.addEventListener('keydown', this.keydown);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
onBlur(ev) {
|
|
78
|
-
if (this.keyListenerActive) {
|
|
79
|
-
ev.srcElement.removeEventListener('keydown', this.keydown);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
private keydown = (event) => {
|
|
84
|
-
switch (event.key) {
|
|
85
|
-
case 'Backspace': {
|
|
86
|
-
event.preventDefault();
|
|
87
|
-
event.stopPropagation();
|
|
88
|
-
this.clear();
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
.Vlt-form__element {
|
|
2
|
-
padding-bottom: 4px;
|
|
3
|
-
}
|
|
4
|
-
.Vlt-form__element__hint {
|
|
5
|
-
margin-top: 4px;
|
|
6
|
-
}
|
|
7
|
-
.Vlt-form__element__error {
|
|
8
|
-
margin-top: 4px;
|
|
9
|
-
}
|
|
10
|
-
.Vlt-radio--inline {
|
|
11
|
-
margin-bottom: 4px;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.Vlt-radio {
|
|
15
|
-
.Vlt-radio__icon {
|
|
16
|
-
border-color: var(--vgip-meta-input-border-color);
|
|
17
|
-
}
|
|
18
|
-
&:hover {
|
|
19
|
-
.Vlt-radio__icon {
|
|
20
|
-
border-color: var(--vgip-meta-input-active-border-color);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
input:checked ~ .Vlt-radio__icon {
|
|
24
|
-
border-color: var(--vgip-meta-input-active-border-color);
|
|
25
|
-
&:after {
|
|
26
|
-
background: var(--vgip-meta-input-active-border-color);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
input:focus + .Vlt-radio__icon, input:active + .Vlt-radio__icon {
|
|
30
|
-
background: var(--vgip-meta-input-bg-color)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -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: 2019-11-13 14:58:27
|
|
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 { FieldRadio } from '.';
|
|
14
|
-
|
|
15
|
-
describe('FieldInput', () => {
|
|
16
|
-
let component: FieldRadio;
|
|
17
|
-
let fixture: ComponentFixture<FieldRadio>;
|
|
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(FieldRadio);
|
|
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,24 +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'>
|
|
4
|
-
{{ model.label || model }}
|
|
5
|
-
</div>
|
|
6
|
-
</div>
|
|
7
|
-
<div *ngIf='!preview' class="Vlt-form__element" [ngClass]="{ 'Vlt-form__element--error': f && f.invalid && ((f | metaModel)._parent.submitted || (f | metaModel ).touched) }">
|
|
8
|
-
<label class="Vlt-label">{{meta.label || meta.name}}<span *ngIf='validations.required' class='Vlt-red'>*</span></label> <!-- eslint-disable-line @angular-eslint/template/label-has-associated-control -->
|
|
9
|
-
<input class='model' type='hidden' [required]='validations.required' [(ngModel)]='model' #f='ngModel' [name]='name' />
|
|
10
|
-
<fieldset *ngFor='let option of options' class="Vlt-radio Vlt-radio--inline">
|
|
11
|
-
<label style='cursor: pointer;'>
|
|
12
|
-
<span class="Vlt-radio__button">
|
|
13
|
-
<input class='main' (change)='onOptionChange(option)' type="radio" [checked]='option === model' [value]='option' [name]='name' (focus)='onActivated($event)' (blur)='onBlur($event)'/>
|
|
14
|
-
<span class="Vlt-radio__icon"></span>
|
|
15
|
-
</span>
|
|
16
|
-
<span style='white-space: nowrap;'>{{option.label || option}}</span>
|
|
17
|
-
</label>
|
|
18
|
-
</fieldset>
|
|
19
|
-
<small *ngIf='f && f.invalid && ((f | metaModel)._parent.submitted || (f | metaModel ).touched)' class="Vlt-form__element__error">
|
|
20
|
-
<span *ngIf="f.errors.required">Required. </span>
|
|
21
|
-
<span *ngIf="f.errors.custom">{{f.errors.custom}} </span>
|
|
22
|
-
</small>
|
|
23
|
-
<small *ngIf='meta.hint' class="Vlt-form__element__hint">{{meta.hint}}</small>
|
|
24
|
-
</div>
|