mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4893] Fix visibility condition in datatable action menu (#5088)
* [ADF-4893] Fix visibility condition in datatable action menu * Add filtering for when menu cache is disabled * Fix unit test and improve code * Fix linting * Fix linting * Add missing return type
This commit is contained in:
committed by
Eugenio Romano
parent
1d7ef62095
commit
47ec01555a
@@ -69,13 +69,13 @@ export class CloudSettingsComponent implements OnInit, OnDestroy {
|
||||
setCurrentSettings(settings) {
|
||||
if (settings) {
|
||||
this.multiselect = settings.multiselect;
|
||||
this.actionMenu = this.actionMenu;
|
||||
this.contextMenu = this.contextMenu;
|
||||
this.actions = this.actions;
|
||||
this.testingMode = settings.testingMode;
|
||||
this.selectionMode = settings.selectionMode;
|
||||
this.taskDetailsRedirection = settings.taskDetailsRedirection;
|
||||
this.processDetailsRedirection = settings.processDetailsRedirection;
|
||||
this.actionMenu = settings.actionMenu;
|
||||
this.contextMenu = settings.contextMenu;
|
||||
this.actions = settings.actions;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -554,6 +554,20 @@ describe('DataTable', () => {
|
||||
expect(actions.length).toBe(4);
|
||||
});
|
||||
|
||||
it('should show only visible actions', () => {
|
||||
const unfilteredActions = [
|
||||
{ title: 'action1', name: 'view1', visible: true },
|
||||
{ title: 'action2', name: 'view2', visible: false },
|
||||
{ title: 'action3', name: 'view3', visible: null },
|
||||
{ title: 'action4', name: 'view4' }
|
||||
];
|
||||
|
||||
const actions = dataTable.getVisibleActions(unfilteredActions);
|
||||
expect(actions.length).toBe(2);
|
||||
expect(actions[0].title).toBe('action1');
|
||||
expect(actions[1].title).toBe('action4');
|
||||
});
|
||||
|
||||
it('should initialize default adapter', () => {
|
||||
const table = new DataTableComponent(null, null);
|
||||
expect(table.data).toBeUndefined();
|
||||
|
@@ -568,12 +568,16 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
|
||||
const event = new DataCellEvent(row, col, []);
|
||||
this.showRowActionsMenu.emit(event);
|
||||
if (!this.rowMenuCacheEnabled) {
|
||||
return event.value.actions;
|
||||
return this.getVisibleActions(event.value.actions);
|
||||
}
|
||||
this.rowMenuCache[id] = event.value.actions;
|
||||
}
|
||||
|
||||
return this.rowMenuCache[id];
|
||||
return this.getVisibleActions(this.rowMenuCache[id]);
|
||||
}
|
||||
|
||||
getVisibleActions(actions: any[]): any[] {
|
||||
return actions.filter((action) => action.visible || action.visible === undefined);
|
||||
}
|
||||
|
||||
onExecuteRowAction(row: DataRow, action: any) {
|
||||
|
Reference in New Issue
Block a user