aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/param-row/param-row.component.ts
blob: 53dcffddd3c62ee3cef09b96c35168b84f0b0e91 (plain)
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} from '@angular/core';
import {PROPERTY_DATA} from "app/utils";
import {DataTypeService} from "app/ng2/services/data-type.service";
import {OperationParameter} from 'app/models';
import {DropdownValue} from "app/ng2/components/ui/form-components/dropdown/ui-element-dropdown.component";

@Component({
    selector: 'param-row',
    templateUrl: './param-row.component.html',
    styleUrls: ['./param-row.component.less']
})

export class ParamRowComponent {
    @Input() param: OperationParameter;
    @Input() inputProps: Array<DropdownValue>;
    @Input() propTypes: { [key: string]: string };
    @Input() onRemoveParam: Function;
    @Input() isAssociateWorkflow: boolean;
    @Input() readonly: boolean;

    propTypeEnum: Array<String> = [];
    filteredInputProps: Array<DropdownValue> = [];

    constructor(private dataTypeService:DataTypeService) {}

    ngOnInit() {
        const types = PROPERTY_DATA.TYPES.concat(
            _.filter(
                Object.keys(this.dataTypeService.getAllDataTypes()),
                type => PROPERTY_DATA.TYPES.indexOf(type) === -1
            )
        );
        this.propTypeEnum = _.filter(
            types,
            type => _.toArray(this.propTypes).indexOf(type) > -1
        );
        this.onChangeType();
    }

    onChangeType() {
        this.filteredInputProps = _.filter(this.inputProps, prop => {
            return this.propTypes[prop.value] === this.param.type;
        });
    }
}