From 9863149a28fbaac9ed5a59de4b27f0942e8ef510 Mon Sep 17 00:00:00 2001 From: AleksanderSklorz <115619721+AleksanderSklorz@users.noreply.github.com> Date: Wed, 8 Mar 2023 14:11:48 +0100 Subject: [PATCH] [ACS-4592] missing right click menu on row and left click is only allow on indicator rotate (#8327) * ACS-4592 Displaying context menu for tree list row and allow to expand row by clicking at label * ACS-4592 Added clicking on label for load more button * ACS-4592 Unit tests * ACS-4592 Added documentation for context menu for tree component and fixed lint issues * ACS-4592 Trigger stuck check --- .../components/tree.component.md | 28 +-- .../lib/tree/components/tree.component.html | 14 +- .../lib/tree/components/tree.component.scss | 8 +- .../tree/components/tree.component.spec.ts | 189 +++++++++++++++++- .../src/lib/tree/components/tree.component.ts | 98 +++++++-- .../tree-context-menu-result.interface.ts | 21 ++ .../src/lib/tree/public-api.ts | 1 + .../src/lib/tree/tree.module.ts | 5 +- 8 files changed, 315 insertions(+), 49 deletions(-) create mode 100644 lib/content-services/src/lib/tree/models/tree-context-menu-result.interface.ts diff --git a/docs/content-services/components/tree.component.md b/docs/content-services/components/tree.component.md index d49ddeb2cb..2ee18cb4eb 100644 --- a/docs/content-services/components/tree.component.md +++ b/docs/content-services/components/tree.component.md @@ -27,23 +27,25 @@ Shows the nodes in tree structure, each node containing children is collapsible/ ### Properties -| Name | Type | Default value | Description | -| ---- | ---- | ------------- | ----------- | -| emptyContentTemplate | `TemplateRef` | | Template that will be rendered when no nodes are loaded. | -| nodeActionsMenuTemplate | `TemplateRef` | | Template that will be rendered when context menu for given node is opened. | -| stickyHeader | `boolean` | false | If set to true header will be sticky. | -| selectableNodes | `boolean` | false | If set to true nodes will be selectable. | -| displayName | `string` | | Display name for tree title. | -| loadMoreSuffix | `string` | | Suffix added to `Load more` string inside load more node. | -| expandIcon | `string` | `chevron_right` | Icon shown when node is collapsed. | -| collapseIcon | `string` | `expand_more` | Icon showed when node is expanded. | +| Name | Type | Default value | Description | +| ---- |---------------| --------- | ----------- | +| emptyContentTemplate | `TemplateRef` | | Template that will be rendered when no nodes are loaded. | +| nodeActionsMenuTemplate | `TemplateRef` | | Template that will be rendered when context menu for given node is opened. | +| stickyHeader | `boolean` | false | If set to true header will be sticky. | +| selectableNodes | `boolean` | false | If set to true nodes will be selectable. | +| displayName | `string` | | Display name for tree title. | +| loadMoreSuffix | `string` | | Suffix added to `Load more` string inside load more node. | +| expandIcon | `string` | `chevron_right` | Icon shown when node is collapsed. | +| collapseIcon | `string` | `expand_more` | Icon showed when node is expanded. | +| contextMenuOptions | `any[]` | | Array of context menu options which should be displayed for each row. | ### Events -| Name | Type | Description | -| ---- | ---- | ----------- | -| paginationChanged | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`` | Emitted when during loading additional nodes pagination changes. | +| Name | Type | Description | +| ---- |----------------------------------------------------------------------------------------|------------------------------------------------------------------| +| paginationChanged | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`` | Emitted when during loading additional nodes pagination changes. | +| contextMenuOptionSelected | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`>` | Emitted when any context menu option is selected. | ## Details diff --git a/lib/content-services/src/lib/tree/components/tree.component.html b/lib/content-services/src/lib/tree/components/tree.component.html index 22b8ad1414..c559cf44f5 100644 --- a/lib/content-services/src/lib/tree/components/tree.component.html +++ b/lib/content-services/src/lib/tree/components/tree.component.html @@ -33,7 +33,9 @@
- + {{ 'ADF-TREE.LOAD-MORE-BUTTON' | translate: { name: loadMoreSuffix } }}
@@ -42,7 +44,10 @@ class="adf-tree-row" [attr.data-automation-id]="'node_' + node.id" *matTreeNodeDef="let node" - matTreeNodePadding> + matTreeNodePadding + [adf-context-menu]="contextMenuOptions" + [adf-context-menu-enabled]="!!contextMenuOptions" + (contextmenu)="contextMenuSource = node">