/
switch-properties.component.ts
50 lines (34 loc) · 1.5 KB
/
switch-properties.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { Constants, ReadResource, ResourcePropertyDefinition } from '@dasch-swiss/dsp-js';
import { BaseValueDirective } from 'src/app/main/directive/base-value.directive';
import { ValueService } from '../../../services/value.service';
@Component({
selector: 'app-switch-properties',
templateUrl: './switch-properties.component.html',
styleUrls: ['./switch-properties.component.scss']
})
export class SwitchPropertiesComponent implements OnInit {
@ViewChild('createVal') createValueComponent: BaseValueDirective;
@Input() property: ResourcePropertyDefinition;
@Input() parentResource: ReadResource;
@Input() parentForm: FormGroup;
@Input() formName: string;
@Input() isRequiredProp: boolean;
mode = 'create';
// gui element in case of textValue
textValueGuiEle: 'simpleText' | 'textArea' | 'richText';
constants = Constants;
constructor(
private _valueService: ValueService
) { }
ngOnInit(): void {
// the input isRequiredProp provided by KeyValuePair is stored as a number
// a conversion from a number to a boolean is required by the input valueRequiredValidator
this.isRequiredProp = !!+this.isRequiredProp;
this.textValueGuiEle = this._valueService.getTextValueGuiEle(this.property.guiElement);
}
saveNewValue() {
const createVal = this.createValueComponent.getNewValue();
}
}