diff --git a/src/app/core/services/private-catalogs.service.ts b/src/app/core/services/private-catalogs.service.ts index c3077b800ba09ffc85e4c029f2ea5575c06dc34d..3c2d9c258d2ca65e585c710e55d5f6fb2d191368 100644 --- a/src/app/core/services/private-catalogs.service.ts +++ b/src/app/core/services/private-catalogs.service.ts @@ -701,7 +701,7 @@ export class PrivateCatalogsService { ); } - createTags(tag: Tag) { + createTags(tag: string) { const req = { request_body: { tag, diff --git a/src/app/shared/components/publish-to-marketplace-page/publish-to-marketplace-page.component.ts b/src/app/shared/components/publish-to-marketplace-page/publish-to-marketplace-page.component.ts index d01c6d33108ee0e759743fea8beeb45743fa691f..c4671ce626a887666fe0aa720f9e37070edc4afa 100644 --- a/src/app/shared/components/publish-to-marketplace-page/publish-to-marketplace-page.component.ts +++ b/src/app/shared/components/publish-to-marketplace-page/publish-to-marketplace-page.component.ts @@ -516,12 +516,6 @@ export class PublishToMarketplacePageComponent implements OnInit { .getSolutionDetails(this.solutionId, this.revisionId) .subscribe({ next: (res) => { - const alert: Alert = { - message: 'Tag deleted successfully', - type: AlertType.Success, - }; - this.alertService.notify(alert, 5000); - this.alertService.notify; const tagsList = res?.solutionTagList; this.tagsItems.update((tags: Tag[]) => [...tagsList]); this.publishToMarketPlaceForm.patchValue({ @@ -555,27 +549,45 @@ export class PublishToMarketplacePageComponent implements OnInit { } addTag(event: MatChipInputEvent): void { - const value = { tag: (event.value || '').trim() }; + if (!(this.allTags().indexOf(event.value) > -1)) { + this.privateCatalogsService.createTags(event.value).subscribe({ + next: (res) => { + const alert: Alert = { + message: 'Tag created successfully', + type: AlertType.Success, + }; + this.alertService.notify(alert, 5000); + this.alertService.notify; - if (value) { - this.privateCatalogsService - .addTag(event.value, this.solutionId) - .subscribe({ - next: (res) => { - const alert: Alert = { - message: 'Tag added successfully', - type: AlertType.Success, - }; - this.alertService.notify(alert, 5000); - this.alertService.notify; - this.updateTags(); - this.filteredTags.next( - this.updateAllTagsSignal(event.value, this.allTags()), - ); - }, - error: () => {}, - }); + this.privateCatalogsService.getAllTag().subscribe({ + next: (res) => { + this.allTags.update((tags: string[]) => [...res]); + this.filteredTags.next(this.allTags()); + }, + error: () => {}, + }); + }, + error: () => {}, + }); } + this.privateCatalogsService.addTag(event.value, this.solutionId).subscribe({ + next: (res) => { + if (this.allTags().indexOf(event.value) > -1) { + const alert: Alert = { + message: 'Tag added successfully', + type: AlertType.Success, + }; + this.alertService.notify(alert, 5000); + this.alertService.notify; + this.updateTags(); + this.filteredTags.next( + this.updateAllTagsSignal(event.value, this.allTags()), + ); + } + this.updateTags(); + }, + error: () => {}, + }); // Clear the input value event.chipInput!.clear();