mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[ADF-2163] added test for target action 'all'
This commit is contained in:
@@ -198,7 +198,6 @@
|
||||
<!-- folder actions -->
|
||||
<content-action
|
||||
icon="content_copy"
|
||||
|
||||
title="{{'DOCUMENT_LIST.ACTIONS.FOLDER.COPY' | translate}}"
|
||||
permission="update"
|
||||
[disableWithNoPermission]="true"
|
||||
@@ -206,19 +205,8 @@
|
||||
(success)="onContentActionSuccess($event)"
|
||||
handler="copy">
|
||||
</content-action>
|
||||
<!-- <content-action
|
||||
icon="content_copy"
|
||||
target="document"
|
||||
title="{{'DOCUMENT_LIST.ACTIONS.DOCUMENT.COPY' | translate}}"
|
||||
permission="update"
|
||||
[disableWithNoPermission]="true"
|
||||
(error)="onContentActionError($event)"
|
||||
(success)="onContentActionSuccess($event)"
|
||||
handler="copy">
|
||||
</content-action> -->
|
||||
<content-action
|
||||
icon="redo"
|
||||
target="folder"
|
||||
title="{{'DOCUMENT_LIST.ACTIONS.FOLDER.MOVE' | translate}}"
|
||||
permission="update"
|
||||
[disableWithNoPermission]="true"
|
||||
@@ -228,7 +216,6 @@
|
||||
</content-action>
|
||||
<content-action
|
||||
icon="delete"
|
||||
target="folder"
|
||||
permission="delete"
|
||||
[disableWithNoPermission]="true"
|
||||
title="{{'DOCUMENT_LIST.ACTIONS.FOLDER.DELETE' | translate}}"
|
||||
@@ -237,17 +224,6 @@
|
||||
handler="delete">
|
||||
</content-action>
|
||||
<!-- document actions -->
|
||||
|
||||
<content-action
|
||||
icon="redo"
|
||||
target="document"
|
||||
title="{{'DOCUMENT_LIST.ACTIONS.DOCUMENT.MOVE' | translate}}"
|
||||
permission="update"
|
||||
[disableWithNoPermission]="true"
|
||||
(error)="onContentActionError($event)"
|
||||
(success)="onContentActionSuccess($event)"
|
||||
handler="move">
|
||||
</content-action>
|
||||
<content-action
|
||||
icon="storage"
|
||||
target="document"
|
||||
@@ -260,16 +236,6 @@
|
||||
title="{{'DOCUMENT_LIST.ACTIONS.DOCUMENT.DOWNLOAD' | translate}}"
|
||||
handler="download">
|
||||
</content-action>
|
||||
<content-action
|
||||
icon="delete"
|
||||
target="document"
|
||||
permission="delete"
|
||||
[disableWithNoPermission]="true"
|
||||
(permissionEvent)="handlePermissionError($event)"
|
||||
title="{{'DOCUMENT_LIST.ACTIONS.DOCUMENT.DELETE' | translate}}"
|
||||
(success)="onDeleteActionSuccess($event)"
|
||||
handler="delete">
|
||||
</content-action>
|
||||
<content-action
|
||||
*ngIf="authenticationService.isBpmLoggedIn()"
|
||||
icon="play_arrow"
|
||||
|
||||
+26
-9
@@ -15,8 +15,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*tslint:disable:ban*/
|
||||
|
||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { EventEmitter } from '@angular/core';
|
||||
import { async, TestBed } from '@angular/core/testing';
|
||||
@@ -25,7 +23,6 @@ import { DataTableModule } from '@alfresco/adf-core';
|
||||
import { MaterialModule } from '../../../material.module';
|
||||
|
||||
import { DocumentListService } from '../../services/document-list.service';
|
||||
// import { FileNode } from '../../../mock';
|
||||
import { ContentActionHandler } from './../../models/content-action.model';
|
||||
import { DocumentActionsService } from './../../services/document-actions.service';
|
||||
import { FolderActionsService } from './../../services/folder-actions.service';
|
||||
@@ -34,7 +31,7 @@ import { DocumentListComponent } from './../document-list.component';
|
||||
import { ContentActionListComponent } from './content-action-list.component';
|
||||
import { ContentActionComponent } from './content-action.component';
|
||||
|
||||
fdescribe('ContentAction', () => {
|
||||
describe('ContentAction', () => {
|
||||
|
||||
let documentList: DocumentListComponent;
|
||||
let actionList: ContentActionListComponent;
|
||||
@@ -133,25 +130,45 @@ fdescribe('ContentAction', () => {
|
||||
expect(model.handler).toBe(handler);
|
||||
});
|
||||
|
||||
it('should require target to get system handler', () => {
|
||||
it('should create document and folder action when there is no target', () => {
|
||||
spyOn(folderActions, 'getHandler').and.stub();
|
||||
spyOn(documentActions, 'getHandler').and.stub();
|
||||
|
||||
let action = new ContentActionComponent(actionList, documentActions, folderActions);
|
||||
action.handler = '<handler>';
|
||||
|
||||
action.ngOnInit();
|
||||
expect(documentList.actions.length).toBe(2);
|
||||
expect(folderActions.getHandler).toHaveBeenCalled();
|
||||
expect(documentActions.getHandler).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should create document action when target is document', () => {
|
||||
spyOn(folderActions, 'getHandler').and.stub();
|
||||
spyOn(documentActions, 'getHandler').and.stub();
|
||||
|
||||
let action = new ContentActionComponent(actionList, documentActions, folderActions);
|
||||
action.handler = '<handler>';
|
||||
action.target = 'document';
|
||||
|
||||
action.ngOnInit();
|
||||
expect(documentList.actions.length).toBe(1);
|
||||
expect(folderActions.getHandler).not.toHaveBeenCalled();
|
||||
expect(documentActions.getHandler).not.toHaveBeenCalled();
|
||||
|
||||
action.target = 'document';
|
||||
action.ngOnInit();
|
||||
expect(documentActions.getHandler).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should create folder action when target is folder', () => {
|
||||
spyOn(folderActions, 'getHandler').and.stub();
|
||||
spyOn(documentActions, 'getHandler').and.stub();
|
||||
|
||||
let action = new ContentActionComponent(actionList, documentActions, folderActions);
|
||||
action.handler = '<handler>';
|
||||
action.target = 'folder';
|
||||
|
||||
action.ngOnInit();
|
||||
expect(documentList.actions.length).toBe(1);
|
||||
expect(folderActions.getHandler).toHaveBeenCalled();
|
||||
expect(documentActions.getHandler).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should be case insensitive for document target', () => {
|
||||
|
||||
+8
-9
@@ -90,13 +90,11 @@ export class ContentActionComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.handler) {
|
||||
if (this.target === 'all') {
|
||||
this.generateAction('folder');
|
||||
this.generateAction('document');
|
||||
} else {
|
||||
this.generateAction(this.target);
|
||||
}
|
||||
if (this.target === 'all') {
|
||||
this.generateAction('folder');
|
||||
this.generateAction('document');
|
||||
} else {
|
||||
this.generateAction(this.target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,8 +114,9 @@ export class ContentActionComponent implements OnInit {
|
||||
target: target,
|
||||
disabled: this.disabled
|
||||
});
|
||||
|
||||
model.handler = this.getSystemHandler(target, this.handler);
|
||||
if (this.handler) {
|
||||
model.handler = this.getSystemHandler(target, this.handler);
|
||||
}
|
||||
|
||||
if (this.execute) {
|
||||
model.execute = (value: any): void => {
|
||||
|
||||
Reference in New Issue
Block a user