1 import {Component, OnInit, Input, ViewChild} from '@angular/core';
2 import {IdlObject} from '@eg/core/idl.service';
3 import {PcrudService} from '@eg/core/pcrud.service';
4 import {ComboboxComponent, ComboboxEntry} from '@eg/share/combobox/combobox.component';
6 export class CompositeNewPointValues {
16 selector: 'eg-composite-new-point',
17 templateUrl: 'composite-new.component.html'
19 export class CompositeNewPointComponent implements OnInit {
21 public values: CompositeNewPointValues;
23 attrTypeDefs: IdlObject[];
24 attrValDefs: IdlObject[];
25 attrTypes: ComboboxEntry[];
26 attrVals: ComboboxEntry[];
28 @Input() set pointType(type_: string) {
29 this.values.pointType = type_;
30 this.values.boolOp = '';
31 this.values.valueLabel = '';
32 this.values.valueId = '';
33 this.values.typeId = '';
34 this.values.typeLabel = '';
37 @ViewChild('valComboBox', {static: false}) valComboBox: ComboboxComponent;
40 private pcrud: PcrudService
42 this.values = new CompositeNewPointValues();
43 this.attrTypeDefs = [];
48 this.pcrud.retrieveAll('crad', {order_by: {crad: 'label'}})
50 this.attrTypeDefs.push(attr);
51 this.attrTypes.push({id: attr.name(), label: attr.label()});
56 this.values.typeId = evt.id;
57 this.values.typeLabel = evt.label;
58 this.valComboBox.selected = null; // reset other combobox
59 this.values.valueId = ''; // don't allow save with old valueId or valueLabel
60 this.values.valueLabel = '';
62 this.attrValDefs = [];
63 this.pcrud.search('ccvm', {'ctype': evt.id},
64 {flesh: 1, flesh_fields: {ccvm: ['composite_def', 'ctype']} }).subscribe(
66 this.attrValDefs.push(data);
67 this.attrVals.push({id: data.code(), label: data.value()});
72 this.attrValDefs = [];
79 this.values.valueId = evt.id;
80 this.values.valueLabel = evt.label;