Operation screen changes.
[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     @Input() isInputParam: boolean;
21
22     propTypeEnum: Array<String> = [];
23     filteredInputProps: Array<DropdownValue> = [];
24
25     constructor(private dataTypeService:DataTypeService) {}
26
27     ngOnInit() {
28         const types = PROPERTY_DATA.TYPES.concat(
29             _.filter(
30                 Object.keys(this.dataTypeService.getAllDataTypes()),
31                 type => PROPERTY_DATA.TYPES.indexOf(type) === -1
32             )
33         );
34         this.propTypeEnum = _.filter(
35             types,
36             type => _.toArray(this.propTypes).indexOf(type) > -1
37         );
38         this.onChangeType();
39     }
40
41     onChangeType() {
42         this.filteredInputProps = _.filter(this.inputProps, prop => {
43             return this.propTypes[prop.value] === this.param.type;
44         });
45     }
46 }