[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
This commit is contained in:
Vito
2017-09-04 08:37:37 -07:00
committed by Mario Romano
parent 62e50e8fbf
commit 4e50c4e2d6
6 changed files with 23 additions and 23 deletions

View File

@@ -268,10 +268,10 @@
</md-input-container> </md-input-container>
</section> </section>
<div *ngIf="!acceptedFilesTypeShow"> <div *ngIf="!acceptedFilesTypeShow">
<adf-upload-button <alfresco-upload-button
#uploadButton #uploadButton
tooltip="Custom tooltip" tooltip="Custom tooltip"
[disable]="!enableUpload" [disabled]="!enableUpload"
data-automation-id="multiple-file-upload" data-automation-id="multiple-file-upload"
[rootFolderId]="documentList.currentFolderId" [rootFolderId]="documentList.currentFolderId"
[multipleFiles]="multipleFileUpload" [multipleFiles]="multipleFileUpload"
@@ -280,13 +280,13 @@
[adf-node-permission]="'create'" [adf-node-permission]="'create'"
[adf-nodes]="getCurrentDocumentListNode()" [adf-nodes]="getCurrentDocumentListNode()"
(permissionEvent)="handlePermissionError($event)"> (permissionEvent)="handlePermissionError($event)">
</adf-upload-button> </alfresco-upload-button>
</div> </div>
<div *ngIf="acceptedFilesTypeShow"> <div *ngIf="acceptedFilesTypeShow">
<alfresco-upload-button <alfresco-upload-button
#uploadButton #uploadButton
tooltip="Custom tooltip" tooltip="Custom tooltip"
[disable]="!enableUpload" [disabled]="!enableUpload"
data-automation-id="multiple-file-upload" data-automation-id="multiple-file-upload"
[rootFolderId]="documentList.currentFolderId" [rootFolderId]="documentList.currentFolderId"
[acceptedFilesType]="acceptedFilesType" [acceptedFilesType]="acceptedFilesType"
@@ -299,7 +299,7 @@
</alfresco-upload-button> </alfresco-upload-button>
</div> </div>
<section> <section>
<md-checkbox [(ngModel)]="enableUpload">Enable upload (demoing enabled/disabled state)</md-checkbox> <md-checkbox [(ngModel)]="enableUpload">Enable upload (demoing enabled/disabled state only if the permission are not checked dynamically)</md-checkbox>
</section> </section>
</div> </div>

View File

@@ -23,7 +23,7 @@ import { NodePermissionDirective, NodePermissionSubject } from './node-permissio
selector: 'adf-text-subject' selector: 'adf-text-subject'
}) })
class TestComponent implements NodePermissionSubject { class TestComponent implements NodePermissionSubject {
disable: boolean = false; disabled: boolean = false;
} }
describe('NodePermissionDirective', () => { describe('NodePermissionDirective', () => {
@@ -126,13 +126,13 @@ describe('NodePermissionDirective', () => {
spyOn(contentService, 'hasPermission').and.returnValue(false); spyOn(contentService, 'hasPermission').and.returnValue(false);
let testComponent = new TestComponent(); let testComponent = new TestComponent();
testComponent.disable = false; testComponent.disabled = false;
const directive = new NodePermissionDirective(null, null, contentService, testComponent); const directive = new NodePermissionDirective(null, null, contentService, testComponent);
directive.nodes = <any> [{}, {}]; directive.nodes = <any> [{}, {}];
directive.updateElement(); directive.updateElement();
expect(testComponent.disable).toBeTruthy(); expect(testComponent.disabled).toBeTruthy();
}); });
it('enables decorated component', () => { it('enables decorated component', () => {
@@ -140,13 +140,13 @@ describe('NodePermissionDirective', () => {
spyOn(contentService, 'hasPermission').and.returnValue(true); spyOn(contentService, 'hasPermission').and.returnValue(true);
let testComponent = new TestComponent(); let testComponent = new TestComponent();
testComponent.disable = true; testComponent.disabled = true;
const directive = new NodePermissionDirective(null, null, contentService, testComponent); const directive = new NodePermissionDirective(null, null, contentService, testComponent);
directive.nodes = <any> [{}, {}]; directive.nodes = <any> [{}, {}];
directive.updateElement(); directive.updateElement();
expect(testComponent.disable).toBeFalsy(); expect(testComponent.disabled).toBeFalsy();
}); });
}); });
}); });

View File

@@ -21,7 +21,7 @@ import { EXTENDIBLE_COMPONENT } from './../interface/injection.tokens';
import { AlfrescoContentService } from './../services/alfresco-content.service'; import { AlfrescoContentService } from './../services/alfresco-content.service';
export interface NodePermissionSubject { export interface NodePermissionSubject {
disable: boolean; disabled: boolean;
} }
@Directive({ @Directive({
@@ -74,7 +74,7 @@ export class NodePermissionDirective implements OnChanges, AfterViewInit {
private enable(): void { private enable(): void {
if (this.parentComponent) { if (this.parentComponent) {
this.parentComponent.disable = false; this.parentComponent.disabled = false;
} else { } else {
this.enableElement(); this.enableElement();
} }
@@ -82,7 +82,7 @@ export class NodePermissionDirective implements OnChanges, AfterViewInit {
private disable(): void { private disable(): void {
if (this.parentComponent) { if (this.parentComponent) {
this.parentComponent.disable = true; this.parentComponent.disabled = true;
} else { } else {
this.disableElement(); this.disableElement();
} }

View File

@@ -58,7 +58,7 @@ Contains components for handling uploads to Content Services.
| Name | Type | Default | Description | | 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.** | | **(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) | | uploadFolders | boolean | false | Allow/disallow upload folders (only for Chrome) |
| multipleFiles | boolean | false | Allow/disallow multiple files | | multipleFiles | boolean | false | Allow/disallow multiple files |

View File

@@ -55,7 +55,7 @@ export class UploadButtonComponent implements OnInit, OnChanges, NodePermissionS
disableWithNoPermission: boolean = false; disableWithNoPermission: boolean = false;
@Input() @Input()
disable: boolean = false; disabled: boolean = false;
@Input() @Input()
uploadFolders: boolean = false; uploadFolders: boolean = false;
@@ -119,7 +119,7 @@ export class UploadButtonComponent implements OnInit, OnChanges, NodePermissionS
} }
isForceDisable(): boolean { 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 */ /** @deprecated Deprecated in 1.8.0, use the button with combination of adf-node-permission directive */

View File

@@ -42,13 +42,13 @@ export class UploadDragAreaComponent implements NodePermissionSubject {
@Input() @Input()
set enabled(enabled: boolean) { set enabled(enabled: boolean) {
console.warn('Deprecated: enabled input property should not be used for UploadDragAreaComponent. Please use disabled instead.'); 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 */ /** @deprecated Deprecated in favor of disabled input property */
get enabled(): boolean { get enabled(): boolean {
console.warn('Deprecated: enabled input property should not be used for UploadDragAreaComponent. Please use disabled instead.'); 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. */ /** @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-'; rootFolderId: string = '-root-';
@Input() @Input()
disable: boolean = false; disabled: boolean = false;
@Input() @Input()
versioning: boolean = false; versioning: boolean = false;
@@ -86,7 +86,7 @@ export class UploadDragAreaComponent implements NodePermissionSubject {
* @param {File[]} files - files dropped in the drag area. * @param {File[]} files - files dropped in the drag area.
*/ */
onFilesDropped(files: File[]): void { onFilesDropped(files: File[]): void {
if (!this.disable && files.length) { if (!this.disabled && files.length) {
const fileModels = files.map(file => new FileModel(file, { const fileModels = files.map(file => new FileModel(file, {
newVersion: this.versioning, newVersion: this.versioning,
path: '/', path: '/',
@@ -107,7 +107,7 @@ export class UploadDragAreaComponent implements NodePermissionSubject {
* @param item - FileEntity * @param item - FileEntity
*/ */
onFilesEntityDropped(item: any): void { onFilesEntityDropped(item: any): void {
if (!this.disable) { if (!this.disabled) {
item.file((file: File) => { item.file((file: File) => {
const fileModel = new FileModel(file, { const fileModel = new FileModel(file, {
newVersion: this.versioning, newVersion: this.versioning,
@@ -129,7 +129,7 @@ export class UploadDragAreaComponent implements NodePermissionSubject {
* @param folder - name of the dropped folder * @param folder - name of the dropped folder
*/ */
onFolderEntityDropped(folder: any): void { onFolderEntityDropped(folder: any): void {
if (!this.disable && folder.isDirectory) { if (!this.disabled && folder.isDirectory) {
FileUtils.flattern(folder).then(entries => { FileUtils.flattern(folder).then(entries => {
let files = entries.map(entry => { let files = entries.map(entry => {
return new FileModel(entry.file, { 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 */ /** Returns true or false considering the component options and node permissions */
isDroppable(): boolean { isDroppable(): boolean {
return !this.disable; return !this.disabled;
} }
/** /**