mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-551] allow setting sorting in html (#1857)
* allow setting sorting in html * readme update * update readme * restore permissions code * - Remove the check permission from the datatable and move inside the documentlist * Remove commented test
This commit is contained in:
committed by
Eugenio Romano
parent
416d8c2a1b
commit
b0be88ec37
@@ -415,86 +415,4 @@ describe('DataTable', () => {
|
||||
expect(event.target.src).toBe(originalSrc);
|
||||
});
|
||||
|
||||
it('should disable the action if there is no permission and disableWithNoPermission true', () => {
|
||||
|
||||
dataTable.data = new ObjectDataTableAdapter(
|
||||
[{id: 1, name: 'xyz', allowableOperations: ['create', 'update']}],
|
||||
[]
|
||||
);
|
||||
|
||||
let row = dataTable.data.getRows();
|
||||
let actions = [
|
||||
{
|
||||
disableWithNoPermission: true,
|
||||
permission: 'delete',
|
||||
target: 'folder',
|
||||
title: 'action2'
|
||||
}
|
||||
];
|
||||
|
||||
let updateActions = dataTable.checkPermissions(row[0], actions);
|
||||
expect(updateActions[0].disabled).toBe(true);
|
||||
});
|
||||
|
||||
it('should not disable the action if there is no permission and disableWithNoPermission false', () => {
|
||||
|
||||
dataTable.data = new ObjectDataTableAdapter(
|
||||
[{id: 1, name: 'xyz', allowableOperations: ['create', 'update']}],
|
||||
[]
|
||||
);
|
||||
|
||||
let row = dataTable.data.getRows();
|
||||
let actions = [
|
||||
{
|
||||
disableWithNoPermission: false,
|
||||
permission: 'delete',
|
||||
target: 'folder',
|
||||
title: 'action2'
|
||||
}
|
||||
];
|
||||
|
||||
let updateActions = dataTable.checkPermissions(row[0], actions);
|
||||
expect(updateActions[0].disabled).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should not disable the action if there is the right permission', () => {
|
||||
|
||||
dataTable.data = new ObjectDataTableAdapter(
|
||||
[{ id: 1, name: 'xyz', allowableOperations: ['create', 'update', 'delete'] }],
|
||||
[]
|
||||
);
|
||||
|
||||
let row = dataTable.data.getRows();
|
||||
let actions = [
|
||||
{
|
||||
permission: 'delete',
|
||||
target: 'folder',
|
||||
title: 'action2'
|
||||
}
|
||||
];
|
||||
|
||||
let updateActions = dataTable.checkPermissions(row[0], actions);
|
||||
expect(updateActions[0].disabled).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should not disable the action if there are no permissions', () => {
|
||||
|
||||
dataTable.data = new ObjectDataTableAdapter(
|
||||
[{id: 1, name: 'xyz', allowableOperations: null}],
|
||||
[]
|
||||
);
|
||||
|
||||
let row = dataTable.data.getRows();
|
||||
let actions = [
|
||||
{
|
||||
permission: 'delete',
|
||||
target: 'folder',
|
||||
title: 'action2'
|
||||
}
|
||||
];
|
||||
|
||||
let updateActions = dataTable.checkPermissions(row[0], actions);
|
||||
expect(updateActions[0].disabled).toBeUndefined();
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -235,33 +235,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges {
|
||||
getRowActions(row: DataRow, col: DataColumn): any[] {
|
||||
let event = new DataCellEvent(row, col, []);
|
||||
this.showRowActionsMenu.emit(event);
|
||||
|
||||
return this.checkPermissions(row, event.value.actions);
|
||||
}
|
||||
|
||||
checkPermissions(row: DataRow, actions: any[]) {
|
||||
let actionsPermission = [];
|
||||
actions.forEach((action) => {
|
||||
actionsPermission.push(this.checkPermission(row, action));
|
||||
});
|
||||
return actionsPermission;
|
||||
}
|
||||
|
||||
checkPermission(row: DataRow, action) {
|
||||
if (action.permission) {
|
||||
if (this.hasPermissions(row)) {
|
||||
let permissions = row.getValue('allowableOperations');
|
||||
let findPermission = permissions.find(permission => permission === action.permission);
|
||||
if (!findPermission && action.disableWithNoPermission === true) {
|
||||
action.disabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
private hasPermissions(row: DataRow): boolean {
|
||||
return row.getValue('allowableOperations') ? true : false;
|
||||
return event.value.actions;
|
||||
}
|
||||
|
||||
onExecuteRowAction(row: DataRow, action: any) {
|
||||
|
Reference in New Issue
Block a user