mirror of
https://github.com/sartography/bpmn-js-spiffworkflow.git
synced 2025-02-23 13:08:11 +00:00
Merge pull request #13 from sartography/feature/gateway_condition_expressions
Feature/gateway condition expressions
This commit is contained in:
commit
b61d5098dc
@ -4,12 +4,13 @@ import {
|
||||
BpmnPropertiesProviderModule,
|
||||
} from 'bpmn-js-properties-panel';
|
||||
import FileSaver from 'file-saver';
|
||||
import diagramXML from '../test/spec/bpmn/basic_message.bpmn';
|
||||
import diagramXML from '../test/spec/bpmn/gateway.bpmn';
|
||||
import spiffworkflow from './spiffworkflow';
|
||||
|
||||
const modelerEl = document.getElementById('modeler');
|
||||
const panelEl = document.getElementById('panel');
|
||||
const spiffModdleExtension = require('./spiffworkflow/moddle/spiffworkflow.json');
|
||||
const bpmnModdleExtension = require('./spiffworkflow/moddle/bpmn.json');
|
||||
|
||||
let bpmnModeler;
|
||||
|
||||
@ -27,6 +28,7 @@ try {
|
||||
],
|
||||
moddleExtensions: {
|
||||
spiffworkflowModdle: spiffModdleExtension,
|
||||
// bpmnModdleExtension,
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
|
6
app/spiffworkflow/conditions/index.js
Normal file
6
app/spiffworkflow/conditions/index.js
Normal file
@ -0,0 +1,6 @@
|
||||
import ConditionsPropertiesProvider from './propertiesPanel/ConditionsPropertiesProvider';
|
||||
|
||||
export default {
|
||||
__init__: ['conditionsPropertiesProvider'],
|
||||
conditionsPropertiesProvider: ['type', ConditionsPropertiesProvider],
|
||||
};
|
@ -0,0 +1,101 @@
|
||||
import { is } from 'bpmn-js/lib/util/ModelUtil';
|
||||
import {
|
||||
isTextFieldEntryEdited,
|
||||
TextFieldEntry,
|
||||
} from '@bpmn-io/properties-panel';
|
||||
import { useService } from 'bpmn-js-properties-panel';
|
||||
|
||||
const LOW_PRIORITY = 500;
|
||||
|
||||
export default function ConditionsPropertiesProvider(
|
||||
propertiesPanel,
|
||||
translate,
|
||||
moddle,
|
||||
commandStack,
|
||||
_elementRegistry
|
||||
) {
|
||||
this.getGroups = function getGroupsCallback(element) {
|
||||
return function pushGroup(groups) {
|
||||
if (is(element, 'bpmn:SequenceFlow')) {
|
||||
const { source } = element;
|
||||
if (is(source, 'bpmn:ExclusiveGateway')) {
|
||||
groups.push(
|
||||
createConditionsGroup(element, translate, moddle, commandStack)
|
||||
);
|
||||
}
|
||||
}
|
||||
return groups;
|
||||
};
|
||||
};
|
||||
propertiesPanel.registerProvider(LOW_PRIORITY, this);
|
||||
}
|
||||
|
||||
ConditionsPropertiesProvider.$inject = [
|
||||
'propertiesPanel',
|
||||
'translate',
|
||||
'moddle',
|
||||
'commandStack',
|
||||
'elementRegistry',
|
||||
];
|
||||
|
||||
function createConditionsGroup(element, translate, moddle, commandStack) {
|
||||
return {
|
||||
id: 'conditions',
|
||||
label: translate('Conditions'),
|
||||
entries: conditionGroup(
|
||||
element,
|
||||
moddle,
|
||||
'Condition Expression',
|
||||
'Expression to Execute',
|
||||
commandStack
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
function conditionGroup(element, moddle, label, description, commandStack) {
|
||||
return [
|
||||
{
|
||||
id: `condition_expression`,
|
||||
element,
|
||||
component: ConditionExpressionTextField,
|
||||
moddle,
|
||||
label,
|
||||
description,
|
||||
commandStack,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
function ConditionExpressionTextField(props) {
|
||||
const { element } = props;
|
||||
const { moddle } = props;
|
||||
const { label } = props;
|
||||
|
||||
const debounce = useService('debounceInput');
|
||||
const getValue = () => {
|
||||
const { conditionExpression } = element.businessObject;
|
||||
if (conditionExpression) {
|
||||
return conditionExpression.body;
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
const setValue = (value) => {
|
||||
let { conditionExpressionModdleElement } = element.businessObject;
|
||||
if (!conditionExpressionModdleElement) {
|
||||
conditionExpressionModdleElement = moddle.create('bpmn:Expression');
|
||||
}
|
||||
conditionExpressionModdleElement.body = value;
|
||||
element.businessObject.conditionExpression =
|
||||
conditionExpressionModdleElement;
|
||||
};
|
||||
|
||||
return TextFieldEntry({
|
||||
element,
|
||||
id: `the-id`,
|
||||
label,
|
||||
getValue,
|
||||
setValue,
|
||||
debounce,
|
||||
});
|
||||
}
|
@ -6,6 +6,7 @@ import DataObjectInterceptor from './DataObject/DataObjectInterceptor';
|
||||
import DataObjectRules from './DataObject/DataObjectRules';
|
||||
import DataObjectRenderer from './DataObject/DataObjectRenderer';
|
||||
import DataObjectPropertiesProvider from './DataObject/propertiesPanel/DataObjectPropertiesProvider';
|
||||
import ConditionsPropertiesProvider from './conditions/propertiesPanel/ConditionsPropertiesProvider';
|
||||
import ExtensionsPropertiesProvider from './extensions/propertiesPanel/ExtensionsPropertiesProvider';
|
||||
import MessagesPropertiesProvider from './messages/propertiesPanel/MessagesPropertiesProvider';
|
||||
|
||||
@ -15,6 +16,7 @@ export default {
|
||||
'dataObjectInterceptor',
|
||||
'dataObjectRules',
|
||||
'dataObjectPropertiesProvider',
|
||||
'conditionsPropertiesProvider',
|
||||
'extensionsPropertiesProvider',
|
||||
'messagesPropertiesProvider',
|
||||
'ioPalette',
|
||||
@ -26,6 +28,7 @@ export default {
|
||||
dataObjectRules: ['type', DataObjectRules],
|
||||
dataObjectRenderer: ['type', DataObjectRenderer],
|
||||
dataObjectPropertiesProvider: ['type', DataObjectPropertiesProvider],
|
||||
conditionsPropertiesProvider: ['type', ConditionsPropertiesProvider],
|
||||
extensionsPropertiesProvider: ['type', ExtensionsPropertiesProvider],
|
||||
messagesPropertiesProvider: ['type', MessagesPropertiesProvider],
|
||||
ioPalette: ['type', IoPalette],
|
||||
|
19
app/spiffworkflow/moddle/bpmn.json
Normal file
19
app/spiffworkflow/moddle/bpmn.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "SpiffBpmn",
|
||||
"uri": "http://www.omg.org/spec/BPMN/20100524/MODEL",
|
||||
"prefix": "bpmn",
|
||||
"associations": [],
|
||||
"types": [
|
||||
{
|
||||
"name": "ConditionExpression",
|
||||
"superClass": [ "Element" ],
|
||||
"properties": [
|
||||
{
|
||||
"name": "expression",
|
||||
"isBody": true,
|
||||
"type": "String"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -91,5 +91,3 @@
|
||||
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
|
110
test/spec/bpmn/gateway.bpmn
Normal file
110
test/spec/bpmn/gateway.bpmn
Normal file
@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1qnx3d3" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.0.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.17.0">
|
||||
<bpmn:process id="test_gateway_expression" name="Test Gateway ExpressionPath" isExecutable="true">
|
||||
<bpmn:startEvent id="StartEvent_1">
|
||||
<bpmn:outgoing>Flow_0ik6wwl</bpmn:outgoing>
|
||||
</bpmn:startEvent>
|
||||
<bpmn:sequenceFlow id="Flow_0ik6wwl" sourceRef="StartEvent_1" targetRef="set_var" />
|
||||
<bpmn:sequenceFlow id="Flow_0l0l3ie" sourceRef="set_var" targetRef="choose_path" />
|
||||
<bpmn:scriptTask id="set_var" name="Set Var">
|
||||
<bpmn:incoming>Flow_0ik6wwl</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_0l0l3ie</bpmn:outgoing>
|
||||
<bpmn:script>the_var = 1</bpmn:script>
|
||||
</bpmn:scriptTask>
|
||||
<bpmn:scriptTask id="set_result_var_top" name="Set Result Var Top">
|
||||
<bpmn:incoming>top_flow</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_13gkhe0</bpmn:outgoing>
|
||||
<bpmn:script>result_var = "TOP"</bpmn:script>
|
||||
</bpmn:scriptTask>
|
||||
<bpmn:scriptTask id="set_result_var_bottom" name="Set Result Var Bottom">
|
||||
<bpmn:incoming>bottom_flow</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_1u2cwim</bpmn:outgoing>
|
||||
<bpmn:script>result_var = "BOTTOM"</bpmn:script>
|
||||
</bpmn:scriptTask>
|
||||
<bpmn:endEvent id="top_end" name="Top End">
|
||||
<bpmn:incoming>Flow_13gkhe0</bpmn:incoming>
|
||||
</bpmn:endEvent>
|
||||
<bpmn:sequenceFlow id="Flow_13gkhe0" sourceRef="set_result_var_top" targetRef="top_end" />
|
||||
<bpmn:endEvent id="bottom_end" name="Bottom End">
|
||||
<bpmn:incoming>Flow_1u2cwim</bpmn:incoming>
|
||||
</bpmn:endEvent>
|
||||
<bpmn:sequenceFlow id="Flow_1u2cwim" sourceRef="set_result_var_bottom" targetRef="bottom_end" />
|
||||
<bpmn:exclusiveGateway id="choose_path" name="Choose Path">
|
||||
<bpmn:incoming>Flow_0l0l3ie</bpmn:incoming>
|
||||
<bpmn:outgoing>bottom_flow</bpmn:outgoing>
|
||||
<bpmn:outgoing>top_flow</bpmn:outgoing>
|
||||
</bpmn:exclusiveGateway>
|
||||
<bpmn:sequenceFlow id="bottom_flow" name="Bottom Flow" sourceRef="choose_path" targetRef="set_result_var_bottom" />
|
||||
<bpmn:sequenceFlow id="top_flow" name="Top Flow" sourceRef="choose_path" targetRef="set_result_var_top">
|
||||
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">the_var == 1</bpmn:conditionExpression>
|
||||
</bpmn:sequenceFlow>
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="test_gateway_expression">
|
||||
<bpmndi:BPMNEdge id="Flow_0ik6wwl_di" bpmnElement="Flow_0ik6wwl">
|
||||
<di:waypoint x="215" y="190" />
|
||||
<di:waypoint x="270" y="190" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_0l0l3ie_di" bpmnElement="Flow_0l0l3ie">
|
||||
<di:waypoint x="370" y="190" />
|
||||
<di:waypoint x="425" y="190" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_13gkhe0_di" bpmnElement="Flow_13gkhe0">
|
||||
<di:waypoint x="630" y="110" />
|
||||
<di:waypoint x="692" y="110" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_1u2cwim_di" bpmnElement="Flow_1u2cwim">
|
||||
<di:waypoint x="630" y="250" />
|
||||
<di:waypoint x="692" y="250" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_15p61p3_di" bpmnElement="bottom_flow">
|
||||
<di:waypoint x="450" y="215" />
|
||||
<di:waypoint x="450" y="250" />
|
||||
<di:waypoint x="530" y="250" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds x="435" y="230" width="62" height="14" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_14md7ua_di" bpmnElement="top_flow">
|
||||
<di:waypoint x="450" y="165" />
|
||||
<di:waypoint x="450" y="110" />
|
||||
<di:waypoint x="530" y="110" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds x="443" y="135" width="45" height="14" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
|
||||
<dc:Bounds x="179" y="172" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Activity_0knhsfp_di" bpmnElement="set_var">
|
||||
<dc:Bounds x="270" y="150" width="100" height="80" />
|
||||
<bpmndi:BPMNLabel />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Activity_0b5ya8m_di" bpmnElement="set_result_var_top">
|
||||
<dc:Bounds x="530" y="70" width="100" height="80" />
|
||||
<bpmndi:BPMNLabel />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Activity_157isb4_di" bpmnElement="set_result_var_bottom">
|
||||
<dc:Bounds x="530" y="210" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Event_1vplzst_di" bpmnElement="top_end">
|
||||
<dc:Bounds x="692" y="92" width="36" height="36" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds x="690" y="135" width="41" height="14" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Event_0hcyrv2_di" bpmnElement="bottom_end">
|
||||
<dc:Bounds x="692" y="232" width="36" height="36" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds x="682" y="275" width="58" height="14" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Gateway_1d6xh77_di" bpmnElement="choose_path" isMarkerVisible="true">
|
||||
<dc:Bounds x="425" y="165" width="50" height="50" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds x="498" y="180" width="64" height="14" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
Loading…
x
Reference in New Issue
Block a user