From 95711616ca9795622a1a0f064c1b06ab9d5894e0 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Fri, 21 Apr 2017 15:55:45 +0100 Subject: [PATCH] upload button enhancements (#1835) - add support for [disabled] attribute - move to angular/material icons - improve demo shell layout (files.component) --- .../app/components/files/files.component.css | 5 - .../app/components/files/files.component.html | 116 ++++++++---------- .../app/components/files/files.component.ts | 37 +++--- .../components/upload-button.component.html | 14 +-- .../src/components/upload-button.component.ts | 8 +- 5 files changed, 83 insertions(+), 97 deletions(-) diff --git a/demo-shell-ng2/app/components/files/files.component.css b/demo-shell-ng2/app/components/files/files.component.css index ce96c9eff8..cb4cb685aa 100644 --- a/demo-shell-ng2/app/components/files/files.component.css +++ b/demo-shell-ng2/app/components/files/files.component.css @@ -15,8 +15,3 @@ .error-message--text { color: #d50000; } - -.options-container { - width: 250px; - margin: 20px; -} diff --git a/demo-shell-ng2/app/components/files/files.component.html b/demo-shell-ng2/app/components/files/files.component.html index 62feaab3c0..7d8ac80977 100644 --- a/demo-shell-ng2/app/components/files/files.component.html +++ b/demo-shell-ng2/app/components/files/files.component.html @@ -121,75 +121,65 @@ -

- -

+
+
+ Multiple File Upload +
+
+ Folder upload +
-

- -

+
+ Custom extensions filter +
-

- -

+
+ Enable versioning +
-

- -

+
+ Disable when user has no permissions +
-

- -

- -
Upload
-
-
- -
-
-
- -
-
-
-
- -
-
+
Upload
+
+ + + +
+
+ + +
+
+ + +
+
+ Enable upload (demoing enabled/disabled state) +
+
diff --git a/demo-shell-ng2/app/components/files/files.component.ts b/demo-shell-ng2/app/components/files/files.component.ts index c2a9c034e4..639e089cd8 100644 --- a/demo-shell-ng2/app/components/files/files.component.ts +++ b/demo-shell-ng2/app/components/files/files.component.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { Component, OnInit, AfterViewInit, Optional, ViewChild, ChangeDetectorRef } from '@angular/core'; +import { Component, Input, OnInit, AfterViewInit, Optional, ViewChild, ChangeDetectorRef } from '@angular/core'; import { ActivatedRoute, Params, Router } from '@angular/router'; import { AlfrescoAuthenticationService, LogService, NotificationService } from 'ng2-alfresco-core'; import { DocumentActionsService, DocumentListComponent, ContentActionHandler, DocumentActionModel, FolderActionModel } from 'ng2-alfresco-documentlist'; @@ -34,13 +34,28 @@ export class FilesComponent implements OnInit, AfterViewInit { errorMessage: string = null; fileNodeId: any; fileShowed: boolean = false; + + @Input() multipleFileUpload: boolean = false; + + @Input() disableWithNoPermission: boolean = false; + + @Input() folderUpload: boolean = false; + + @Input() acceptedFilesTypeShow: boolean = false; + + @Input() versioning: boolean = false; + + @Input() acceptedFilesType: string = '.jpg,.pdf,.js'; + @Input() + enableUpload: boolean = true; + @ViewChild(DocumentListComponent) documentList: DocumentListComponent; @@ -82,32 +97,12 @@ export class FilesComponent implements OnInit, AfterViewInit { } } - toggleMultipleFileUpload() { - this.multipleFileUpload = !this.multipleFileUpload; - return this.multipleFileUpload; - } - - toggleDisableWithNoPermission() { - this.disableWithNoPermission = !this.disableWithNoPermission; - return this.disableWithNoPermission; - } - toggleFolder() { this.multipleFileUpload = false; this.folderUpload = !this.folderUpload; return this.folderUpload; } - toggleAcceptedFilesType() { - this.acceptedFilesTypeShow = !this.acceptedFilesTypeShow; - return this.acceptedFilesTypeShow; - } - - toggleVersioning() { - this.versioning = !this.versioning; - return this.versioning; - } - ngOnInit() { if (this.route) { this.route.params.forEach((params: Params) => { 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 c93621f5b1..78f28aaa24 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,7 +1,7 @@
-
- file_upload +
+ file_upload @@ -11,7 +11,7 @@ (change)="onFilesAdded($event)" multiple="multiple" accept="{{acceptedFilesType}}" - [attr.disabled]="disableButton" + [attr.disabled]="isDisabled()" #uploadFiles> @@ -22,21 +22,21 @@
-
- file_upload +
+ file_upload
diff --git a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts index 4bfdef9a2c..e2c34807af 100644 --- a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts +++ b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts @@ -56,6 +56,9 @@ export class UploadButtonComponent implements OnInit, OnChanges { private static DEFAULT_ROOT_ID: string = '-root-'; + @Input() + disabled: boolean = false; + @Input() showNotificationBar: boolean = true; @@ -96,7 +99,6 @@ export class UploadButtonComponent implements OnInit, OnChanges { permissionEvent: EventEmitter = new EventEmitter(); private disableButton: boolean = false; - private permissionValue: Subject = new Subject(); constructor(private el: ElementRef, @@ -109,6 +111,10 @@ export class UploadButtonComponent implements OnInit, OnChanges { } } + isDisabled(): boolean { + return this.disabled || this.disableButton; + } + ngOnInit() { this.permissionValue.subscribe((hasPermission: boolean) => { if (!hasPermission && this.disableWithNoPermission) {