From f6102dfc0783c2bf450c3bcc9c8240a7c8d46d65 Mon Sep 17 00:00:00 2001 From: Maurizio Vitale Date: Tue, 11 Apr 2017 13:43:33 +0100 Subject: [PATCH] DocumentList - Check permissions on delete folder/file (#1808) * Add check permission on delete folder/file * Provide a way to disable the action when if there is no permission * Improve the code using the external permission inside the folder/document action service * Add basic documentation. - How disable the button when the permission is missing - How to show a notification message when the permission is missing * Resize the image * Change the value to true for demo purpose * Update folder-actions.service.ts * Update document-actions.service.ts --- .../app/components/files/files.component.html | 6 ++ .../app/components/files/files.component.ts | 7 +- .../datatable/datatable.component.html | 6 +- .../datatable/datatable.component.spec.ts | 83 ++++++++++++++++++ .../datatable/datatable.component.ts | 34 ++++++- .../ng2-alfresco-documentlist/README.md | 56 +++++++++++- .../content-action-disable-delete-button.png | Bin 0 -> 136132 bytes .../content-action-notification-message.png | Bin 0 -> 177494 bytes .../ng2-alfresco-documentlist/index.ts | 1 + .../content-action.component.ts | 14 +++ .../document-list.component.spec.ts | 17 +++- .../src/components/document-list.component.ts | 2 +- .../src/events/permission-error.event.ts | 28 ++++++ .../src/models/content-action.model.ts | 6 +- .../src/models/permissions.model.ts | 30 +++++++ .../services/document-actions.service.spec.ts | 71 ++++++++++++++- .../src/services/document-actions.service.ts | 34 +++++-- .../src/services/document-list.service.ts | 4 +- .../services/folder-actions.service.spec.ts | 59 ++++++++++++- .../src/services/folder-actions.service.ts | 34 +++++-- 20 files changed, 460 insertions(+), 32 deletions(-) create mode 100644 ng2-components/ng2-alfresco-documentlist/docs/assets/content-action-disable-delete-button.png create mode 100644 ng2-components/ng2-alfresco-documentlist/docs/assets/content-action-notification-message.png create mode 100644 ng2-components/ng2-alfresco-documentlist/src/events/permission-error.event.ts create mode 100644 ng2-components/ng2-alfresco-documentlist/src/models/permissions.model.ts diff --git a/demo-shell-ng2/app/components/files/files.component.html b/demo-shell-ng2/app/components/files/files.component.html index 99789187ea..5df948d19f 100644 --- a/demo-shell-ng2/app/components/files/files.component.html +++ b/demo-shell-ng2/app/components/files/files.component.html @@ -70,7 +70,10 @@ @@ -91,6 +94,9 @@ diff --git a/demo-shell-ng2/app/components/files/files.component.ts b/demo-shell-ng2/app/components/files/files.component.ts index 6dcb2faf85..2fc9bc27af 100644 --- a/demo-shell-ng2/app/components/files/files.component.ts +++ b/demo-shell-ng2/app/components/files/files.component.ts @@ -17,7 +17,7 @@ import { Component, OnInit, AfterViewInit, Optional, ViewChild, ViewChildren, ChangeDetectorRef } from '@angular/core'; import { ActivatedRoute, Params, Router } from '@angular/router'; -import { AlfrescoAuthenticationService, LogService } from 'ng2-alfresco-core'; +import { AlfrescoAuthenticationService, LogService, NotificationService } from 'ng2-alfresco-core'; import { DocumentActionsService, DocumentListComponent, ContentActionHandler, DocumentActionModel, FolderActionModel } from 'ng2-alfresco-documentlist'; import { FormService } from 'ng2-activiti-form'; import { UploadButtonComponent, UploadDragAreaComponent } from 'ng2-alfresco-upload'; @@ -55,6 +55,7 @@ export class FilesComponent implements OnInit, AfterViewInit { private logService: LogService, private changeDetector: ChangeDetectorRef, private router: Router, + private notificationService: NotificationService, @Optional() private route: ActivatedRoute) { documentActions.setHandler('my-handler', this.myDocumentActionHandler.bind(this)); } @@ -168,6 +169,10 @@ export class FilesComponent implements OnInit, AfterViewInit { }.bind(this); } + onPermissionsFailed(event: any) { + this.notificationService.openSnackMessage(`you don't have the ${event.permission} permission to ${event.action} the ${event.type} `, 4000); + } + reload(event: any) { if (event && event.value && event.value.entry && event.value.entry.parentId) { if (this.documentList.currentFolderId === event.value.entry.parentId) { diff --git a/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.html b/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.html index d3135b021b..0fe2b29eb0 100644 --- a/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.html +++ b/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.html @@ -34,14 +34,14 @@ [class.alfresco-datatable__row--selected]="selectedRow === row" [adf-upload]="allowDropFiles" [adf-upload-data]="row"> - +