diff --git a/demo-shell-ng2/app/components/files/files.component.html b/demo-shell-ng2/app/components/files/files.component.html
index 0de6bbb427..83c3f08831 100644
--- a/demo-shell-ng2/app/components/files/files.component.html
+++ b/demo-shell-ng2/app/components/files/files.component.html
@@ -73,6 +73,12 @@
title="{{'DOCUMENT_LIST.ACTIONS.DOCUMENT.CUSTOM' | translate}}"
(execute)="myCustomAction1($event)">
+
+
diff --git a/demo-shell-ng2/i18n/en.json b/demo-shell-ng2/i18n/en.json
index f5bbbccf7d..6732e04604 100644
--- a/demo-shell-ng2/i18n/en.json
+++ b/demo-shell-ng2/i18n/en.json
@@ -14,6 +14,7 @@
},
"DOCUMENT": {
"DOWNLOAD": "Download",
+ "DELETE": "Delete",
"SYSTEM_2": "System document action 2",
"CUSTOM": "Custom action"
}
diff --git a/ng2-components/ng2-alfresco-documentlist/README.md b/ng2-components/ng2-alfresco-documentlist/README.md
index 302b590f72..75d89787b8 100644
--- a/ng2-components/ng2-alfresco-documentlist/README.md
+++ b/ng2-components/ng2-alfresco-documentlist/README.md
@@ -194,6 +194,7 @@ 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
All system handler names are case-insensitive, `handler="download"` and `handler="DOWNLOAD"`
will trigger the same `download` action.
diff --git a/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts b/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts
index 18f54ae95f..2fbd93e744 100644
--- a/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts
+++ b/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts
@@ -106,6 +106,12 @@ import {
title="{{'DOCUMENT_LIST.ACTIONS.DOCUMENT.CUSTOM' | translate}}"
(execute)="myCustomAction1($event)">
+
+
diff --git a/ng2-components/ng2-alfresco-documentlist/karma-test-shim.js b/ng2-components/ng2-alfresco-documentlist/karma-test-shim.js
index 5544ce9a11..14049525ec 100644
--- a/ng2-components/ng2-alfresco-documentlist/karma-test-shim.js
+++ b/ng2-components/ng2-alfresco-documentlist/karma-test-shim.js
@@ -14,16 +14,14 @@ System.config({
format: 'register',
map: Object.keys(window.__karma__.files).filter(onlyAppFiles).reduce(createPathRecords, {})
},
- 'ng2-alfresco-core/dist': {
- defaultExtension: 'js'
- },
- 'rxjs': {
- defaultExtension: 'js'
- }
+ 'ng2-alfresco-core/dist': { defaultExtension: 'js' },
+ 'rxjs': { defaultExtension: 'js' },
+ 'ng2-translate': { defaultExtension: 'js' }
},
map: {
'ng2-alfresco-core/dist': '/base/node_modules/ng2-alfresco-core/dist',
- 'rxjs': '/base/node_modules/rxjs'
+ 'rxjs': '/base/node_modules/rxjs',
+ 'ng2-translate': '/base/node_modules/ng2-translate/bundles'
}
});
diff --git a/ng2-components/ng2-alfresco-documentlist/karma.conf.js b/ng2-components/ng2-alfresco-documentlist/karma.conf.js
index 9b707f91ac..d011d5af49 100644
--- a/ng2-components/ng2-alfresco-documentlist/karma.conf.js
+++ b/ng2-components/ng2-alfresco-documentlist/karma.conf.js
@@ -17,6 +17,7 @@ module.exports = function (config) {
{pattern: 'node_modules/angular2/bundles/http.dev.js', included: true, watched: true},
{pattern: 'node_modules/alfresco-core-rest-api/bundle.js', included: true, watched: false},
{pattern: 'node_modules/ng2-alfresco-core/dist/**/*.js', included: false, served: true, watched: false},
+ {pattern: 'node_modules/ng2-translate/bundles/ng2-translate.js', included: true, watched: false},
{pattern: 'karma-test-shim.js', included: true, watched: true},
diff --git a/ng2-components/ng2-alfresco-documentlist/package.json b/ng2-components/ng2-alfresco-documentlist/package.json
index 781d54d12f..a043d4a36b 100644
--- a/ng2-components/ng2-alfresco-documentlist/package.json
+++ b/ng2-components/ng2-alfresco-documentlist/package.json
@@ -56,10 +56,9 @@
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"systemjs": "0.19.26",
- "zone.js": "^0.6.12"
- },
- "peerDependencies": {
- "angular2": "2.0.0-beta.15"
+ "zone.js": "^0.6.12",
+ "alfresco-core-rest-api": "^0.1.0",
+ "ng2-translate": "^1.11.3"
},
"devDependencies": {
"copyfiles": "^0.2.1",
diff --git a/ng2-components/ng2-alfresco-documentlist/src/assets/alfresco.service.mock.ts b/ng2-components/ng2-alfresco-documentlist/src/assets/alfresco.service.mock.ts
index f0862e90e1..ebcb6c6466 100644
--- a/ng2-components/ng2-alfresco-documentlist/src/assets/alfresco.service.mock.ts
+++ b/ng2-components/ng2-alfresco-documentlist/src/assets/alfresco.service.mock.ts
@@ -15,7 +15,6 @@
* limitations under the License.
*/
-import {Http} from 'angular2/http';
import {Observable} from 'rxjs/Observable';
import {AlfrescoService} from '../../src/services/alfresco.service';
import {AlfrescoSettingsService} from 'ng2-alfresco-core/dist/ng2-alfresco-core';
@@ -25,10 +24,9 @@ export class AlfrescoServiceMock extends AlfrescoService {
_folderToReturn: any = {};
constructor(
- http: Http = null,
settings: AlfrescoSettingsService = null
) {
- super(http, settings);
+ super(settings);
}
getFolder(folder: string) {
diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.ts b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.ts
index fdb8845f55..031b0e05c1 100644
--- a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.ts
+++ b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.ts
@@ -247,7 +247,7 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit
*/
executeContentAction(node: MinimalNodeEntity, action: ContentActionModel) {
if (action) {
- action.handler(node);
+ action.handler(node, this);
}
}
diff --git a/ng2-components/ng2-alfresco-documentlist/src/models/content-action.model.ts b/ng2-components/ng2-alfresco-documentlist/src/models/content-action.model.ts
index bfd303d523..c8f01df746 100644
--- a/ng2-components/ng2-alfresco-documentlist/src/models/content-action.model.ts
+++ b/ng2-components/ng2-alfresco-documentlist/src/models/content-action.model.ts
@@ -34,5 +34,5 @@ export class ContentActionModel {
}
export interface ContentActionHandler {
- (obj: any): any;
+ (obj: any, target?: any): any;
}
diff --git a/ng2-components/ng2-alfresco-documentlist/src/services/alfresco.service.ts b/ng2-components/ng2-alfresco-documentlist/src/services/alfresco.service.ts
index 7047a95adb..ca248e5cad 100644
--- a/ng2-components/ng2-alfresco-documentlist/src/services/alfresco.service.ts
+++ b/ng2-components/ng2-alfresco-documentlist/src/services/alfresco.service.ts
@@ -16,7 +16,7 @@
*/
import { Injectable } from 'angular2/core';
-import { Http, Response } from 'angular2/http';
+import { Response } from 'angular2/http';
import { Observable } from 'rxjs/Rx';
import { NodePaging, MinimalNodeEntity } from './../models/document-library.model';
import { AlfrescoSettingsService } from 'ng2-alfresco-core/dist/ng2-alfresco-core';
@@ -32,7 +32,6 @@ export class AlfrescoService {
private _baseUrlPath: string = '/alfresco/api/-default-/public/alfresco/versions/1';
constructor(
- private http: Http,
private settings: AlfrescoSettingsService) {
}
@@ -71,6 +70,13 @@ export class AlfrescoService {
return apiInstance.getNodeChildren(nodeId, opts);
}
+ deleteNode(nodeId: string) {
+ let client = this.getAlfrescoClient();
+ let nodesApi = new AlfrescoApi.NodesApi(client);
+ let opts = {};
+ return Observable.fromPromise(nodesApi.deleteNode(nodeId, opts));
+ }
+
/**
* Gets the folder node with the content.
* @param folder Path to folder.
diff --git a/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.ts b/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.ts
index 26eb3a1bdb..afd2fcb8ca 100644
--- a/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.ts
+++ b/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.ts
@@ -42,24 +42,31 @@ export class DocumentActionsService {
}
}
+ canExecuteAction(obj: any): boolean {
+ return this._alfrescoService && obj && !obj.isFolder;
+ }
+
private setupActionHandlers() {
this.handlers['download'] = this.download.bind(this);
+ this.handlers['delete'] = this.deleteNode.bind(this);
- // todo: just for dev/demo purposes, to be replaced with real actions
+ // 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(obj: any) {
window.alert('standard document action 1');
}
+ // TODO: for demo purposes only, will be removed during future revisions
private handleStandardAction2(obj: any) {
window.alert('standard document action 2');
}
private download(obj: any) {
- if (this._alfrescoService && obj && !obj.isFolder) {
+ if (this.canExecuteAction(obj)) {
let link = document.createElement('a');
document.body.appendChild(link);
link.setAttribute('download', 'download');
@@ -68,4 +75,14 @@ export class DocumentActionsService {
document.body.removeChild(link);
}
}
+
+ 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();
+ }
+ });
+ }
+ }
}