mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-06-30 18:15:11 +00:00
[ACS-4331] Add deleteTag method to tag service (#8126)
* ACS-4331 - added deleteTag method to tag service * ACS-4331 - docs + unit test * ACS-4331 - docs correction * ACS-4331 - docs alignment fix * ACS-4331 - applied small fixes * ACS-4331 - updated docs * [ACS-4331] removed extra spaces
This commit is contained in:
parent
2dccde9e6b
commit
25d85c7890
@ -31,6 +31,10 @@ Manages tags in Content Services.
|
||||
- _nodeId:_ `string` - ID of the target node
|
||||
- _tag:_ `string` - Name of the tag to remove
|
||||
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<any>` - Null object when the operation completes
|
||||
- **deleteTag**(tagId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<void>`<br/>
|
||||
Completely deletes a tag, this will cause the tag to be removed from all the nodes.
|
||||
- _tagId:_ `string` - ID of the tag to remove
|
||||
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<void>` - Null object when the operation completes
|
||||
- **createTags**(tags: `TagBody[]`): [`Observable`](http://reactivex.io/documentation/observable.html)`<TagEntry[]>`<br/>
|
||||
Creates tags.
|
||||
- _tags:_ `TagBody[]` - List of tags to create.
|
||||
|
@ -66,7 +66,7 @@ describe('TagService', () => {
|
||||
|
||||
describe('Content tests', () => {
|
||||
|
||||
it('getTagsByNodeId catch errors call', async () => {
|
||||
it('should catch errors on getTagsByNodeId call', async () => {
|
||||
spyOn(service, 'getTagsByNodeId').and.returnValue(throwError({error : 'error'}));
|
||||
await service.getTagsByNodeId('fake-node-id').subscribe(() => {
|
||||
throwError('This call should fail');
|
||||
@ -75,7 +75,7 @@ describe('TagService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('delete tag should trigger a refresh event', async () => {
|
||||
it('should trigger a refresh event on removeTag() call', async () => {
|
||||
await service.refresh.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
});
|
||||
@ -83,7 +83,7 @@ describe('TagService', () => {
|
||||
service.removeTag('fake-node-id', 'fake-tag');
|
||||
});
|
||||
|
||||
it('add tag should trigger a refresh event', async () => {
|
||||
it('should trigger a refresh event on addTag() call', async () => {
|
||||
await service.refresh.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
});
|
||||
@ -91,6 +91,14 @@ describe('TagService', () => {
|
||||
service.addTag('fake-node-id', 'fake-tag');
|
||||
});
|
||||
|
||||
it('should trigger a refresh event on deleteTag() call', async () => {
|
||||
await service.refresh.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
});
|
||||
|
||||
service.deleteTag('fake-tag-id');
|
||||
});
|
||||
|
||||
describe('createTags', () => {
|
||||
it('should call createTags on tagsApi', () => {
|
||||
spyOn(service.tagsApi, 'createTags').and.returnValue(Promise.resolve([]));
|
||||
|
@ -18,7 +18,7 @@
|
||||
import { AlfrescoApiService, LogService, UserPreferencesService } from '@alfresco/adf-core';
|
||||
import { EventEmitter, Injectable, Output } from '@angular/core';
|
||||
import { from, Observable, throwError } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
import { catchError, map, tap } from 'rxjs/operators';
|
||||
import {
|
||||
RequestQuery,
|
||||
RequestSortDefinitionInner,
|
||||
@ -227,6 +227,20 @@ export class TagService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a tag with tagId.
|
||||
* This will cause the tag to be removed from all nodes.
|
||||
* You must have admin rights to delete a tag.
|
||||
*
|
||||
* @param tagId of the tag to be deleted
|
||||
* @returns Null object when the operation completes
|
||||
*/
|
||||
deleteTag(tagId: string): Observable<void> {
|
||||
return from(this.tagsApi.deleteTag(tagId)).pipe(
|
||||
tap((data) => this.refresh.emit(data))
|
||||
);
|
||||
}
|
||||
|
||||
private handleError(error: any) {
|
||||
this.logService.error(error);
|
||||
return throwError(error || 'Server error');
|
||||
|
Loading…
x
Reference in New Issue
Block a user