#482 populate action/context menu with bpm processes

This commit is contained in:
Denys Vuika
2016-07-27 11:44:20 +01:00
parent 31c010a349
commit a945cd1fff
3 changed files with 53 additions and 6 deletions

View File

@@ -15,11 +15,13 @@
* limitations under the License.
*/
import { Component } from '@angular/core';
import { Component, OnInit, ViewChild } from '@angular/core';
import {
DOCUMENT_LIST_DIRECTIVES,
DOCUMENT_LIST_PROVIDERS,
DocumentActionsService
DocumentActionsService,
DocumentList,
ContentActionModel, ContentActionHandler
} from 'ng2-alfresco-documentlist';
import {
MDL,
@@ -30,6 +32,7 @@ import {
import { PaginationComponent } from 'ng2-alfresco-datatable';
import { ALFRESCO_ULPOAD_COMPONENTS } from 'ng2-alfresco-upload';
import { VIEWERCOMPONENT } from 'ng2-alfresco-viewer';
import { FormService } from 'ng2-activiti-form';
declare let __moduleName: string;
@@ -46,10 +49,10 @@ declare let __moduleName: string;
CONTEXT_MENU_DIRECTIVES,
PaginationComponent
],
providers: [DOCUMENT_LIST_PROVIDERS],
providers: [DOCUMENT_LIST_PROVIDERS, FormService],
pipes: [AlfrescoPipeTranslate]
})
export class FilesComponent {
export class FilesComponent implements OnInit {
currentPath: string = '/Sites/swsdp/documentLibrary';
urlFile: string;
@@ -62,8 +65,12 @@ export class FilesComponent {
acceptedFilesType: string = '.jpg,.pdf,.js';
@ViewChild(DocumentList)
documentList: DocumentList;
constructor(private contentService: AlfrescoContentService,
documentActions: DocumentActionsService) {
private documentActions: DocumentActionsService,
private formService: FormService) {
documentActions.setHandler('my-handler', this.myDocumentActionHandler.bind(this));
}
@@ -111,4 +118,30 @@ export class FilesComponent {
this.acceptedFilesTypeShow = !this.acceptedFilesTypeShow;
return this.acceptedFilesTypeShow;
}
ngOnInit() {
console.log(this.documentList);
this.formService.getProcessDefinitions().subscribe(
defs => this.setupBpmActions(defs || []),
err => console.log(err)
);
}
private setupBpmActions(actions: any[]) {
actions.map(def => {
let action = new ContentActionModel();
action.target = 'document';
action.title = 'Activiti: ' + (def.name || 'Unknown process');
action.handler = this.getBpmActionHandler(def);
this.documentList.actions.push(action);
});
console.log(this.documentList.actions);
}
private getBpmActionHandler(processDefinition: any): ContentActionHandler {
return function (obj: any, target?: any) {
window.alert(`Starting BPM process: ${processDefinition.id}`);
}.bind(this);
}
}