aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/pages/connection-wizard/connection-wizard-header/connection-wizard-header.component.ts
blob: f5bc3b7ca4ca642d2e3b892afbd771fab9af9bf5 (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
/**
 * Created by rc2122 on 9/27/2017.
 */
import {Component, Inject, forwardRef} from "@angular/core";
import {ConnectionWizardService} from "../connection-wizard.service";
import {WizardHeaderBaseComponent} from "app/ng2/components/ui/multi-steps-wizard/multi-steps-wizard-header-base.component";

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

export class ConnectionWizardHeaderComponent extends WizardHeaderBaseComponent{

    constructor(@Inject(forwardRef(() => ConnectionWizardService)) public connectWizardService: ConnectionWizardService) {
        super();
    }

    private _getReqOrCapName(isFromNode:boolean) {
        const attributeReqOrCap:string = isFromNode ? 'requirement' : 'capability';
        if (this.connectWizardService.selectedMatch[attributeReqOrCap]) {
            return this.connectWizardService.selectedMatch[attributeReqOrCap].getTitle();
        } else if (this.connectWizardService.selectedMatch.relationship) {
            return this.connectWizardService.selectedMatch.relationship.relation[attributeReqOrCap];
        }
        return '';
    }

    private getSelectedReqOrCapName = (isFromNode:boolean):string => {
        if(!this.connectWizardService.selectedMatch){
            return '';
        }
        return this._getReqOrCapName(this.connectWizardService.selectedMatch.isFromTo ? isFromNode : !isFromNode);
    }
}