From decbaba90d62226e081ab123f1f7380ee52585f7 Mon Sep 17 00:00:00 2001 From: Alexander Skrock Date: Thu, 24 Aug 2023 16:15:12 +0200 Subject: [PATCH] feat(element-templates): use the configured property name for execution listener binding --- src/element-templates/CreateHelper.js | 21 +++++++++---------- .../cmd/ChangeElementTemplateHandler.js | 4 ++-- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/element-templates/CreateHelper.js b/src/element-templates/CreateHelper.js index 59bc19f9..87a7e4a2 100644 --- a/src/element-templates/CreateHelper.js +++ b/src/element-templates/CreateHelper.js @@ -150,28 +150,27 @@ export function createCamundaOut(binding, value, bpmnFactory) { * * @return {ModdleElement} */ -export function createCamundaExecutionListenerScript(binding, value, bpmnFactory) { +export function createCamundaExecutionListener(binding, value, bpmnFactory) { const { event, + name, scriptFormat } = binding; - let parameterValue, - parameterDefinition; - if (scriptFormat) { - parameterDefinition = bpmnFactory.create('camunda:Script', { - scriptFormat, - value + return bpmnFactory.create('camunda:ExecutionListener', { + event, + script: bpmnFactory.create('camunda:Script', { + scriptFormat, + value + }) }); - } else { - parameterValue = value; } + const boundPropertyName = name || 'value'; return bpmnFactory.create('camunda:ExecutionListener', { event, - value: parameterValue, - script: parameterDefinition + [boundPropertyName]: value }); } diff --git a/src/element-templates/cmd/ChangeElementTemplateHandler.js b/src/element-templates/cmd/ChangeElementTemplateHandler.js index 8e081243..621abb64 100644 --- a/src/element-templates/cmd/ChangeElementTemplateHandler.js +++ b/src/element-templates/cmd/ChangeElementTemplateHandler.js @@ -14,7 +14,7 @@ import { import handleLegacyScopes from '../util/handleLegacyScopes'; import { - createCamundaExecutionListenerScript, + createCamundaExecutionListener, createCamundaFieldInjection, createCamundaIn, createCamundaInWithBusinessKey, @@ -253,7 +253,7 @@ export default class ChangeElementTemplateHandler { const newBinding = newProperty.binding, propertyValue = newProperty.value; - return createCamundaExecutionListenerScript(newBinding, propertyValue, bpmnFactory); + return createCamundaExecutionListener(newBinding, propertyValue, bpmnFactory); }); commandStack.execute('element.updateModdleProperties', {