'Download' action for document list menu

- default ‘download’ action for document list menu
- readme updates

refs #20
This commit is contained in:
Denys Vuika
2016-05-03 13:58:37 +01:00
parent 8ec414036f
commit 5cf9b296d6
11 changed files with 112 additions and 25 deletions

View File

@@ -47,6 +47,7 @@
<quick-document-action icon="thumb_up" handler="system2"></quick-document-action>
</quick-document-actions>
<document-actions>
<document-action title="Download" handler="DOWNLOAD"></document-action>
<document-action title="System action" handler="system2"></document-action>
<document-action title="Custom action" (execute)="myCustomAction1($event)"></document-action>
</document-actions>

View File

@@ -113,6 +113,31 @@ All document actions are rendered as a dropdown menu as on the picture below:
![Document Actions](docs/assets/document-actions.png)
#### 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
<alfresco-document-list ...>
<document-actions>
<document-action title="Download" handler="download"></document-action>
</document-actions>
</alfresco-document-list>
```
![Download document action](docs/assets/document-action-download.png)
#### Quick document actions
It is also possible to display most frequent actions within a separate `<quick-documents>`

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

View File

@@ -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];

View File

@@ -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
]);

View File

@@ -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"}
{"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"}

View File

@@ -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
];

View File

@@ -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);
}

View File

@@ -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;
}());

View File

@@ -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,KAAK,CAAC,4BAA4B,CAAC,CAAC;gBAC/C,CAAC;gBApBL;oBAAC,iBAAU,EAAE;;0CAAA;gBAqBb,6BAAC;YAAD,CAAC,AApBD,IAoBC;YApBD,2DAoBC,CAAA"}
{"version":3,"file":"document-actions.service.js","sourceRoot":"","sources":["document-actions.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;YAOH;gBAGI,gCAAoB,gBAAiC;oBAAjC,qBAAgB,GAAhB,gBAAgB,CAAiB;oBAF7C,aAAQ,GAA4C,EAAE,CAAC;oBAG3D,IAAI,CAAC,mBAAmB,EAAE,CAAC;gBAC/B,CAAC;gBAED,2CAAU,GAAV,UAAW,GAAW;oBAClB,EAAE,CAAC,CAAC,GAAG,CAAC,CAA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AW,CAAC,IAAI,CAAC,CAAC;oBACpC,CAAC;gBACL,CAAC;gBAzCL;oBAAC,iBAAU,EAAE;;0CAAA;gBA0Cb,6BAAC;YAAD,CAAC,AAzCD,IAyCC;YAzCD,2DAyCC,CAAA"}

View File

@@ -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);
}
}
}