如何使用自定义触发器将动态值添加到字段注入列表到 camunda 属性面板?

How to add dynamic values to field injections list with custom trigger to camunda properties panel?

我这里有两个问题

  1. 是否可以将动态列表值添加到字段注入列表输入中?
  2. 我能否为此创建一个触发器,以便可以从任何其他输入选择启动,比如 class 选择将填充所有字段

我只是在研究 FieldInjection.js 是否可以扩展相同的

有人可以为此提供提示或指导吗?

谢谢。

对于任何对答案感兴趣的人,我能够通过将 Java Class select 输入的设置函数更改为以下

来实现上述目标

少量进口

var extensionElementsHelper = require('../../../../helper/ExtensionElementsHelper'),
    elementHelper = require('../../../../helper/ElementHelper')

var CAMUNDA_FIELD_EXTENSION_ELEMENT = 'camunda:Field';

function getExtensionFields(bo) {
      return bo && extensionElementsHelper.getExtensionElements(bo, CAMUNDA_FIELD_EXTENSION_ELEMENT) || [];
}

然后更改设置函数以创建扩展元素并将字段值推送为:

set: function(element, values, node) {
      var bo = getBusinessObject(element);
      var type = getImplementationType(element);
      var attr = getAttribute(type);
      var prop = {}
      var commands = [];
      prop[attr] = values.delegate || '';
      var extensionElements = getExtensionFields(bo);
      //remove any extension elements existing before
      extensionElements.forEach(function(ele){
        commands.push(extensionElementsHelper.removeEntry(getBusinessObject(element), element, ele));
      });
      if(prop[attr] !== ""){
        var extensionElements = elementHelper.createElement('bpmn:ExtensionElements', { values: [] }, bo, bpmnFactory);
        commands.push(cmdHelper.updateBusinessObject(element, bo, { extensionElements: extensionElements }));
        var arrProperties = ["private org.camunda.bpm.engine.delegate.Expression com.cfe.extensions.SampleJavaDelegate.varOne","private org.camunda.bpm.engine.delegate.Expression com.cfe.extensions.SampleJavaDelegate.varTwo"]

        var newFieldElem = "";
        arrProperties.forEach(function(prop){
          var eachProp = {
            name:"",
            string:"",
            expression:""
          }
          var type = prop.split(" ")[1].split(".").reverse()[0];
          var val = prop.split(" ")[2].split(".").reverse()[0];
          eachProp.name = val;
          if( type == "String"){
            eachProp.string = "${" + val  +" }"
          }else if( type == "Expression"){
            eachProp.expression = "${" + val  +" }"
          }

          newFieldElem = elementHelper.createElement(CAMUNDA_FIELD_EXTENSION_ELEMENT, eachProp, extensionElements, bpmnFactory);
          commands.push(cmdHelper.addElementsTolist(element, extensionElements, 'values', [ newFieldElem ]));
        });
      }
      commands.push(cmdHelper.updateBusinessObject(element, bo, prop));
      return commands;
    }

干杯!