Skip to content
Snippets Groups Projects
Commit 9b9831bd authored by Kawtar Laariche's avatar Kawtar Laariche
Browse files

#24: add create tag functionality

parent 27a6b5a6
No related branches found
No related tags found
No related merge requests found
...@@ -701,7 +701,7 @@ export class PrivateCatalogsService { ...@@ -701,7 +701,7 @@ export class PrivateCatalogsService {
); );
} }
createTags(tag: Tag) { createTags(tag: string) {
const req = { const req = {
request_body: { request_body: {
tag, tag,
......
...@@ -516,12 +516,6 @@ export class PublishToMarketplacePageComponent implements OnInit { ...@@ -516,12 +516,6 @@ export class PublishToMarketplacePageComponent implements OnInit {
.getSolutionDetails(this.solutionId, this.revisionId) .getSolutionDetails(this.solutionId, this.revisionId)
.subscribe({ .subscribe({
next: (res) => { next: (res) => {
const alert: Alert = {
message: 'Tag deleted successfully',
type: AlertType.Success,
};
this.alertService.notify(alert, 5000);
this.alertService.notify;
const tagsList = res?.solutionTagList; const tagsList = res?.solutionTagList;
this.tagsItems.update((tags: Tag[]) => [...tagsList]); this.tagsItems.update((tags: Tag[]) => [...tagsList]);
this.publishToMarketPlaceForm.patchValue({ this.publishToMarketPlaceForm.patchValue({
...@@ -555,27 +549,45 @@ export class PublishToMarketplacePageComponent implements OnInit { ...@@ -555,27 +549,45 @@ export class PublishToMarketplacePageComponent implements OnInit {
} }
addTag(event: MatChipInputEvent): void { 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.getAllTag().subscribe({
this.privateCatalogsService next: (res) => {
.addTag(event.value, this.solutionId) this.allTags.update((tags: string[]) => [...res]);
.subscribe({ this.filteredTags.next(this.allTags());
next: (res) => { },
const alert: Alert = { error: () => {},
message: 'Tag added successfully', });
type: AlertType.Success, },
}; error: () => {},
this.alertService.notify(alert, 5000); });
this.alertService.notify;
this.updateTags();
this.filteredTags.next(
this.updateAllTagsSignal(event.value, this.allTags()),
);
},
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 // Clear the input value
event.chipInput!.clear(); event.chipInput!.clear();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment