Service operation UI merge
[sdc.git] / catalog-ui / src / app / ng2 / pages / interface-operation / operation-creator / param-row / param-row.component.ts
1 import {Component, Input} from '@angular/core';
2 import {PROPERTY_DATA} from "app/utils";
3 import {DataTypeService} from "app/ng2/services/data-type.service";
4 import {OperationParameter} from 'app/models';
5 import {DropdownValue} from "app/ng2/components/ui/form-components/dropdown/ui-element-dropdown.component";
6
7 @Component({
8     selector: 'param-row',
9     templateUrl: './param-row.component.html',
10     styleUrls: ['./param-row.component.less']
11 })
12
13 export class ParamRowComponent {
14     @Input() param: OperationParameter;
15     @Input() inputProps: Array<DropdownValue>;
16     @Input() propTypes: { [key: string]: string };
17     @Input() onRemoveParam: Function;
18     @Input() isAssociateWorkflow: boolean;
19     @Input() readonly: boolean;
20
21     propTypeEnum: Array<String> = [];
22     filteredInputProps: Array<DropdownValue> = [];
23
24     constructor(private dataTypeService:DataTypeService) {}
25
26     ngOnInit() {
27         const types = PROPERTY_DATA.TYPES.concat(
28             _.filter(
29                 Object.keys(this.dataTypeService.getAllDataTypes()),
30                 type => PROPERTY_DATA.TYPES.indexOf(type) === -1
31             )
32         );
33         this.propTypeEnum = _.filter(
34             types,
35             type => _.toArray(this.propTypes).indexOf(type) > -1
36         );
37         this.onChangeType();
38     }
39
40     onChangeType() {
41         this.filteredInputProps = _.filter(this.inputProps, prop => {
42             return this.propTypes[prop.value] === this.param.type;
43         });
44     }
45 }