From 3e2683e06b18206640300d8f46143101c3499d0a Mon Sep 17 00:00:00 2001 From: AleksanderSklorz <115619721+AleksanderSklorz@users.noreply.github.com> Date: Thu, 30 Mar 2023 08:47:09 +0200 Subject: [PATCH] [ACS-4126] viewer allow assigning tags to content basic (#8417) * ACS-4126 Moved component for tags creation from applications to ADF, putting that component into Viewer * ACS-4126 Assigning tags to node and removed reference to modal from component for tags creating * ACS-4126 Started working on assigning existing tags to node * ACS-4126 Added newest changes for tags creation component * ACS-4126 Usage of MatSelectionList, possibility for selecting existing tag * ACS-4126 Allow to pass already assigned tags to tags creator as default top list * ACS-4126 Fixed some css issues like aligning of icons, hiden add input icon when input is already visible * ACS-4126 Allow to unlink tags from content * ACS-4126 Allow for discard changes and fixed some validation issues * ACS-4126 Integrate with changes for removing pagination * ACS-4126 Autoscroll to input, remove scrollbar from search list * ACS-4126 Code formatting * ACS-4126 Renamed prefix for tags and style classes * ACS-4126 Refreshing assigned tags after linking them, disable some operations during saving * ACS-4126 Remove scrollbar from create label for long text, corrected some validations, use p tag instead of card view for displaying already assigned tags * ACS-4126 Removed redundant code from tags creator component * ACS-4126 Corrected translations * ACS-4126 Hide input during saving * ACS-4126 Unit tests for ContentMetadataComponent * ACS-4126 Unit tests for TagService * ACS-4126 Fixed unit tests for TagsCreator * ACS-4126 Added documentation * ACS-4126 Added additional unit tests * ACS-4126 Fixed lint issues * ACS-4126 Remove tags from files and folders list when taggable is unchecked * ACS-4126 Small correction in styles * ACS-4126 Corrected type for assigning single tag * ACS-4126 Updated docs * ACS-4126 Updated docs * ACS-4126 Fixed some unit tests * ACS-4126 Fixed lint issues * ACS-4126 Updated jsdoc * ACS-4126 Reverted one unwanted line * ACS-4126 Removed space which caused lint issue * ACS-4126 Fixed unit tests * ACS-4126 Restored change * ACS-4126 Fixed unit tests * ACS-4126 Small correction --- .../components/tags-creator.component.md | 40 + docs/content-services/services/tag.service.md | 5 + .../services/node-aspect.service.spec.ts | 10 + .../services/node-aspect.service.ts | 5 +- .../content-metadata-card.component.html | 3 +- .../content-metadata-card.component.spec.ts | 7 +- .../content-metadata.component.html | 31 +- .../content-metadata.component.scss | 39 + .../content-metadata.component.spec.ts | 377 +++++++++- .../content-metadata.component.ts | 103 ++- .../content-metadata.module.ts | 4 +- lib/content-services/src/lib/i18n/en.json | 27 +- .../src/lib/tag/public-api.ts | 4 + .../src/lib/tag/services/tag.service.spec.ts | 45 ++ .../src/lib/tag/services/tag.service.ts | 16 +- .../src/lib/tag/tag-actions.component.spec.ts | 2 +- .../lib/tag/tag-node-list.component.spec.ts | 2 +- .../src/lib/tag/tag.module.ts | 9 +- .../lib/tag/tags-creator/tags-creator-mode.ts | 26 + .../tags-creator/tags-creator.component.html | 87 +++ .../tags-creator/tags-creator.component.scss | 144 ++++ .../tags-creator.component.spec.ts | 689 ++++++++++++++++++ .../tags-creator/tags-creator.component.ts | 427 +++++++++++ 23 files changed, 2067 insertions(+), 35 deletions(-) create mode 100644 docs/content-services/components/tags-creator.component.md create mode 100644 lib/content-services/src/lib/tag/tags-creator/tags-creator-mode.ts create mode 100644 lib/content-services/src/lib/tag/tags-creator/tags-creator.component.html create mode 100644 lib/content-services/src/lib/tag/tags-creator/tags-creator.component.scss create mode 100644 lib/content-services/src/lib/tag/tags-creator/tags-creator.component.spec.ts create mode 100644 lib/content-services/src/lib/tag/tags-creator/tags-creator.component.ts 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">