diff --git a/demo-shell-ng2/app/components/files/files.component.html b/demo-shell-ng2/app/components/files/files.component.html
index 1e8e217a92..60e03585e2 100644
--- a/demo-shell-ng2/app/components/files/files.component.html
+++ b/demo-shell-ng2/app/components/files/files.component.html
@@ -47,6 +47,7 @@
+
diff --git a/ng2-components/ng2-alfresco-documentlist/README.md b/ng2-components/ng2-alfresco-documentlist/README.md
index 3fab9777dc..5aaf8e29ac 100644
--- a/ng2-components/ng2-alfresco-documentlist/README.md
+++ b/ng2-components/ng2-alfresco-documentlist/README.md
@@ -113,6 +113,31 @@ All document actions are rendered as a dropdown menu as on the picture below:

+
+#### Default action handlers
+
+The following action handlers are provided out-of-box:
+
+- Download
+
+All system handler names are case-insensitive, `handler="download"` and `handler="DOWNLOAD"`
+will trigger the same `download` action.
+
+##### Download
+
+Initiates download of the corresponding document file.
+
+```html
+
+
+
+
+
+```
+
+
+
+
#### Quick document actions
It is also possible to display most frequent actions within a separate ``
diff --git a/ng2-components/ng2-alfresco-documentlist/docs/assets/document-action-download.png b/ng2-components/ng2-alfresco-documentlist/docs/assets/document-action-download.png
new file mode 100644
index 0000000000..762ef14625
Binary files /dev/null and b/ng2-components/ng2-alfresco-documentlist/docs/assets/document-action-download.png differ
diff --git a/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.d.ts b/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.d.ts
index 4ce90714dc..8085f80ba4 100644
--- a/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.d.ts
+++ b/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.d.ts
@@ -9,6 +9,7 @@ import { QuickFolderAction } from './src/components/quick-folder-action';
import { QuickFolderActionList } from './src/components/quick-folder-action-list';
import { FolderActionsService } from './src/services/folder-actions.service';
import { DocumentActionsService } from './src/services/document-actions.service';
+import { AlfrescoService } from './src/services/alfresco.service';
export * from './src/components/document-list';
export * from './src/components/document-action';
export * from './src/components/document-action-list';
@@ -20,9 +21,10 @@ export * from './src/components/quick-folder-action';
export * from './src/components/quick-folder-action-list';
export * from './src/services/folder-actions.service';
export * from './src/services/document-actions.service';
+export * from './src/services/alfresco.service';
declare var _default: {
directives: (typeof DocumentList | typeof DocumentAction | typeof DocumentActionList | typeof QuickDocumentAction | typeof QuickDocumentActionList | typeof FolderAction | typeof FolderActionList | typeof QuickFolderAction | typeof QuickFolderActionList)[];
- providers: (typeof FolderActionsService | typeof DocumentActionsService)[];
+ providers: (typeof AlfrescoService | typeof FolderActionsService | typeof DocumentActionsService)[];
};
export default _default;
export declare const DOCUMENT_LIST_DIRECTIVES: [any];
diff --git a/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.js b/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.js
index c7e179bf62..b50c261648 100644
--- a/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.js
+++ b/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.js
@@ -1,7 +1,7 @@
-System.register(['./src/components/document-list', './src/components/document-action', './src/components/document-action-list', './src/components/quick-document-action', './src/components/quick-document-action-list', './src/components/folder-action', './src/components/folder-action-list', './src/components/quick-folder-action', './src/components/quick-folder-action-list', './src/services/folder-actions.service', './src/services/document-actions.service'], function(exports_1, context_1) {
+System.register(['./src/components/document-list', './src/components/document-action', './src/components/document-action-list', './src/components/quick-document-action', './src/components/quick-document-action-list', './src/components/folder-action', './src/components/folder-action-list', './src/components/quick-folder-action', './src/components/quick-folder-action-list', './src/services/folder-actions.service', './src/services/document-actions.service', './src/services/alfresco.service'], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
- var document_list_1, document_action_1, document_action_list_1, quick_document_action_1, quick_document_action_list_1, folder_action_1, folder_action_list_1, quick_folder_action_1, quick_folder_action_list_1, folder_actions_service_1, document_actions_service_1;
+ var document_list_1, document_action_1, document_action_list_1, quick_document_action_1, quick_document_action_list_1, folder_action_1, folder_action_list_1, quick_folder_action_1, quick_folder_action_list_1, folder_actions_service_1, document_actions_service_1, alfresco_service_1;
var DOCUMENT_LIST_DIRECTIVES, DOCUMENT_LIST_PROVIDERS;
var exportedNames_1 = {
'DOCUMENT_LIST_DIRECTIVES': true,
@@ -59,6 +59,10 @@ System.register(['./src/components/document-list', './src/components/document-ac
function (document_actions_service_1_1) {
document_actions_service_1 = document_actions_service_1_1;
exportStar_1(document_actions_service_1_1);
+ },
+ function (alfresco_service_1_1) {
+ alfresco_service_1 = alfresco_service_1_1;
+ exportStar_1(alfresco_service_1_1);
}],
execute: function() {
exports_1("default",{
@@ -74,6 +78,7 @@ System.register(['./src/components/document-list', './src/components/document-ac
quick_folder_action_list_1.QuickFolderActionList
],
providers: [
+ alfresco_service_1.AlfrescoService,
folder_actions_service_1.FolderActionsService,
document_actions_service_1.DocumentActionsService
]
@@ -90,6 +95,7 @@ System.register(['./src/components/document-list', './src/components/document-ac
quick_folder_action_list_1.QuickFolderActionList
]);
exports_1("DOCUMENT_LIST_PROVIDERS", DOCUMENT_LIST_PROVIDERS = [
+ alfresco_service_1.AlfrescoService,
folder_actions_service_1.FolderActionsService,
document_actions_service_1.DocumentActionsService
]);
diff --git a/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.js.map b/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.js.map
index dbe264adeb..e193925b3f 100644
--- a/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.js.map
+++ b/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.js.map
@@ -1 +1 @@
-{"version":3,"file":"ng2-alfresco-documentlist.js","sourceRoot":"","sources":["ng2-alfresco-documentlist.ts"],"names":[],"mappings":";;;;QA4Ca,wBAAwB,EAYxB,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA9BpC,oBAAe;gBACX,UAAU,EAAE;oBACR,4BAAY;oBACZ,gCAAc;oBACd,yCAAkB;oBAClB,2CAAmB;oBACnB,oDAAuB;oBACvB,4BAAY;oBACZ,qCAAgB;oBAChB,uCAAiB;oBACjB,gDAAqB;iBACxB;gBACD,SAAS,EAAE;oBACP,6CAAoB;oBACpB,iDAAsB;iBACzB;aACJ,EAAA;YAEY,sCAAA,wBAAwB,GAAU;gBAC3C,4BAAY;gBACZ,gCAAc;gBACd,yCAAkB;gBAClB,2CAAmB;gBACnB,oDAAuB;gBACvB,4BAAY;gBACZ,qCAAgB;gBAChB,uCAAiB;gBACjB,gDAAqB;aACxB,CAAA,CAAC;YAEW,qCAAA,uBAAuB,GAAU;gBAC1C,6CAAoB;gBACpB,iDAAsB;aACzB,CAAA,CAAC"}
\ No newline at end of file
+{"version":3,"file":"ng2-alfresco-documentlist.js","sourceRoot":"","sources":["ng2-alfresco-documentlist.ts"],"names":[],"mappings":";;;;QAgDa,wBAAwB,EAYxB,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA/BpC,oBAAe;gBACX,UAAU,EAAE;oBACR,4BAAY;oBACZ,gCAAc;oBACd,yCAAkB;oBAClB,2CAAmB;oBACnB,oDAAuB;oBACvB,4BAAY;oBACZ,qCAAgB;oBAChB,uCAAiB;oBACjB,gDAAqB;iBACxB;gBACD,SAAS,EAAE;oBACP,kCAAe;oBACf,6CAAoB;oBACpB,iDAAsB;iBACzB;aACJ,EAAA;YAEY,sCAAA,wBAAwB,GAAU;gBAC3C,4BAAY;gBACZ,gCAAc;gBACd,yCAAkB;gBAClB,2CAAmB;gBACnB,oDAAuB;gBACvB,4BAAY;gBACZ,qCAAgB;gBAChB,uCAAiB;gBACjB,gDAAqB;aACxB,CAAA,CAAC;YAEW,qCAAA,uBAAuB,GAAU;gBAC1C,kCAAe;gBACf,6CAAoB;gBACpB,iDAAsB;aACzB,CAAA,CAAC"}
\ No newline at end of file
diff --git a/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.ts b/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.ts
index 635204a1ec..0915658b9d 100644
--- a/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.ts
+++ b/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.ts
@@ -7,8 +7,10 @@ import {FolderAction} from './src/components/folder-action';
import {FolderActionList} from './src/components/folder-action-list';
import {QuickFolderAction} from './src/components/quick-folder-action';
import {QuickFolderActionList} from './src/components/quick-folder-action-list';
+
import {FolderActionsService} from './src/services/folder-actions.service';
import {DocumentActionsService} from './src/services/document-actions.service';
+import {AlfrescoService} from './src/services/alfresco.service';
// components
export * from './src/components/document-list';
@@ -23,6 +25,7 @@ export * from './src/components/quick-folder-action-list';
// services
export * from './src/services/folder-actions.service';
export * from './src/services/document-actions.service';
+export * from './src/services/alfresco.service';
export default {
directives: [
@@ -37,6 +40,7 @@ export default {
QuickFolderActionList
],
providers: [
+ AlfrescoService,
FolderActionsService,
DocumentActionsService
]
@@ -55,6 +59,7 @@ export const DOCUMENT_LIST_DIRECTIVES: [any] = [
];
export const DOCUMENT_LIST_PROVIDERS: [any] = [
+ AlfrescoService,
FolderActionsService,
DocumentActionsService
];
diff --git a/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.d.ts b/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.d.ts
index 3f4723230e..b6f31d0c1e 100644
--- a/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.d.ts
+++ b/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.d.ts
@@ -1,8 +1,12 @@
import { ContentActionHandler } from '../models/content-action.model';
+import { AlfrescoService } from './alfresco.service';
export declare class DocumentActionsService {
+ private _alfrescoService;
private handlers;
- constructor();
+ constructor(_alfrescoService: AlfrescoService);
getHandler(key: string): ContentActionHandler;
- private handleStandardAction1(document);
- private handleStandardAction2(document);
+ private setupActionHandlers();
+ private handleStandardAction1(obj);
+ private handleStandardAction2(obj);
+ private download(obj);
}
diff --git a/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.js b/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.js
index be278cb279..387aba04d8 100644
--- a/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.js
+++ b/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.js
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-System.register(['angular2/core'], function(exports_1, context_1) {
+System.register(['angular2/core', './alfresco.service'], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
@@ -26,33 +26,55 @@ System.register(['angular2/core'], function(exports_1, context_1) {
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
- var core_1;
+ var core_1, alfresco_service_1;
var DocumentActionsService;
return {
setters:[
function (core_1_1) {
core_1 = core_1_1;
+ },
+ function (alfresco_service_1_1) {
+ alfresco_service_1 = alfresco_service_1_1;
}],
execute: function() {
DocumentActionsService = (function () {
- function DocumentActionsService() {
+ function DocumentActionsService(_alfrescoService) {
+ this._alfrescoService = _alfrescoService;
this.handlers = {};
- // todo: just for dev/demo purposes, to be replaced with real actions
- this.handlers['system1'] = this.handleStandardAction1;
- this.handlers['system2'] = this.handleStandardAction2;
+ this.setupActionHandlers();
}
DocumentActionsService.prototype.getHandler = function (key) {
- return this.handlers[key];
+ if (key) {
+ var lkey = key.toLowerCase();
+ return this.handlers[lkey];
+ }
+ return null;
};
- DocumentActionsService.prototype.handleStandardAction1 = function (document) {
+ DocumentActionsService.prototype.setupActionHandlers = function () {
+ this.handlers['download'] = this.download.bind(this);
+ // 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);
+ };
+ DocumentActionsService.prototype.handleStandardAction1 = function (obj) {
window.alert('standard document action 1');
};
- DocumentActionsService.prototype.handleStandardAction2 = function (document) {
+ DocumentActionsService.prototype.handleStandardAction2 = function (obj) {
window.alert('standard document action 2');
};
+ DocumentActionsService.prototype.download = function (obj) {
+ if (obj && !obj.isFolder) {
+ var link = document.createElement('a');
+ document.body.appendChild(link);
+ link.setAttribute('download', 'download');
+ link.href = this._alfrescoService.getContentUrl(obj);
+ link.click();
+ document.body.removeChild(link);
+ }
+ };
DocumentActionsService = __decorate([
core_1.Injectable(),
- __metadata('design:paramtypes', [])
+ __metadata('design:paramtypes', [alfresco_service_1.AlfrescoService])
], DocumentActionsService);
return DocumentActionsService;
}());
diff --git a/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.js.map b/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.js.map
index 29b47fbd4a..ebbac98667 100644
--- a/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.js.map
+++ b/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.js.map
@@ -1 +1 @@
-{"version":3,"file":"document-actions.service.js","sourceRoot":"","sources":["document-actions.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;YAMH;gBAGI;oBAFQ,aAAQ,GAA4C,EAAE,CAAC;oBAG3D,qEAAqE;oBACrE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC;oBACtD,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC;gBAC1D,CAAC;gBAED,2CAAU,GAAV,UAAW,GAAW;oBAClB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;gBAC9B,CAAC;gBAEO,sDAAqB,GAA7B,UAA8B,QAAa;oBACvC,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;gBAC/C,CAAC;gBAEO,sDAAqB,GAA7B,UAA8B,QAAa;oBACvC,MAAM,CAAC,KAA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AAC,4BAA4B,CAAC,CAAC;gBAC/C,CAAC;gBAEO,yCAAQ,GAAhB,UAAiB,GAAQ;oBACrB,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;wBACvB,IAAI,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;wBACvC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;wBAChC,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;wBAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;wBACrD,IAAI,CAAC,KAAK,EAAE,CAAC;wBACb,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;oBACpC,CAAC;gBACL,CAAC;gBAzCL;oBAAC,iBAAU,EAAE;;0CAAA;gBA0Cb,6BAAC;YAAD,CAAC,AAzCD,IAyCC;YAzCD,2DAyCC,CAAA"}
\ No newline at end of file
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 360619d5cc..4a212002ba 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
@@ -17,26 +17,48 @@
import {Injectable} from 'angular2/core';
import {ContentActionHandler} from '../models/content-action.model';
+import {AlfrescoService} from './alfresco.service';
@Injectable()
export class DocumentActionsService {
private handlers: { [id: string]: ContentActionHandler; } = {};
- constructor() {
- // todo: just for dev/demo purposes, to be replaced with real actions
- this.handlers['system1'] = this.handleStandardAction1;
- this.handlers['system2'] = this.handleStandardAction2;
+ constructor(private _alfrescoService: AlfrescoService) {
+ this.setupActionHandlers();
}
getHandler(key: string): ContentActionHandler {
- return this.handlers[key];
+ if (key) {
+ let lkey = key.toLowerCase();
+ return this.handlers[lkey];
+ }
+ return null;
}
- private handleStandardAction1(document: any) {
+ private setupActionHandlers() {
+ this.handlers['download'] = this.download.bind(this);
+
+ // 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);
+ }
+
+ private handleStandardAction1(obj: any) {
window.alert('standard document action 1');
}
- private handleStandardAction2(document: any) {
+ private handleStandardAction2(obj: any) {
window.alert('standard document action 2');
}
+
+ private download(obj: any) {
+ if (obj && !obj.isFolder) {
+ let link = document.createElement('a');
+ document.body.appendChild(link);
+ link.setAttribute('download', 'download');
+ link.href = this._alfrescoService.getContentUrl(obj);
+ link.click();
+ document.body.removeChild(link);
+ }
+ }
}