mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-5362] Add option to make actions button visible only on hover (#7117)
* [AAE-5362] Add option to make actions button visible only on hover * [AAE-5362] Refactor * Unrelated linting fixes
This commit is contained in:
@@ -346,6 +346,7 @@ Learm more about styling your datatable: [Customizing the component's styles](#c
|
|||||||
| ---- | ---- | ------------- | ----------- |
|
| ---- | ---- | ------------- | ----------- |
|
||||||
| actions | `boolean` | false | Toggles the data actions column. |
|
| actions | `boolean` | false | Toggles the data actions column. |
|
||||||
| actionsPosition | `string` | "right" | Position of the actions dropdown menu. Can be "left" or "right". |
|
| actionsPosition | `string` | "right" | Position of the actions dropdown menu. Can be "left" or "right". |
|
||||||
|
| actionsVisibleOnHover | `boolean` | false | If set to true, the actions button will only be visible on row hover. |
|
||||||
| allowFiltering | `boolean` | false | Flag that indicate if the datatable allow the use facet [widget](../../../lib/testing/src/lib/core/pages/form/widgets/widget.ts) search for filtering. |
|
| allowFiltering | `boolean` | false | Flag that indicate if the datatable allow the use facet [widget](../../../lib/testing/src/lib/core/pages/form/widgets/widget.ts) search for filtering. |
|
||||||
| columns | `any[]` | \[] | The columns that the datatable will show. |
|
| columns | `any[]` | \[] | The columns that the datatable will show. |
|
||||||
| contextMenu | `boolean` | false | Toggles custom context menu for the component. |
|
| contextMenu | `boolean` | false | Toggles custom context menu for the component. |
|
||||||
|
@@ -407,7 +407,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
component.displayEmpty = true;
|
component.displayEmpty = true;
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable()
|
await fixture.whenStable();
|
||||||
|
|
||||||
let defaultProp = queryDom(fixture);
|
let defaultProp = queryDom(fixture);
|
||||||
let exifProp = queryDom(fixture, 'EXIF');
|
let exifProp = queryDom(fixture, 'EXIF');
|
||||||
@@ -419,7 +419,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
component.displayAspect = 'CUSTOM';
|
component.displayAspect = 'CUSTOM';
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable()
|
await fixture.whenStable();
|
||||||
|
|
||||||
defaultProp = queryDom(fixture);
|
defaultProp = queryDom(fixture);
|
||||||
exifProp = queryDom(fixture, 'EXIF');
|
exifProp = queryDom(fixture, 'EXIF');
|
||||||
@@ -431,7 +431,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
component.displayAspect = 'Properties';
|
component.displayAspect = 'Properties';
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable()
|
await fixture.whenStable();
|
||||||
|
|
||||||
defaultProp = queryDom(fixture);
|
defaultProp = queryDom(fixture);
|
||||||
exifProp = queryDom(fixture, 'EXIF');
|
exifProp = queryDom(fixture, 'EXIF');
|
||||||
|
@@ -188,7 +188,7 @@ describe('DropdownSitesComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
let options = debug.queryAll(By.css('mat-option'));
|
const options = debug.queryAll(By.css('mat-option'));
|
||||||
options[0].triggerEventHandler('click', null);
|
options[0].triggerEventHandler('click', null);
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
@@ -135,7 +135,7 @@ describe('CommentsComponent', () => {
|
|||||||
getProcessCommentsSpy.and.returnValue(of([]));
|
getProcessCommentsSpy.and.returnValue(of([]));
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable()
|
await fixture.whenStable();
|
||||||
|
|
||||||
expect(fixture.nativeElement.querySelector('#comment-container')).toBeNull();
|
expect(fixture.nativeElement.querySelector('#comment-container')).toBeNull();
|
||||||
});
|
});
|
||||||
@@ -145,7 +145,7 @@ describe('CommentsComponent', () => {
|
|||||||
component.ngOnChanges({'taskId': change});
|
component.ngOnChanges({'taskId': change});
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable()
|
await fixture.whenStable();
|
||||||
|
|
||||||
expect(fixture.nativeElement.querySelector('#comment-input')).not.toBeNull();
|
expect(fixture.nativeElement.querySelector('#comment-input')).not.toBeNull();
|
||||||
});
|
});
|
||||||
@@ -154,7 +154,7 @@ describe('CommentsComponent', () => {
|
|||||||
component.readOnly = true;
|
component.readOnly = true;
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable()
|
await fixture.whenStable();
|
||||||
|
|
||||||
expect(fixture.nativeElement.querySelector('#comment-input')).toBeNull();
|
expect(fixture.nativeElement.querySelector('#comment-input')).toBeNull();
|
||||||
});
|
});
|
||||||
|
@@ -72,7 +72,8 @@
|
|||||||
[attr.data-automation-id]="'datatable-row-' + idx">
|
[attr.data-automation-id]="'datatable-row-' + idx">
|
||||||
<!-- Actions (left) -->
|
<!-- Actions (left) -->
|
||||||
<div *ngIf="actions && actionsPosition === 'left'" role="gridcell" class="adf-datatable-cell">
|
<div *ngIf="actions && actionsPosition === 'left'" role="gridcell" class="adf-datatable-cell">
|
||||||
<button mat-icon-button [matMenuTriggerFor]="menu"
|
<button mat-icon-button [matMenuTriggerFor]="menu" #actionsMenuTrigger="matMenuTrigger"
|
||||||
|
[ngClass]="getHideActionsWithoutHoverClass(actionsMenuTrigger)"
|
||||||
[title]="'ADF-DATATABLE.CONTENT-ACTIONS.TOOLTIP' | translate"
|
[title]="'ADF-DATATABLE.CONTENT-ACTIONS.TOOLTIP' | translate"
|
||||||
[attr.id]="'action_menu_left_' + idx"
|
[attr.id]="'action_menu_left_' + idx"
|
||||||
[attr.data-automation-id]="'action_menu_' + idx">
|
[attr.data-automation-id]="'action_menu_' + idx">
|
||||||
@@ -209,7 +210,8 @@
|
|||||||
<div *ngIf="actions && actionsPosition === 'right'"
|
<div *ngIf="actions && actionsPosition === 'right'"
|
||||||
role="gridcell"
|
role="gridcell"
|
||||||
class="adf-datatable-cell adf-datatable__actions-cell adf-datatable-center-actions-column-ie">
|
class="adf-datatable-cell adf-datatable__actions-cell adf-datatable-center-actions-column-ie">
|
||||||
<button mat-icon-button [matMenuTriggerFor]="menu"
|
<button mat-icon-button [matMenuTriggerFor]="menu" #actionsMenuTrigger="matMenuTrigger"
|
||||||
|
[ngClass]="getHideActionsWithoutHoverClass(actionsMenuTrigger)"
|
||||||
[attr.aria-label]="'ADF-DATATABLE.ACCESSIBILITY.ROW_OPTION_BUTTON' | translate"
|
[attr.aria-label]="'ADF-DATATABLE.ACCESSIBILITY.ROW_OPTION_BUTTON' | translate"
|
||||||
[title]="'ADF-DATATABLE.CONTENT-ACTIONS.TOOLTIP' | translate"
|
[title]="'ADF-DATATABLE.CONTENT-ACTIONS.TOOLTIP' | translate"
|
||||||
[attr.id]="'action_menu_right_' + idx"
|
[attr.id]="'action_menu_right_' + idx"
|
||||||
|
@@ -149,6 +149,10 @@
|
|||||||
top: 4px;
|
top: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.adf-datatable-row:not(:hover) .adf-datatable-hide-actions-without-hover {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.adf-image-table-cell {
|
.adf-image-table-cell {
|
||||||
margin: 8px;
|
margin: 8px;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
@@ -439,6 +443,10 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.adf-datatable-row:not(:hover) .adf-datatable-hide-actions-without-hover {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.adf-datatable-cell--image {
|
.adf-datatable-cell--image {
|
||||||
max-width: $data-table-thumbnail-width;
|
max-width: $data-table-thumbnail-width;
|
||||||
}
|
}
|
||||||
|
@@ -22,6 +22,7 @@ import {
|
|||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { FocusKeyManager } from '@angular/cdk/a11y';
|
import { FocusKeyManager } from '@angular/cdk/a11y';
|
||||||
import { MatCheckboxChange } from '@angular/material/checkbox';
|
import { MatCheckboxChange } from '@angular/material/checkbox';
|
||||||
|
import { MatMenuTrigger } from '@angular/material/menu';
|
||||||
import { Subscription, Observable, Observer } from 'rxjs';
|
import { Subscription, Observable, Observer } from 'rxjs';
|
||||||
import { DataColumnListComponent } from '../../../data-column/data-column-list.component';
|
import { DataColumnListComponent } from '../../../data-column/data-column-list.component';
|
||||||
import { DataColumn } from '../../data/data-column.model';
|
import { DataColumn } from '../../data/data-column.model';
|
||||||
@@ -103,6 +104,10 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
|
|||||||
@Input()
|
@Input()
|
||||||
actionsPosition: string = 'right'; // left|right
|
actionsPosition: string = 'right'; // left|right
|
||||||
|
|
||||||
|
/** Toggles whether the actions dropdown should only be visible if the row is hovered over or the dropdown menu is open. */
|
||||||
|
@Input()
|
||||||
|
actionsVisibleOnHover: boolean = false;
|
||||||
|
|
||||||
/** Fallback image for rows where the thumbnail is missing. */
|
/** Fallback image for rows where the thumbnail is missing. */
|
||||||
@Input()
|
@Input()
|
||||||
fallbackThumbnail: string;
|
fallbackThumbnail: string;
|
||||||
@@ -676,6 +681,10 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getHideActionsWithoutHoverClass(actionsMenuTrigger: MatMenuTrigger) {
|
||||||
|
return { 'adf-datatable-hide-actions-without-hover': this.actionsVisibleOnHover && !actionsMenuTrigger.menuOpen };
|
||||||
|
}
|
||||||
|
|
||||||
rowAllowsDrop(row: DataRow): boolean {
|
rowAllowsDrop(row: DataRow): boolean {
|
||||||
return row.isDropTarget === true;
|
return row.isDropTarget === true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user