1 import { Component, forwardRef, Inject, OnInit } from '@angular/core';
2 import { Match } from 'app/models';
3 import { Capability } from 'app/models/capability';
4 import { Requirement } from 'app/models/requirement';
5 import { IStepComponent } from 'app/models/wizard-step';
6 import { Dictionary } from 'lodash';
7 import { ConnectionWizardService } from '../connection-wizard.service';
10 selector: 'from-node-step',
11 templateUrl: './from-node-step.component.html'
14 export class FromNodeStepComponent implements IStepComponent, OnInit{
16 optionalRequirementsMap: Dictionary<Requirement[]>;
17 optionalCapabilitiesMap: Dictionary<Capability[]>;
19 constructor(@Inject(forwardRef(() => ConnectionWizardService)) public connectWizardService: ConnectionWizardService) {}
22 this.optionalRequirementsMap = this.connectWizardService.getOptionalRequirementsByInstanceUniqueId(true);
23 this.optionalCapabilitiesMap = this.connectWizardService.getOptionalCapabilitiesByInstanceUniqueId(false);
26 preventNext = (): boolean => {
27 return !this.connectWizardService.selectedMatch || (!this.connectWizardService.selectedMatch.capability && !this.connectWizardService.selectedMatch.requirement);
30 preventBack = (): boolean => {
34 private updateSelectedReqOrCap = (selected: Requirement|Capability): void => {
36 this.connectWizardService.selectedMatch = null;
37 } else if (selected instanceof Requirement) {
38 this.connectWizardService.selectedMatch = new Match(<Requirement>selected, null, true, this.connectWizardService.connectRelationModel.fromNode.componentInstance.uniqueId, null);
40 this.connectWizardService.selectedMatch = new Match(null, <Capability>selected , false, null, this.connectWizardService.connectRelationModel.fromNode.componentInstance.uniqueId);