edit node permission (#261)

This commit is contained in:
Cilibiu Bogdan
2018-03-27 11:49:49 +03:00
committed by suzanadirla
parent 56ddeb8c40
commit ded29aee4d
6 changed files with 64 additions and 0 deletions

View File

@@ -181,7 +181,12 @@
<adf-info-drawer title="Details"> <adf-info-drawer title="Details">
<adf-info-drawer-tab label="Properties"> <adf-info-drawer-tab label="Properties">
<div *ngIf="infoInstance.loading">
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
</div>
<adf-content-metadata-card <adf-content-metadata-card
[readOnly]="!canUpdate(documentList.selection)"
[displayEmpty]="true" [displayEmpty]="true"
[preset]="'custom'" [preset]="'custom'"
[node]="infoInstance.node"> [node]="infoInstance.node">

View File

@@ -188,7 +188,12 @@
<adf-info-drawer title="Details"> <adf-info-drawer title="Details">
<adf-info-drawer-tab label="Properties"> <adf-info-drawer-tab label="Properties">
<div *ngIf="infoInstance.loading">
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
</div>
<adf-content-metadata-card <adf-content-metadata-card
[readOnly]="!canUpdate(documentList.selection)"
[displayEmpty]="true" [displayEmpty]="true"
[preset]="'custom'" [preset]="'custom'"
[node]="infoInstance.node"> [node]="infoInstance.node">

View File

@@ -346,4 +346,40 @@ describe('PageComponent', () => {
expect(component.canMoveShared(selection)).toBe(false); expect(component.canMoveShared(selection)).toBe(false);
}); });
}); });
describe('canUpdate()', () => {
it('should return true if node can be edited', () => {
const selection = [ { entry: {
allowableOperations: ['update']
} } ];
expect(component.canUpdate(selection)).toBe(true);
});
it(`should return false if node cannot be edited`, () => {
const selection = [ { entry: {
allowableOperations: ['other-permission']
} } ];
expect(component.canUpdate(selection)).toBe(false);
});
});
describe('canUpdateShared()', () => {
it('should return true if shared node can be edited', () => {
const selection = [ { entry: {
allowableOperationsOnTarget: ['update']
} } ];
expect(component.canUpdateShared(selection)).toBe(true);
});
it(`should return false if shared node cannot be edited`, () => {
const selection = [ { entry: {
allowableOperationsOnTarget: ['other-permission']
} } ];
expect(component.canUpdateShared(selection)).toBe(false);
});
});
}); });

View File

@@ -124,6 +124,14 @@ export abstract class PageComponent {
return selection.every(node => node.entry && this.nodeSharedHasPermission(node.entry, 'delete')); return selection.every(node => node.entry && this.nodeSharedHasPermission(node.entry, 'delete'));
} }
canUpdate(selection: Array<MinimalNodeEntity> = []): boolean {
return selection.every(node => node.entry && this.nodeHasPermission(node.entry, 'update'));
}
canUpdateShared(selection: Array<MinimalNodeEntity> = []): boolean {
return selection.every(node => node.entry && this.nodeSharedHasPermission(node.entry, 'update'));
}
canPreviewFile(selection: Array<MinimalNodeEntity>): boolean { canPreviewFile(selection: Array<MinimalNodeEntity>): boolean {
return this.isFileSelected(selection); return this.isFileSelected(selection);
} }

View File

@@ -170,7 +170,12 @@
<adf-info-drawer title="Details"> <adf-info-drawer title="Details">
<adf-info-drawer-tab label="Properties"> <adf-info-drawer-tab label="Properties">
<div *ngIf="infoInstance.loading">
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
</div>
<adf-content-metadata-card <adf-content-metadata-card
[readOnly]="!canUpdate(documentList.selection)"
[displayEmpty]="true" [displayEmpty]="true"
[preset]="'custom'" [preset]="'custom'"
[node]="infoInstance.node"> [node]="infoInstance.node">

View File

@@ -187,7 +187,12 @@
<adf-info-drawer title="Details"> <adf-info-drawer title="Details">
<adf-info-drawer-tab label="Properties"> <adf-info-drawer-tab label="Properties">
<div *ngIf="infoInstance.loading">
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
</div>
<adf-content-metadata-card <adf-content-metadata-card
[readOnly]="!canUpdateShared(documentList.selection)"
[displayEmpty]="true" [displayEmpty]="true"
[preset]="'custom'" [preset]="'custom'"
[node]="infoInstance.node"> [node]="infoInstance.node">