/
switch-properties.component.ts
45 lines (32 loc) · 1.36 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
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';
@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';
textArea = false;
constants = Constants;
constructor() { }
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;
if(this.property.guiElement === Constants.SalsahGui + Constants.HashDelimiter + 'Textarea') {
this.textArea = true;
}
}
saveNewValue() {
const createVal = this.createValueComponent.getNewValue();
}
}