@@ -175,7 +184,9 @@
[acceptedFilesType]="acceptedFilesType"
[multipleFiles]="multipleFileUpload"
[uploadFolders]="folderUpload"
- [versioning] = "versioning">
+ [versioning] = "versioning"
+ [disableWithNoPermission]="disableWithNoPermission"
+ (permissionEvent)="onUploadPermissionFailed($event)">
diff --git a/demo-shell-ng2/app/components/files/files.component.ts b/demo-shell-ng2/app/components/files/files.component.ts
index 1f1f4eeeb7..c2a9c034e4 100644
--- a/demo-shell-ng2/app/components/files/files.component.ts
+++ b/demo-shell-ng2/app/components/files/files.component.ts
@@ -35,6 +35,7 @@ export class FilesComponent implements OnInit, AfterViewInit {
fileNodeId: any;
fileShowed: boolean = false;
multipleFileUpload: boolean = false;
+ disableWithNoPermission: boolean = false;
folderUpload: boolean = false;
acceptedFilesTypeShow: boolean = false;
versioning: boolean = false;
@@ -86,6 +87,11 @@ export class FilesComponent implements OnInit, AfterViewInit {
return this.multipleFileUpload;
}
+ toggleDisableWithNoPermission() {
+ this.disableWithNoPermission = !this.disableWithNoPermission;
+ return this.disableWithNoPermission;
+ }
+
toggleFolder() {
this.multipleFileUpload = false;
this.folderUpload = !this.folderUpload;
@@ -173,6 +179,10 @@ export class FilesComponent implements OnInit, AfterViewInit {
this.notificationService.openSnackMessage(`you don't have the ${event.permission} permission to ${event.action} the ${event.type} `, 4000);
}
+ onUploadPermissionFailed(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-upload/README.md b/ng2-components/ng2-alfresco-upload/README.md
index 932c74d67d..589667e2ad 100644
--- a/ng2-components/ng2-alfresco-upload/README.md
+++ b/ng2-components/ng2-alfresco-upload/README.md
@@ -178,6 +178,43 @@ Attribute | Options | Default | Description | Mandatory
`currentFolderPath` | *string* | '/Sites/swsdp/documentLibrary' | define the path where the files are uploaded |
`versioning` | *boolean* | false | Versioning false is the default uploader behaviour and it rename using an integer suffix if there is a name clash. Versioning true to indicate that a major version should be created |
`staticTitle` | *string* | 'FILE_UPLOAD.BUTTON.UPLOAD_FILE' or 'FILE_UPLOAD.BUTTON.UPLOAD_FOLDER' string in the JSON text file | define the text of the upload button|
+`disableWithNoPermission` | *boolean* | false | If the value is true and the user doesn't have the permission to delete the node the button will be disabled |
+
+### How to show notification message with no permission
+You can show a notification error when the user doesn't have the right permission to perform the action.
+The UploadButtonComponent provides the event permissionEvent that is raised when the delete permission is missing
+You can subscribe to this event from your component and use the NotificationService to show a message.
+
+```html
+
+
+
+export class MyComponent {
+
+onUploadPermissionFailed(event: any) {
+ this.notificationService.openSnackMessage(`you don't have the ${event.permission} permission to ${event.action} the ${event.type} `, 4000);
+}
+
+}
+```
+
+
+
+#### How to disable the button when the delete permission is missing
+You can easily disable the button when the user doesn't own the permission to perform the action.
+The UploadButtonComponent provides the property disableWithNoPermission that can be true. In this way the button should be disabled if the delete permission is missing for the node.
+
+```html
+
+
+```
+
+
+
### Drag and drop
diff --git a/ng2-components/ng2-alfresco-upload/docs/assets/upload-disable-button.png b/ng2-components/ng2-alfresco-upload/docs/assets/upload-disable-button.png
new file mode 100644
index 0000000000..344e330228
Binary files /dev/null and b/ng2-components/ng2-alfresco-upload/docs/assets/upload-disable-button.png differ
diff --git a/ng2-components/ng2-alfresco-upload/docs/assets/upload-notification-message.png b/ng2-components/ng2-alfresco-upload/docs/assets/upload-notification-message.png
new file mode 100644
index 0000000000..762f3fab0f
Binary files /dev/null and b/ng2-components/ng2-alfresco-upload/docs/assets/upload-notification-message.png differ
diff --git a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.css b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.css
index 37396e1d5a..7358dca90a 100644
--- a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.css
+++ b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.css
@@ -9,6 +9,27 @@
z-index: 4;
}
+
+.mdl-button--file--disabled {
+ background: rgba(0,0,0,.12);
+ color: rgba(0,0,0,.26);
+}
+
+.mdl-button--file--disabled:hover {
+ background: rgba(0,0,0,.12);
+ color: rgba(0,0,0,.26);
+}
+
+.mdl-button--file--disabled:focus:not(:active) {
+ box-shadow: 0 0 8px rgba(0,0,0,.18), 0 8px 16px rgba(0,0,0,.36);
+ background-color: rgba(158,158,158,.4);
+}
+
+.mdl-button--file--disabled input[type="file"]:disabled {
+ cursor: default;
+ background-color: transparent;
+}
+
.mdl-textfield--file .mdl-textfield__input {
box-sizing: border-box;
width: calc(100% - 32px);
diff --git a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.html b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.html
index 6ead8b50a4..c93621f5b1 100644
--- a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.html
+++ b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.html
@@ -1,6 +1,6 @@