-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [ACS-4523] Add categories management mode component, manage mode completed * [ACS-4523] Add categories management fixes and unit tests * [ACS-4523] Add unit tests to content metadata * ACS-4523] CR fixes * [ACS-4523] Tag and category name controls decoupled * [ACS-4523] CR fixes * [ACS-4523] CR fixes * [ACS-4523] CR fixes * [ACS-4523] Display path for already linked categories * [ACS-4523] Add new license header * [ACS-4523] Fix category service import
- Loading branch information
1 parent
e9b8d99
commit a563dc2
Showing
25 changed files
with
1,619 additions
and
123 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
docs/content-services/components/categories-management.component.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
Title: Categories management component | ||
Added: v6.0.0-A.3 | ||
Status: Active | ||
Last reviewed: 2023-04-07 | ||
--- | ||
|
||
# [Categories management component](../../../lib/content-services/src/lib/category/categories-management/categories-management.component.ts "Defined in categories-management.component.ts") | ||
|
||
Component allows to both assign/unassign categories to content and create multiple categories depending on selected mode. In assign mode component is composed of: list of categories that will be assigned to a file, input to search for existing categories that user can select and second list under the input containing existing categories that node can be assigned to. In crud mode component is composed of: list of categories that will be created, input to type a name of category that will be created and a list of categories existing under a given parent, in this mode existing categories are not selectable. | ||
|
||
## Basic Usage | ||
|
||
```html | ||
<adf-categories-management | ||
[(categoryNameControlVisible)]="categoryControlVisible" | ||
[disableRemoval]="saving" | ||
[categories]="categories" | ||
[parentId]="parentId" | ||
[managementMode]="categoriesManagementMode" | ||
[classifiableChanged]="classifiableChanged" | ||
(categoriesChange)="storeCategoriesToAssign($event)"> | ||
</adf-categories-management> | ||
``` | ||
|
||
## Class members | ||
|
||
### Properties | ||
|
||
| Name | Type | Default value | Description | | ||
| ---- | ---- | ------------- | ----------- | | ||
| categories | [`Category`](https://github.com/Alfresco/alfresco-js-api/blob/develop/src/api/content-rest-api/docs/Category.md)[] | [] | List of categories to assign/create. | | ||
| categoryNameControlVisible | `boolean` | false | Determines if category name control is visible. | | ||
| classifiableChanged | [`Observable<void>`](https://rxjs.dev/guide/observable) | | (optional) Observable emitting when `classifiable` aspect changes for a given node. | | ||
| disableRemoval | `boolean` | false | Determines if categories assigned/created can be unassigned/removed from the list. | | ||
| managementMode | `CategoriesManagementMode` | | Management mode determines if component works in assign/unassign mode or create mode. | | ||
| parentId | `string` | | (optional) ID of a parent category that new categories will be created under. | | ||
|
||
### Events | ||
|
||
| Name | Type | Description | | ||
| ---- | ---- | ----------- | | ||
| categoriesChange | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`Category`](https://github.com/Alfresco/alfresco-js-api/blob/develop/src/api/content-rest-api/docs/Category.md)`>` | Emitted when categories list changes. | | ||
| categoryNameControlVisibleChange | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<boolean>` | Emitted when category name control visibility changes. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
lib/content-services/src/lib/category/categories-management/categories-management-mode.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/*! | ||
* @license | ||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
export enum CategoriesManagementMode { | ||
CRUD, | ||
ASSIGN | ||
} |
85 changes: 85 additions & 0 deletions
85
...tent-services/src/lib/category/categories-management/categories-management.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<div class="adf-categories-management"> | ||
<p *ngIf="!categories.length && !categoryNameControlVisible" | ||
class="adf-no-categories-message"> | ||
{{ isCRUDMode ? 'CATEGORIES_MANAGEMENT.NO_CATEGORIES_CREATED' : 'CATEGORIES_MANAGEMENT.NO_CATEGORIES_ASSIGNED' | translate }} | ||
</p> | ||
<div class="adf-categories-list" | ||
[class.adf-categories-list-fixed]="!categoryNameControlVisible"> | ||
<span | ||
*ngFor="let category of categories" | ||
[class.adf-categories-padded]="!isCRUDMode" | ||
class="adf-assigned-categories"> | ||
{{ category.name }} | ||
<button | ||
data-automation-id="categories-remove-category-button" | ||
mat-icon-button | ||
[class.adf-btn-padded]="!isCRUDMode" | ||
(click)="removeCategory(category)" | ||
[attr.title]="isCRUDMode ? 'CATEGORIES_MANAGEMENT.DELETE_CATEGORY' : 'CATEGORIES_MANAGEMENT.UNASSIGN_CATEGORY' | translate" | ||
[disabled]="disableRemoval"> | ||
<mat-icon>remove</mat-icon> | ||
</button> | ||
</span> | ||
</div> | ||
<div *ngIf="((!categoryNameControlVisible && categories.length)) || categoryNameControlVisible" | ||
[hidden]="!categoryNameControlVisible" | ||
class="adf-category-name-field"> | ||
<mat-form-field> | ||
<mat-icon matPrefix>search</mat-icon> | ||
<mat-label id="adf-category-name-input-label"> | ||
{{ 'CATEGORIES_MANAGEMENT.NAME' | translate }} | ||
</mat-label> | ||
<input | ||
#categoryNameInput | ||
matInput | ||
autocomplete="off" | ||
[formControl]="categoryNameControl" | ||
(keyup.enter)="addCategory()" | ||
aria-labelledby="adf-category-name-input-label" | ||
adf-auto-focus | ||
/> | ||
<mat-error [hidden]="!categoryNameControl.invalid">{{ categoryNameErrorMessageKey | translate }}</mat-error> | ||
</mat-form-field> | ||
<button | ||
mat-icon-button | ||
[class.adf-btn-padded]="!isCRUDMode" | ||
(click)="hideNameInput()" | ||
[attr.title]="'CATEGORIES_MANAGEMENT.HIDE_INPUT' | translate"> | ||
<mat-icon>remove</mat-icon> | ||
</button> | ||
</div> | ||
</div> | ||
<div class="adf-existing-categories-panel" *ngIf="existingCategoriesPanelVisible"> | ||
<ng-container *ngIf="isCRUDMode && (!existingCategoriesLoading || existingCategories)"> | ||
<span class="adf-create-category-label" | ||
(click)="addCategory()" | ||
[hidden]="categoryNameControl.invalid || typing"> | ||
{{ 'CATEGORIES_MANAGEMENT.GENERIC_CREATE' | translate : { name: categoryNameControl.value } }} | ||
</span> | ||
</ng-container> | ||
<div *ngIf="categoryNameControlVisible" class="adf-categories-list"> | ||
<ng-container *ngIf="!existingCategoriesLoading && existingCategories"> | ||
<p class="adf-existing-categories-label"> | ||
{{ isCRUDMode ? 'CATEGORIES_MANAGEMENT.EXISTING_CATEGORIES' : 'CATEGORIES_MANAGEMENT.SELECT_EXISTING_CATEGORY' | translate }} | ||
</p> | ||
<mat-selection-list | ||
[disabled]="isCRUDMode" | ||
(selectionChange)="addCategoryToAssign($event)"> | ||
<mat-list-option | ||
*ngFor="let category of existingCategories" | ||
class="adf-category" | ||
[value]="category"> | ||
{{ category.name }} | ||
</mat-list-option> | ||
<p *ngIf="!existingCategories?.length && !existingCategoriesLoading"> | ||
{{ 'CATEGORIES_MANAGEMENT.NO_EXISTING_CATEGORIES' | translate }} | ||
</p> | ||
</mat-selection-list> | ||
</ng-container> | ||
<mat-spinner | ||
*ngIf="existingCategoriesLoading" | ||
[diameter]="50" | ||
[attr.aria-label]="'CATEGORIES_MANAGEMENT.LOADING' | translate"> | ||
</mat-spinner> | ||
</div> | ||
</div> |
79 changes: 79 additions & 0 deletions
79
...tent-services/src/lib/category/categories-management/categories-management.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
.adf-categories-management { | ||
.adf-category-name-field { | ||
display: flex; | ||
justify-content: space-between; | ||
width: 100%; | ||
|
||
mat-form-field { | ||
width: 100%; | ||
} | ||
|
||
.adf-btn-padded { | ||
margin-right: -14px; | ||
} | ||
} | ||
|
||
.adf-assigned-categories { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
word-break: break-word; | ||
|
||
.adf-btn-padded { | ||
margin-right: -14px; | ||
} | ||
} | ||
|
||
.adf-categories-padded { | ||
padding: 5px 0; | ||
} | ||
|
||
[hidden] { | ||
visibility: hidden; | ||
} | ||
} | ||
|
||
.adf-categories-list { | ||
padding-bottom: 10px; | ||
|
||
.mat-list-base .mat-list-item, | ||
.mat-list-base .mat-list-option { | ||
display: flex; | ||
height: 100%; | ||
overflow-wrap: anywhere; | ||
padding: 5px 0; | ||
font-size: 14px; | ||
|
||
&.mat-list-item-disabled { | ||
background-color: inherit; | ||
color: inherit; | ||
} | ||
|
||
.mat-list-item-content, | ||
.mat-list-item-content-reverse { | ||
padding: 0; | ||
|
||
.mat-pseudo-checkbox { | ||
display: none; | ||
} | ||
} | ||
} | ||
|
||
.adf-existing-categories-label { | ||
font-size: 10px; | ||
color: var(--theme-secondary-text-color); | ||
margin-bottom: 2px; | ||
} | ||
|
||
mat-spinner { | ||
margin: auto; | ||
} | ||
} | ||
|
||
.adf-existing-categories-panel { | ||
.adf-create-category-label { | ||
color: var(--theme-primary-color); | ||
cursor: pointer; | ||
overflow-wrap: anywhere; | ||
} | ||
} |
Oops, something went wrong.