diff options
author | 2020-09-04 15:27:00 +0100 | |
---|---|---|
committer | 2020-09-07 13:28:22 +0000 | |
commit | 3e9a9769dd21f0b16b3f238e42349cba3b1a78de (patch) | |
tree | 1517e5266d5b9ae8e5c386d06937eb503d59d431 /catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs | |
parent | 84a51513bca9c41c8757db017eb45b2d801da195 (diff) |
Enable selection of requirements
Instead of all requirements of the component instances in a component being exposed outside the component, this change will enable the component designer to specifiy which should be exposed outside the component and which are to be internal to the component
Change-Id: Ib063f7b8b0aca94896e78a46f069725bae3d494d
Issue-ID: SDC-2771
Signed-off-by: MichaelMorris <michael.morris@est.tech>
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Diffstat (limited to 'catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs')
4 files changed, 37 insertions, 9 deletions
diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/req-capabilities-tab.component.html b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/req-capabilities-tab.component.html index 27e05ec1f0..c73f69734f 100644 --- a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/req-capabilities-tab.component.html +++ b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/req-capabilities-tab.component.html @@ -10,7 +10,7 @@ </div> <div class="w-sdc-designer-sidebar-section w-sdc-designer-sidebar-section-relations"> <sdc-accordion [title]="'Requirements'" [arrow-direction]="'right'" [testId]="'Requirements-accordion'"> - <requirement-list [component]='component' [requirements]="requirements" [isInstanceSelected]="isComponentInstanceSelected"></requirement-list> + <requirement-list [component]='component' [requirements]="requirements" [isInstanceSelected]="isComponentInstanceSelected" [isViewOnly]='isViewOnly'></requirement-list> </sdc-accordion> </div> @@ -28,7 +28,7 @@ <sdc-accordion *ngIf="requirementsInstancesMap" [title]="'Requirements'" [arrow-direction]="'right'" [testId]="'Requirements-accordion'"> <sdc-accordion *ngFor="let key of objectKeys(requirementsInstancesMap); let i = index" [title]="key"> - <requirement-list [component]='component' [requirements]="requirementsInstancesMap[key]" [isInstanceSelected]="isComponentInstanceSelected"></requirement-list> + <requirement-list [component]='component' [requirements]="requirementsInstancesMap[key]" [isInstanceSelected]="isComponentInstanceSelected" [isViewOnly]='isViewOnly'></requirement-list> </sdc-accordion> </sdc-accordion> diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/req-capabilities-tab.component.ts b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/req-capabilities-tab.component.ts index 03697b38f2..7c91cbc4b8 100644 --- a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/req-capabilities-tab.component.ts +++ b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/req-capabilities-tab.component.ts @@ -122,10 +122,12 @@ export class ReqAndCapabilitiesTabComponent implements OnInit, OnDestroy { this.requirementsInstancesMap = new InstanceRequirementsMap(); _.forEach(this.requirements, (requirement:Requirement) => { - if (this.requirementsInstancesMap[requirement.ownerName]) { - this.requirementsInstancesMap[requirement.ownerName] = this.requirementsInstancesMap[requirement.ownerName].concat(requirement); - } else { - this.requirementsInstancesMap[requirement.ownerName] = new Array<Requirement>(requirement); + if(this.isComponentInstanceSelected || requirement.external){ + if (this.requirementsInstancesMap[requirement.ownerName]) { + this.requirementsInstancesMap[requirement.ownerName] = this.requirementsInstancesMap[requirement.ownerName].concat(requirement); + } else { + this.requirementsInstancesMap[requirement.ownerName] = new Array<Requirement>(requirement); + } } }); } diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/requirement-list/requirement-list.component.html b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/requirement-list/requirement-list.component.html index 8292729cf8..291b103344 100644 --- a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/requirement-list/requirement-list.component.html +++ b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/requirement-list/requirement-list.component.html @@ -13,6 +13,17 @@ </div> </div> </div> + <div class="checkbox-label-mark-as-external" + *ngIf="isInstanceSelected"> + <checkbox + class="checkbox-label" + data-tests-id="checkbox-mark-as-external" + [label]="'External'" + (checkedChange)="onMarkAsExternal(requirement)" + [(checked)]="requirement.external" + [disabled]="isViewOnly"> + </checkbox> + </div> </div> </div> </div> diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/requirement-list/requirement-list.component.ts b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/requirement-list/requirement-list.component.ts index e167c47dcc..3716ef0af0 100644 --- a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/requirement-list/requirement-list.component.ts +++ b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/requirement-list/requirement-list.component.ts @@ -2,6 +2,8 @@ import { Component, Input } from '@angular/core'; import { Component as TopologyTemplate, RelationshipModel, Relationship, Requirement } from "app/models"; import { CompositionService } from "app/ng2/pages/composition/composition.service"; import { ResourceNamePipe } from "app/ng2/pipes/resource-name.pipe"; +import { ComponentInstanceServiceNg2 } from "app/ng2/services/component-instance-services/component-instance.service"; +import { WorkspaceService } from "app/ng2/pages/workspace/workspace.service"; @Component({ selector: 'requirement-list', @@ -11,10 +13,12 @@ export class RequirementListComponent { @Input() component: TopologyTemplate; @Input() requirements: Array<Requirement>; @Input() isInstanceSelected:boolean; + @Input() isViewOnly: boolean; + readonly:boolean; - - constructor(private compositionService: CompositionService) { } - + constructor(private compositionService: CompositionService, + private workspaceService: WorkspaceService, + private componentInstanceServiceNg2: ComponentInstanceServiceNg2) {} public getRelation = (requirement:any):any => { if (this.isInstanceSelected && this.component.componentInstancesRelations) { @@ -36,5 +40,16 @@ export class RequirementListComponent { return null; }; + onMarkAsExternal(requirement:Requirement) { + if (requirement.external){ + requirement.external = false; + } else { + requirement.external = true; + } + this.componentInstanceServiceNg2.updateInstanceRequirement(this.workspaceService.metadata.getTypeUrl(), this.workspaceService.metadata.uniqueId, this.component.uniqueId, requirement).subscribe((response:any) => { + }, (error) => { console.log("An error has occured setting external: ", error); });; + + } + }; |