Alfresco: linking directly to workflow

房东的猫 提交于 2020-02-06 07:23:47

问题


I would like to start a workflow from the site links dashlet on my Alfresco site. Using Firebug to examine the POST gives me a URL that works, but it only displays the form without any UI:

http://localhost:8081/share/service/components/form?htmlid=template_x002e_start-workflow_x002e_start-workflow_x0023_default-startWorkflowForm-alf-id1&itemKind=workflow&itemId=activiti%24orpWorkflow&mode=create&submitType=json&showCaption=true&formUI=true&showCancelButton=true&destination=
  1. Is this possible? And if so, how can I format the link to include the UI?
  2. If not, are there custom dashlets out there designed for starting workflows?

回答1:


When you select workflow from dropdown it will generate url based on selected workflow and redirect you to that.

Ex. For ParallelGroupReview workflow URL is.

http://localhost:8080/share/service/components/form?htmlid=template_x002e_start-workflow_x002e_start-workflow_x0023_default-startWorkflowForm-alf-id1&itemKind=workflow&itemId=activiti%24activitiParallelGroupReview&mode=create&submitType=json&showCaption=true&formUI=true&showCancelButton=true&destination=

Now if you use this url directly in browser you will be able to see same form but header and footer part will be missing, because those global components will not be avilable outside of share context.

If you see start-workflow.ftl you will be able to see header and footer components are inserted which are responsible for rest of the UI.

<#include "include/alfresco-template.ftl" />
<@templateHeader />

<@templateBody>
   <@markup id="alf-hd">
   <div id="alf-hd">
      <@region scope="global" id="share-header" chromeless="true"/>
   </div>
   </@>
   <@markup id="bd">
   <div id="bd">
      <div class="share-form">
         <@region id="start-workflow" scope="template"/>
      </div>
   </div>
   </@>
</@>

<@templateFooter>
   <@markup id="al-ft">
   <div id="alf-ft">
      <@region id="footer" scope="global"/>
   </div>
   </@>
</@>

You can reuse same component just need to make sure header and footer are initialized properly.




回答2:


I created an extension module which has the following target:

<targetPackageRoot>org.alfresco.components.workflow</targetPackageRoot>

I included the following piece in my extended start-workflow.get.html.ftl:

<@markup id="start-workflow-js" target="js" action="after">
   <@script src="${url.context}/res/components/workflow/initiate-workflow.js" group="workflow"/>
</@>

to extend the default start-workflow.js of my own.

You'll need to change the following methods:

  • onReady: so it reads your param from the url to know which workflowdefinition to start and fire onWorkflowSelectChange
  • onWorkflowSelectChange: So it reads the workflowdefintion to load the form



回答3:


You can make a little customization for Share.

For example, if you need to open the start form of any business process, you can find its index in the popup and add an additional parameter to the URL (let's say, openFormParam).

In start-workflow.js:

onReady: function StartWorkflow_onReady() {
    // skipped ...
    // get the additional parameter from the URL here
    // var openFormParam = ...

    if(openFormParam !== null) {
        var p_aArgs = [];
        var index = {index: 0}; // for the first workflow in the popup

        p_aArgs.push(0, index);
        this.onWorkflowSelectChange(null, p_aArgs);
    }

    return Alfresco.component.StartWorkflow.superclass.onReady.call(this);
},

 // OOTB
onWorkflowSelectChange: function StartWorkflow_onWorkflowSelectChange(p_sType, p_aArgs) {
    var i = p_aArgs[1].index;
    if (i >= 0) {
        // Update label of workflow menu button
        var workflowDefinition = this.options.workflowDefinitions[i];
        this.widgets.workflowDefinitionMenuButton.set("label", workflowDefinition.title + " " + Alfresco.constants.MENU_ARROW_SYMBOL);
        this.widgets.workflowDefinitionMenuButton.set("title", workflowDefinition.description);

        // Load the form for the specific workflow
        Alfresco.util.Ajax.request({
            url: Alfresco.constants.URL_SERVICECONTEXT + "components/form",
            dataObj: {
                htmlid: this.id + "-startWorkflowForm-" + Alfresco.util.generateDomId(),
                itemKind: "workflow",
                itemId: workflowDefinition.name,
                mode: "create",
                submitType: "json",
                showCaption: true,
                formUI: true,
                showCancelButton: true,
                destination: this.options.destination
            },
            successCallback: {
                fn: this.onWorkflowFormLoaded,
                scope: this
            },

            failureMessage: this.msg("message.failure"),
                scope: this,
                execScripts: true
        });
    }
},


来源:https://stackoverflow.com/questions/31252572/alfresco-linking-directly-to-workflow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!