diff options
author | 2022-01-23 12:40:06 +0000 | |
---|---|---|
committer | 2022-03-02 11:44:48 +0000 | |
commit | c4a8271d664deb39e69fbba329b11ff57b9b276b (patch) | |
tree | 3f070217dd738d0d0ab4231ff1bd06b903e7cb19 /catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts | |
parent | 7f07f514eacacfb54d851201c49b24acd9b5e343 (diff) |
Support for multiple directives
Issue-ID: SDC-3861
Signed-off-by: KrupaNagabhushan <krupa.nagabhushan@est.tech>
Change-Id: Ie63c4879c28567b2d87e5fb08975b46014cf3660
Diffstat (limited to 'catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts')
-rw-r--r-- | catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts b/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts index 35e80dc70a..8500269420 100644 --- a/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts +++ b/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts @@ -13,7 +13,7 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import { Component, ComponentRef, EventEmitter, Input, Output } from '@angular/core'; +import {Component, ComponentRef, EventEmitter, Input, Output} from '@angular/core'; import { ButtonModel, ComponentInstance, @@ -141,7 +141,7 @@ export class ServiceDependenciesComponent { capabilities: string = ToscaFilterConstraintType.CAPABILITIES; properties: string = ToscaFilterConstraintType.PROPERTIES; private componentInstancesConstraints: ConstraintObject[] = []; - directiveOptions: string[]; + isEditable: boolean; @Input() readonly: boolean; @Input() compositeService: ComponentMetadata; @@ -161,7 +161,6 @@ export class ServiceDependenciesComponent { } ngOnInit() { - this.loadDirectives(); this.isLoading = false; this.operatorTypes = [ {label: '>', value: OPERATOR_TYPES.GREATER_THAN}, @@ -179,12 +178,6 @@ export class ServiceDependenciesComponent { }); } - loadDirectives() { - this.topologyTemplateService.getDirectiveList().subscribe((data: string[]) => { - this.directiveOptions = data; - }) - } - ngOnChanges(changes) { if (changes.currentServiceInstance) { this.currentServiceInstance = changes.currentServiceInstance.currentValue; @@ -196,9 +189,10 @@ export class ServiceDependenciesComponent { } } - private getActualDirectiveValue = (): string => { - return this.currentServiceInstance.directives.length > 0 ? this.currentServiceInstance.directives[0] : ""; + private getActualDirectiveValue = (): string[] => { + return this.currentServiceInstance.directives.length > 0 ? this.currentServiceInstance.directives : []; } + public openRemoveDependencyModal = (): ComponentRef<ModalComponent> => { const actionButton: ButtonModel = new ButtonModel(I18nTexts.modalApprove, 'blue', this.onUncheckDependency); const cancelButton: ButtonModel = new ButtonModel(I18nTexts.modalCancel, 'grey', this.onCloseRemoveDependencyModal); @@ -242,15 +236,13 @@ export class ServiceDependenciesComponent { this.modalServiceNg2.closeCurrentModal(); } - onOptionsSelected(event: any) { - const newDirectiveValue = event.target.value; - if (newDirectiveValue.toLowerCase() !== this.getActualDirectiveValue()) { - const rulesListOrig = this.componentInstancesConstraints; - this.setDirectiveValue(newDirectiveValue); - this.constraintProperties = []; - this.constraintCapabilities = []; - this.updateComponentInstance(this.isDependent, rulesListOrig); - } + onAddDirectives(directives: string[]) { + this.isEditable = false; + this.setDirectiveValue(directives); + const rulesListOrig = this.componentInstancesConstraints; + this.constraintProperties = []; + this.constraintCapabilities = []; + this.updateComponentInstance(this.isDependent, rulesListOrig); } private onRemoveDirective() { @@ -259,11 +251,12 @@ export class ServiceDependenciesComponent { this.constraintCapabilities = []; } - private setDirectiveValue(newDirectiveValue: string) { - if (this.isDependent) { - this.openUpdateDependencyModal().instance.open(); - } - this.currentServiceInstance.setDirectiveValue(newDirectiveValue); + private onEditDirectives() { + this.isEditable = true; + } + + private setDirectiveValue(newDirectiveValues: string[]) { + this.currentServiceInstance.setDirectiveValue(newDirectiveValues); } updateComponentInstance(isDependentOrigVal: boolean, rulesListOrig: ConstraintObject[]) { |