mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-06-30 18:15:11 +00:00
#9 folder delete action
This commit is contained in:
parent
c08b33b155
commit
3c6c5dd136
@ -41,6 +41,12 @@
|
||||
title="{{'DOCUMENT_LIST.ACTIONS.FOLDER.CUSTOM' | translate}}"
|
||||
(execute)="myFolderAction1($event)">
|
||||
</content-action>
|
||||
<content-action
|
||||
target="folder"
|
||||
type="menu"
|
||||
title="{{'DOCUMENT_LIST.ACTIONS.FOLDER.DELETE' | translate}}"
|
||||
handler="delete">
|
||||
</content-action>
|
||||
|
||||
<!-- document actions -->
|
||||
<content-action
|
||||
|
@ -10,7 +10,8 @@
|
||||
"ACTIONS": {
|
||||
"FOLDER": {
|
||||
"SYSTEM_1": "System folder action 1",
|
||||
"CUSTOM": "Custom folder action"
|
||||
"CUSTOM": "Custom folder action",
|
||||
"DELETE": "Delete"
|
||||
},
|
||||
"DOCUMENT": {
|
||||
"DOWNLOAD": "Download",
|
||||
|
@ -193,8 +193,8 @@ All document actions with `type="menu"` are rendered as a dropdown menu as on th
|
||||
|
||||
The following action handlers are provided out-of-box:
|
||||
|
||||
- Download
|
||||
- Delete
|
||||
- Download (document)
|
||||
- Delete (document, folder)
|
||||
|
||||
All system handler names are case-insensitive, `handler="download"` and `handler="DOWNLOAD"`
|
||||
will trigger the same `download` action.
|
||||
|
@ -23,7 +23,7 @@ import {AlfrescoService} from './alfresco.service';
|
||||
export class DocumentActionsService {
|
||||
private handlers: { [id: string]: ContentActionHandler; } = {};
|
||||
|
||||
constructor(private _alfrescoService: AlfrescoService) {
|
||||
constructor(private _alfrescoService?: AlfrescoService) {
|
||||
this.setupActionHandlers();
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ export class DocumentActionsService {
|
||||
}
|
||||
|
||||
canExecuteAction(obj: any): boolean {
|
||||
return this._alfrescoService && obj && !obj.isFolder;
|
||||
return this._alfrescoService && obj && obj.entry.isFile === true;
|
||||
}
|
||||
|
||||
private setupActionHandlers() {
|
||||
|
@ -17,15 +17,14 @@
|
||||
|
||||
import {Injectable} from 'angular2/core';
|
||||
import {ContentActionHandler} from '../models/content-action.model';
|
||||
import {AlfrescoService} from './alfresco.service';
|
||||
|
||||
@Injectable()
|
||||
export class FolderActionsService {
|
||||
private handlers: { [id: string]: ContentActionHandler; } = {};
|
||||
|
||||
constructor() {
|
||||
// todo: just for dev/demo purposes, to be replaced with real actions
|
||||
this.handlers['system1'] = this.handleStandardAction1.bind(this);
|
||||
this.handlers['system2'] = this.handleStandardAction2.bind(this);
|
||||
constructor(private _alfrescoService?: AlfrescoService) {
|
||||
this.setupActionHandlers();
|
||||
}
|
||||
|
||||
getHandler(key: string): ContentActionHandler {
|
||||
@ -43,11 +42,35 @@ export class FolderActionsService {
|
||||
}
|
||||
}
|
||||
|
||||
canExecuteAction(obj: any): boolean {
|
||||
return this._alfrescoService && obj && obj.entry.isFolder === true;
|
||||
}
|
||||
|
||||
private setupActionHandlers() {
|
||||
this.handlers['delete'] = this.deleteNode.bind(this);
|
||||
|
||||
// TODO: for demo purposes only, will be removed during future revisions
|
||||
this.handlers['system1'] = this.handleStandardAction1.bind(this);
|
||||
this.handlers['system2'] = this.handleStandardAction2.bind(this);
|
||||
}
|
||||
|
||||
// TODO: for demo purposes only, will be removed during future revisions
|
||||
private handleStandardAction1(document: any) {
|
||||
window.alert('standard folder action 1');
|
||||
}
|
||||
|
||||
// TODO: for demo purposes only, will be removed during future revisions
|
||||
private handleStandardAction2(document: any) {
|
||||
window.alert('standard folder action 2');
|
||||
}
|
||||
|
||||
private deleteNode(obj: any, target?: any) {
|
||||
if (this.canExecuteAction(obj) && obj.entry && obj.entry.id) {
|
||||
this._alfrescoService.deleteNode(obj.entry.id).subscribe(() => {
|
||||
if (target && typeof target.reload === 'function') {
|
||||
target.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user