From 4e50c4e2d6661fe368a75c8880bdebc2324c3e84 Mon Sep 17 00:00:00 2001 From: Vito Date: Mon, 4 Sep 2017 08:37:37 -0700 Subject: [PATCH] [ADF-1458] revert changes applied for upload button (#2286) * [ADF-1458] reverting changes from ADF-1458 * [ADF-1458] reapply default value to disabled * [ADF-1458] revert changes on README * [ADF-1458] update readme added more check for node permission checking * [ADF-1458] reverting changes to tests * [ADF-1458] revert changes for test directive --- .../app/components/files/files.component.html | 10 +++++----- .../directives/node-permission.directive.spec.ts | 10 +++++----- .../src/directives/node-permission.directive.ts | 6 +++--- ng2-components/ng2-alfresco-upload/README.md | 2 +- .../src/components/upload-button.component.ts | 4 ++-- .../src/components/upload-drag-area.component.ts | 14 +++++++------- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/demo-shell-ng2/app/components/files/files.component.html b/demo-shell-ng2/app/components/files/files.component.html index 64aa3c06e1..3f4ba40def 100644 --- a/demo-shell-ng2/app/components/files/files.component.html +++ b/demo-shell-ng2/app/components/files/files.component.html @@ -268,10 +268,10 @@
- - +
- Enable upload (demoing enabled/disabled state) + Enable upload (demoing enabled/disabled state only if the permission are not checked dynamically)
diff --git a/ng2-components/ng2-alfresco-core/src/directives/node-permission.directive.spec.ts b/ng2-components/ng2-alfresco-core/src/directives/node-permission.directive.spec.ts index 0ec0b88340..d7cd557923 100644 --- a/ng2-components/ng2-alfresco-core/src/directives/node-permission.directive.spec.ts +++ b/ng2-components/ng2-alfresco-core/src/directives/node-permission.directive.spec.ts @@ -23,7 +23,7 @@ import { NodePermissionDirective, NodePermissionSubject } from './node-permissio selector: 'adf-text-subject' }) class TestComponent implements NodePermissionSubject { - disable: boolean = false; + disabled: boolean = false; } describe('NodePermissionDirective', () => { @@ -126,13 +126,13 @@ describe('NodePermissionDirective', () => { spyOn(contentService, 'hasPermission').and.returnValue(false); let testComponent = new TestComponent(); - testComponent.disable = false; + testComponent.disabled = false; const directive = new NodePermissionDirective(null, null, contentService, testComponent); directive.nodes = [{}, {}]; directive.updateElement(); - expect(testComponent.disable).toBeTruthy(); + expect(testComponent.disabled).toBeTruthy(); }); it('enables decorated component', () => { @@ -140,13 +140,13 @@ describe('NodePermissionDirective', () => { spyOn(contentService, 'hasPermission').and.returnValue(true); let testComponent = new TestComponent(); - testComponent.disable = true; + testComponent.disabled = true; const directive = new NodePermissionDirective(null, null, contentService, testComponent); directive.nodes = [{}, {}]; directive.updateElement(); - expect(testComponent.disable).toBeFalsy(); + expect(testComponent.disabled).toBeFalsy(); }); }); }); diff --git a/ng2-components/ng2-alfresco-core/src/directives/node-permission.directive.ts b/ng2-components/ng2-alfresco-core/src/directives/node-permission.directive.ts index 107992e7bd..f707b6a2fa 100644 --- a/ng2-components/ng2-alfresco-core/src/directives/node-permission.directive.ts +++ b/ng2-components/ng2-alfresco-core/src/directives/node-permission.directive.ts @@ -21,7 +21,7 @@ import { EXTENDIBLE_COMPONENT } from './../interface/injection.tokens'; import { AlfrescoContentService } from './../services/alfresco-content.service'; export interface NodePermissionSubject { - disable: boolean; + disabled: boolean; } @Directive({ @@ -74,7 +74,7 @@ export class NodePermissionDirective implements OnChanges, AfterViewInit { private enable(): void { if (this.parentComponent) { - this.parentComponent.disable = false; + this.parentComponent.disabled = false; } else { this.enableElement(); } @@ -82,7 +82,7 @@ export class NodePermissionDirective implements OnChanges, AfterViewInit { private disable(): void { if (this.parentComponent) { - this.parentComponent.disable = true; + this.parentComponent.disabled = true; } else { this.disableElement(); } diff --git a/ng2-components/ng2-alfresco-upload/README.md b/ng2-components/ng2-alfresco-upload/README.md index 8a77837537..165b65455c 100644 --- a/ng2-components/ng2-alfresco-upload/README.md +++ b/ng2-components/ng2-alfresco-upload/README.md @@ -58,7 +58,7 @@ Contains components for handling uploads to Content Services. | Name | Type | Default | Description | | --- | --- | --- | --- | -| disable | boolean | false | Toggle component disabled state | +| disabled | boolean | false | Toggle component disabled state if there is no node permission checking | | **(deprecated)** showNotificationBar | boolean | true | Hide/show notification bar. **Deprecated in 1.6.0: use UploadService events and NotificationService api instead.** | | uploadFolders | boolean | false | Allow/disallow upload folders (only for Chrome) | | multipleFiles | boolean | false | Allow/disallow multiple files | 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 65fb6a594a..18e1baaa12 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 @@ -55,7 +55,7 @@ export class UploadButtonComponent implements OnInit, OnChanges, NodePermissionS disableWithNoPermission: boolean = false; @Input() - disable: boolean = false; + disabled: boolean = false; @Input() uploadFolders: boolean = false; @@ -119,7 +119,7 @@ export class UploadButtonComponent implements OnInit, OnChanges, NodePermissionS } isForceDisable(): boolean { - return this.disable ? true : undefined; + return this.disabled ? true : undefined; } /** @deprecated Deprecated in 1.8.0, use the button with combination of adf-node-permission directive */ diff --git a/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.ts b/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.ts index b8534daa10..d8b9a58fa8 100644 --- a/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.ts +++ b/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.ts @@ -42,13 +42,13 @@ export class UploadDragAreaComponent implements NodePermissionSubject { @Input() set enabled(enabled: boolean) { console.warn('Deprecated: enabled input property should not be used for UploadDragAreaComponent. Please use disabled instead.'); - this.disable = !enabled; + this.disabled = !enabled; } /** @deprecated Deprecated in favor of disabled input property */ get enabled(): boolean { console.warn('Deprecated: enabled input property should not be used for UploadDragAreaComponent. Please use disabled instead.'); - return !this.disable; + return !this.disabled; } /** @deprecated Deprecated in 1.6.0, you can use UploadService events and NotificationService api instead. */ @@ -64,7 +64,7 @@ export class UploadDragAreaComponent implements NodePermissionSubject { rootFolderId: string = '-root-'; @Input() - disable: boolean = false; + disabled: boolean = false; @Input() versioning: boolean = false; @@ -86,7 +86,7 @@ export class UploadDragAreaComponent implements NodePermissionSubject { * @param {File[]} files - files dropped in the drag area. */ onFilesDropped(files: File[]): void { - if (!this.disable && files.length) { + if (!this.disabled && files.length) { const fileModels = files.map(file => new FileModel(file, { newVersion: this.versioning, path: '/', @@ -107,7 +107,7 @@ export class UploadDragAreaComponent implements NodePermissionSubject { * @param item - FileEntity */ onFilesEntityDropped(item: any): void { - if (!this.disable) { + if (!this.disabled) { item.file((file: File) => { const fileModel = new FileModel(file, { newVersion: this.versioning, @@ -129,7 +129,7 @@ export class UploadDragAreaComponent implements NodePermissionSubject { * @param folder - name of the dropped folder */ onFolderEntityDropped(folder: any): void { - if (!this.disable && folder.isDirectory) { + if (!this.disabled && folder.isDirectory) { FileUtils.flattern(folder).then(entries => { let files = entries.map(entry => { return new FileModel(entry.file, { @@ -176,7 +176,7 @@ export class UploadDragAreaComponent implements NodePermissionSubject { /** Returns true or false considering the component options and node permissions */ isDroppable(): boolean { - return !this.disable; + return !this.disabled; } /**