mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
style permissions fix and add in hasPermission possibility to check t… (#2113)
* style permissions fix and add in hasPermission possibility to check the negate permission * remove fdescribe in discovery test and add test for negate permissions
This commit is contained in:
parent
03f60d910f
commit
d573f32640
@ -24,6 +24,14 @@ adf-document-list >>> adf-datatable tr.is-selected .image-table-cell {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
adf-document-list >>> adf-datatable tr.document-list__create {
|
||||
background: green !important;
|
||||
}
|
||||
|
||||
adf-document-list >>> adf-datatable tr.document-list__disable {
|
||||
background: red !important;
|
||||
}
|
||||
|
||||
adf-document-list >>> adf-datatable tr.is-selected .image-table-cell::before {
|
||||
content: "\E876"; /* "done" */
|
||||
font-family: "Material Icons";
|
||||
@ -45,7 +53,8 @@ adf-document-list >>> adf-datatable tr.is-selected .image-table-cell::before {
|
||||
.adf-demo-site-container-style {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
margin-left: 3%;
|
||||
width: 100%;
|
||||
min-width: 200px;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
<div class="container">
|
||||
<div class="adf-demo-site-container-style" id="demo-container">
|
||||
<span> Choose A Site from DropDown </span>
|
||||
<p></p>
|
||||
<adf-sites-dropdown (change)="getSiteContent($event)">
|
||||
</adf-sites-dropdown>
|
||||
</div>
|
||||
|
@ -18,7 +18,7 @@
|
||||
import { ChangeDetectorRef, Component, Input, OnInit, Optional, ViewChild } from '@angular/core';
|
||||
import { MdDialog } from '@angular/material';
|
||||
import { ActivatedRoute, Params } from '@angular/router';
|
||||
import { AlfrescoContentService, FileUploadCompleteEvent, FolderCreatedEvent, NotificationService, SiteModel, UploadService } from 'ng2-alfresco-core';
|
||||
import { AlfrescoContentService, FileUploadCompleteEvent, FolderCreatedEvent, NotificationService, PermissionsEnum, SiteModel, UploadService } from 'ng2-alfresco-core';
|
||||
import { DocumentListComponent, DropdownSitesComponent, PermissionStyleModel } from 'ng2-alfresco-documentlist';
|
||||
|
||||
import { CreateFolderDialogComponent } from '../../dialogs/create-folder.dialog';
|
||||
@ -40,7 +40,7 @@ export class FilesComponent implements OnInit {
|
||||
|
||||
useCustomToolbar = true;
|
||||
toolbarColor = 'default';
|
||||
useDropdownBreadcrumb = true;
|
||||
useDropdownBreadcrumb = false;
|
||||
|
||||
selectionModes = [
|
||||
{ value: 'none', viewValue: 'None' },
|
||||
@ -115,6 +115,9 @@ export class FilesComponent implements OnInit {
|
||||
|
||||
this.uploadService.fileUploadComplete.debounceTime(300).subscribe(value => this.onFileUploadComplete(value));
|
||||
this.contentService.folderCreated.subscribe(value => this.onFolderCreated(value));
|
||||
|
||||
// this.permissionsStyle.push(new PermissionStyleModel('document-list__create', PermissionsEnum.CREATE));
|
||||
// this.permissionsStyle.push(new PermissionStyleModel('document-list__disable', PermissionsEnum.NOT_CREATE, false, true));
|
||||
}
|
||||
|
||||
onNavigationError(err: any) {
|
||||
|
@ -111,19 +111,29 @@ describe('AlfrescoContentService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should havePermission should be false if allowableOperation is not present in the node', () => {
|
||||
it('should havePermission be false if allowableOperation is not present in the node', () => {
|
||||
let permissionNode = {};
|
||||
expect(contentService.hasPermission(permissionNode, 'create')).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should havePermission should be true if allowableOperation is present and you have the permission for the request operation', () => {
|
||||
it('should havePermission be true if allowableOperation is present and you have the permission for the request operation', () => {
|
||||
let permissionNode = {allowableOperations: ['delete', 'update', 'create', 'updatePermissions']};
|
||||
|
||||
expect(contentService.hasPermission(permissionNode, 'create')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should havePermission should be false if allowableOperation is present but you don\'t have the permission for the request operation', () => {
|
||||
it('should havePermission be false if allowableOperation is present but you don\'t have the permission for the request operation', () => {
|
||||
let permissionNode = {allowableOperations: ['delete', 'update', 'updatePermissions']};
|
||||
expect(contentService.hasPermission(permissionNode, 'create')).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should havePermission works in the opposite way with negate value', () => {
|
||||
let permissionNode = {allowableOperations: ['delete', 'update', 'updatePermissions']};
|
||||
expect(contentService.hasPermission(permissionNode, '!create')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should havePermission return false id no permission parameter are passed', () => {
|
||||
let permissionNode = {allowableOperations: ['delete', 'update', 'updatePermissions']};
|
||||
expect(contentService.hasPermission(permissionNode, null)).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
@ -90,7 +90,7 @@ let fakeBPMDiscoveryResponse: any = {
|
||||
'minorVersion': '6'
|
||||
};
|
||||
|
||||
fdescribe('Discovery Api Service', () => {
|
||||
describe('Discovery Api Service', () => {
|
||||
|
||||
let service;
|
||||
|
||||
|
@ -1060,6 +1060,7 @@ The permissionsStyle array can define different styles depending from the permi
|
||||
[PermissionStyleModel](https://github.com/Alfresco/alfresco-ng2-components/blob/master/ng2-components/ng2-alfresco-documentlist/src/models/permissions-style.model.ts)
|
||||
|
||||
| Property | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| isFile/isFolder | allow you to select if you want apply the style to file/folder nodes |
|
||||
| permission | is an enum value [Permissions](https://github.com/Alfresco/alfresco-ng2-core/blob/master/ng2-components/ng2-alfresco-documentlist/src/models/permissions.enum.ts) |
|
||||
| css| the name of the class to add |
|
||||
@ -1080,9 +1081,8 @@ this.permissionsStyle.push(new PermissionStyleModel('document-list__create', Per
|
||||
```
|
||||
|
||||
```css
|
||||
|
||||
adf-document-list >>> adf-datatable >>> tr.alfresco-datatable__row.document-list__create {
|
||||
color: rgb(57, 239, 121);
|
||||
adf-document-list >>> adf-datatable tr.document-list__create {
|
||||
background: green !important;
|
||||
}
|
||||
```
|
||||
|
||||
@ -1102,10 +1102,8 @@ this.permissionsStyle.push(new PermissionStyleModel('document-list__disable', Pe
|
||||
```
|
||||
|
||||
```css
|
||||
|
||||
adf-document-list >>> adf-datatable >>> tr.alfresco-datatable__row.document-list__disable {
|
||||
color: rgba(0, 0, 0, 0.28);
|
||||
|
||||
adf-document-list >>> adf-datatable tr.document-list__disable {
|
||||
background: red !important;
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -59,6 +59,7 @@ export * from './src/models/content-action.model';
|
||||
export * from './src/models/document-library.model';
|
||||
export * from './src/models/permissions.model';
|
||||
export * from './src/models/permissions-style.model';
|
||||
export * from './src/models/permissions-style.model';
|
||||
|
||||
export const DOCUMENT_LIST_DIRECTIVES: any[] = [
|
||||
DocumentListComponent,
|
||||
|
@ -256,9 +256,7 @@ export class ShareDataRow implements DataRow {
|
||||
|
||||
if (this.applyPermissionStyleToFolder(nodeEntity.entry, currentPermissionsStyle) || this.applyPermissionStyleToFile(nodeEntity.entry, currentPermissionsStyle)) {
|
||||
|
||||
if (currentPermissionsStyle.permission.startsWith('!') && !this.documentListService.hasPermission(nodeEntity.entry, currentPermissionsStyle.permission)) {
|
||||
permissionsClasses += ` ${currentPermissionsStyle.css}`;
|
||||
} else if (this.documentListService.hasPermission(nodeEntity.entry, currentPermissionsStyle.permission)) {
|
||||
if (this.documentListService.hasPermission(nodeEntity.entry, currentPermissionsStyle.permission)) {
|
||||
permissionsClasses += ` ${currentPermissionsStyle.css}`;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user