Catalog alignment
[sdc.git] / catalog-ui / src / app / ng2 / pages / composition / graph / connection-wizard / connection-wizard-header / connection-wizard-header.component.ts
1 /**
2  * Created by rc2122 on 9/27/2017.
3  */
4 import {Component, Inject, forwardRef} from "@angular/core";
5 import {ConnectionWizardService} from "../connection-wizard.service";
6 import {WizardHeaderBaseComponent} from "app/ng2/components/ui/multi-steps-wizard/multi-steps-wizard-header-base.component";
7
8 @Component({
9     selector: 'connection-wizard-header',
10     templateUrl: './connection-wizard-header.component.html',
11     styleUrls:['./connection-wizard-header.component.less']
12 })
13
14 export class ConnectionWizardHeaderComponent extends WizardHeaderBaseComponent{
15
16     constructor(@Inject(forwardRef(() => ConnectionWizardService)) public connectWizardService: ConnectionWizardService) {
17         super();
18     }
19
20     private _getReqOrCapName(isFromNode:boolean) {
21         const attributeReqOrCap:string = isFromNode ? 'requirement' : 'capability';
22         if (this.connectWizardService.selectedMatch[attributeReqOrCap]) {
23             return this.connectWizardService.selectedMatch[attributeReqOrCap].getTitle();
24         } else if (this.connectWizardService.selectedMatch.relationship) {
25             return this.connectWizardService.selectedMatch.relationship.relation[attributeReqOrCap];
26         }
27         return '';
28     }
29
30     private getSelectedReqOrCapName = (isFromNode:boolean):string => {
31         if(!this.connectWizardService.selectedMatch){
32             return '';
33         }
34         return this._getReqOrCapName(this.connectWizardService.selectedMatch.isFromTo ? isFromNode : !isFromNode);
35     }
36 }
37