diff --git a/docs/content-services/components/tags-creator.component.md b/docs/content-services/components/tags-creator.component.md new file mode 100644 index 0000000000..0916341ea6 --- /dev/null +++ b/docs/content-services/components/tags-creator.component.md @@ -0,0 +1,40 @@ +--- +Title: Tags Creator component +Added: v6.0.0-A.3 +Status: Active +Last reviewed: 2023-03-27 +--- + +# [Tags Creator component](../../../lib/content-services/src/lib/tag/tags-creator/tags-creator.component.ts "Defined in tags-creator.component.ts") + +Allows to create multiple tags. That component contains input and two lists. Top list is all created tags, bottom list is searched tags based on input's value. + +## Basic Usage + +```html + + +``` + +## Class members + +### Properties + +| Name | Type | Default value | Description | +|-----------------------|-------------------|---------------|-------------------------------------------------------------------------------------------------------------------------------------| +| mode | `TagsCreatorMode` | | Create mode if only new tags can be created or Create And Assign mode if new tags can be created and existing tags can be selected. | +| disabledTagsRemoving | `boolean` | false | False if tags can be removed from top list, true otherwise. | +| tags | `string[]` | | Default top list. | +| tagNameControlVisible | `boolean` | false | True if input should be visible, false otherwise. | | + +### Events + +| Name | Type | Description | +|-----------------------------------|------------------------------------------------------------------------|--------------------------------------------------| +| existingTagsPanelVisibilityChange | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`` | Emitted when bottom list is showing or hiding. | +| tagsChange | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`` | Emitted when tags in top list are changed. | +| tagNameControlVisibleChange | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`` | Emitted when input is showing or hiding. | + diff --git a/docs/content-services/services/tag.service.md b/docs/content-services/services/tag.service.md index 18e22d2ae5..a890c9b416 100644 --- a/docs/content-services/services/tag.service.md +++ b/docs/content-services/services/tag.service.md @@ -61,6 +61,11 @@ Manages tags in Content Services. Find tag which name matches exactly to passed name. - _name:_ `string` - Value for name which should be used during finding exact tag. - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`` - Found tag which name matches exactly to passed name. +- **assignTagsToNode**(nodeId: `string`, tags: `TagBody[]`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TagPaging`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/TagPaging.md)`|`[`TagEntry`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/TagEntry.md)`>`
+ Assign tags to node. If tag is new then tag is also created additionally, if tag already exists then it is just assigned. + - _nodeId:_ `string` - Id of node to which tags should be assigned. + - _tags:_ `TagBody[]` - List of tags to create and assign or just assign if they already exist. + - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TagPaging`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/TagPaging.md)`|`[`TagEntry`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/TagEntry.md)`>` - Just linked tags to node or single tag if linked only one tag. ## Details diff --git a/lib/content-services/src/lib/aspect-list/services/node-aspect.service.spec.ts b/lib/content-services/src/lib/aspect-list/services/node-aspect.service.spec.ts index b2ce9044b5..0b855f5257 100644 --- a/lib/content-services/src/lib/aspect-list/services/node-aspect.service.spec.ts +++ b/lib/content-services/src/lib/aspect-list/services/node-aspect.service.spec.ts @@ -25,6 +25,7 @@ import { ContentTestingModule } from '../../testing/content.testing.module'; import { NodeAspectService } from './node-aspect.service'; import { DialogAspectListService } from './dialog-aspect-list.service'; import { CardViewContentUpdateService } from '../../common/services/card-view-content-update.service'; +import { TagService } from '@alfresco/adf-content-services'; describe('NodeAspectService', () => { @@ -99,4 +100,13 @@ describe('NodeAspectService', () => { nodeAspectService.updateNodeAspects('fake-node-id'); }); + it('should call emit on refresh from TagService', () => { + const tagService = TestBed.inject(TagService); + spyOn(dialogAspectListService, 'openAspectListDialog').and.returnValue(of([])); + const node = new MinimalNode({ id: 'fake-node-id', aspectNames: ['a', 'b', 'c'] }); + spyOn(nodeApiService, 'updateNode').and.returnValue(of(node)); + spyOn(tagService.refresh, 'emit'); + nodeAspectService.updateNodeAspects('some node id', 'some-selector'); + expect(tagService.refresh.emit).toHaveBeenCalled(); + }); }); diff --git a/lib/content-services/src/lib/aspect-list/services/node-aspect.service.ts b/lib/content-services/src/lib/aspect-list/services/node-aspect.service.ts index c027f54eeb..3dbe34767d 100644 --- a/lib/content-services/src/lib/aspect-list/services/node-aspect.service.ts +++ b/lib/content-services/src/lib/aspect-list/services/node-aspect.service.ts @@ -19,6 +19,7 @@ import { Injectable } from '@angular/core'; import { DialogAspectListService } from './dialog-aspect-list.service'; import { CardViewContentUpdateService } from '../../common/services/card-view-content-update.service'; import { NodesApiService } from '../../common/services/nodes-api.service'; +import { TagService } from '../../tag/services/tag.service'; @Injectable({ providedIn: 'root' @@ -27,7 +28,8 @@ export class NodeAspectService { constructor(private nodesApiService: NodesApiService, private dialogAspectListService: DialogAspectListService, - private cardViewContentUpdateService: CardViewContentUpdateService) { + private cardViewContentUpdateService: CardViewContentUpdateService, + private tagService: TagService) { } updateNodeAspects(nodeId: string, selectorAutoFocusedOnClose?: string) { @@ -35,6 +37,7 @@ export class NodeAspectService { this.nodesApiService.updateNode(nodeId, { aspectNames: [...aspectList] }).subscribe((updatedNode) => { this.nodesApiService.nodeUpdated.next(updatedNode); this.cardViewContentUpdateService.updateNodeAspect(updatedNode); + this.tagService.refresh.emit(); }); }); } diff --git a/lib/content-services/src/lib/content-metadata/components/content-metadata-card/content-metadata-card.component.html b/lib/content-services/src/lib/content-metadata/components/content-metadata-card/content-metadata-card.component.html index ada1a528f2..66529e27c1 100644 --- a/lib/content-services/src/lib/content-metadata/components/content-metadata-card/content-metadata-card.component.html +++ b/lib/content-services/src/lib/content-metadata/components/content-metadata-card/content-metadata-card.component.html @@ -8,7 +8,8 @@ [editable]="editable" [multi]="multi" [displayAspect]="displayAspect" - [preset]="preset"> + [preset]="preset" + [displayTags]="true">