[ADF-2163] start refactoring folder dulpication action

This commit is contained in:
VitoAlbano
2018-02-01 10:12:09 +00:00
parent 495b8c5185
commit 76d5e5f805
2 changed files with 14 additions and 12 deletions
@@ -198,7 +198,7 @@
<!-- folder actions -->
<content-action
icon="content_copy"
target="all"
title="{{'DOCUMENT_LIST.ACTIONS.FOLDER.COPY' | translate}}"
permission="update"
[disableWithNoPermission]="true"
@@ -84,7 +84,7 @@ export class ContentActionComponent implements OnInit, OnChanges {
success = new EventEmitter();
model: ContentActionModel;
duplicateModel: ContentActionModel;
// duplicateModel: ContentActionModel;
constructor(
private list: ContentActionListComponent,
@@ -102,15 +102,13 @@ export class ContentActionComponent implements OnInit, OnChanges {
target: this.target,
disabled: this.disabled
});
this.duplicateModel = null;
if (this.handler) {
if(this.target === 'all') {
this.duplicateModel = Object.assign({}, this.model);
this.duplicateModel.handler = this.getSystemHandler('folder', this.handler);
this.duplicateModel.target = 'folder';
if (this.target === 'all') {
this.duplicateActionForFolder();
this.model.target = 'document';
this.model.handler = this.getSystemHandler('document', this.handler);
}else {
this.model.handler = this.getSystemHandler('document', this.handler);
}else{
this.model.handler = this.getSystemHandler(this.target, this.handler);
}
}
@@ -126,9 +124,6 @@ export class ContentActionComponent implements OnInit, OnChanges {
register(): boolean {
if (this.list) {
if(this.target === 'all' ) {
this.list.registerAction(this.duplicateModel);
}
return this.list.registerAction(this.model);
}
return false;
@@ -139,6 +134,13 @@ export class ContentActionComponent implements OnInit, OnChanges {
this.model.title = this.title;
}
private duplicateActionForFolder() {
let folderActionModel = Object.assign({}, this.model);
folderActionModel.handler = this.getSystemHandler('folder', this.handler);
folderActionModel.target = 'folder';
this.list.registerAction(folderActionModel);
}
getSystemHandler(target: string, name: string): ContentActionHandler {
if (target) {
let ltarget = target.toLowerCase();