aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/components/inputs-table/inputs-table.component.ts
blob: f2cac21237514b2710aa7415810e961df14c2f8a (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
/**
 * Created by rc2122 on 5/4/2017.
 */
import {Component, Input, Output, EventEmitter, ViewChild} from "@angular/core";
import {InputFEModel} from "app/models";
import {ConfirmationDeleteInputComponent} from "./confirmation-delete-input/confirmation-delete-input.component";

@Component({
    selector: 'inputs-table',
    templateUrl: './inputs-table.component.html',
    styleUrls: ['../inputs-table/inputs-table.component.less']
})
export class InputsTableComponent {

    @Input() inputs: Array<InputFEModel>;
    @Input() instanceNamesMap: Map<string, string>;
    @Input() readonly:boolean;
    @Input() isLoading:boolean;
    @Output() inputValueChanged: EventEmitter<any> = new EventEmitter<any>();
    @Output() deleteInput: EventEmitter<any> = new EventEmitter<any>();
    @ViewChild ('deleteInputConfirmation') deleteInputConfirmation:ConfirmationDeleteInputComponent;

    selectedInputToDelete:InputFEModel;

    constructor (){
    }

    onInputValueChanged = (input) => {
        this.inputValueChanged.emit(input);
    };

    onDeleteInput = () => {
        this.deleteInput.emit(this.selectedInputToDelete);
    };

    openDeleteModal = (input:InputFEModel) => {
        this.selectedInputToDelete = input;
        this.deleteInputConfirmation.openModal();
    }
}