diff --git a/app/spiffworkflow/messages/MessageHelpers.js b/app/spiffworkflow/messages/MessageHelpers.js index 61f16c4..09d8206 100644 --- a/app/spiffworkflow/messages/MessageHelpers.js +++ b/app/spiffworkflow/messages/MessageHelpers.js @@ -86,6 +86,20 @@ export function findFormalExpressions(shapeElement) { return formalExpressions; } +export function getMessageElementForShapeElement(shapeElement) { + const { businessObject } = shapeElement; + const taskMessage = getMessageRefElement(shapeElement); + const messages = findMessageModdleElements(businessObject); + if (taskMessage) { + for (const message of messages) { + if (message.id === taskMessage.id) { + return message; + } + } + } + return null; +} + function processCorrelationProperty(correlationProperty, message) { const expressions = []; for (const retrievalExpression of correlationProperty.correlationPropertyRetrievalExpression) { diff --git a/app/spiffworkflow/messages/propertiesPanel/MessageSelect.js b/app/spiffworkflow/messages/propertiesPanel/MessageSelect.js index 8dd7748..e1df995 100644 --- a/app/spiffworkflow/messages/propertiesPanel/MessageSelect.js +++ b/app/spiffworkflow/messages/propertiesPanel/MessageSelect.js @@ -16,7 +16,6 @@ export function MessageSelect(props) { const getValue = () => { const messageRefElement = getMessageRefElement(shapeElement); - console.log('messageRefElement', messageRefElement); if (messageRefElement) { return messageRefElement.id; } diff --git a/app/spiffworkflow/messages/propertiesPanel/MessageVariable.js b/app/spiffworkflow/messages/propertiesPanel/MessageVariable.js index a13edeb..5635c72 100644 --- a/app/spiffworkflow/messages/propertiesPanel/MessageVariable.js +++ b/app/spiffworkflow/messages/propertiesPanel/MessageVariable.js @@ -1,9 +1,6 @@ import { useService } from 'bpmn-js-properties-panel'; import { TextFieldEntry } from '@bpmn-io/properties-panel'; -import { - findMessageModdleElements, - getMessageRefElement, -} from '../MessageHelpers'; +import { getMessageElementForShapeElement } from '../MessageHelpers'; /** * Allows the creation, or editing of messageVariable at the bpmn:sendTask level of a BPMN document. @@ -13,21 +10,15 @@ export function MessageVariable(props) { const debounce = useService('debounceInput'); const getMessageVariableObject = () => { - const { businessObject } = shapeElement; - const taskMessage = getMessageRefElement(shapeElement); - const messages = findMessageModdleElements(businessObject); - if (taskMessage) { - for (const message of messages) { - if (message.id === taskMessage.id) { - const { extensionElements } = message; - if (extensionElements) { - return message.extensionElements - .get('values') - .filter(function getInstanceOfType(e) { - return e.$instanceOf('spiffworkflow:messageVariable'); - })[0]; - } - } + const messageElement = getMessageElementForShapeElement(shapeElement); + if (messageElement) { + const { extensionElements } = messageElement; + if (extensionElements) { + return messageElement.extensionElements + .get('values') + .filter(function getInstanceOfType(e) { + return e.$instanceOf('spiffworkflow:messageVariable'); + })[0]; } } return null; @@ -35,7 +26,6 @@ export function MessageVariable(props) { const getValue = () => { const messageVariableObject = getMessageVariableObject(); - // console.log('messageVariableObject', messageVariableObject); if (messageVariableObject) { return messageVariableObject.messageVariable; } @@ -43,19 +33,18 @@ export function MessageVariable(props) { }; const setValue = (value) => { - const { businessObject } = shapeElement; let messageVariableObject = getMessageVariableObject(); - // console.log('messageVariableObject', messageVariableObject); if (!messageVariableObject) { - messageVariableObject = businessObject.$model.create( + const messageElement = getMessageElementForShapeElement(shapeElement); + messageVariableObject = messageElement.$model.create( 'spiffworkflow:messageVariable' ); - if (!businessObject.extensionElements) { - businessObject.extensionElements = businessObject.$model.create( + if (!messageElement.extensionElements) { + messageElement.extensionElements = messageElement.$model.create( 'bpmn:ExtensionElements' ); } - businessObject.extensionElements + messageElement.extensionElements .get('values') .push(messageVariableObject); }