mirror of
https://github.com/sartography/bpmn-js-spiffworkflow.git
synced 2025-02-21 20:18:20 +00:00
* Assure that Data object in pools can be changed to reference other data objects within the same pool.
* In the runnable demo, add the keyboard bindings to copy/paste/delete etc... work. * Added a test for data objects in pools.
This commit is contained in:
parent
f6a79440eb
commit
f40cecc05e
@ -20,6 +20,7 @@ let bpmnModeler;
|
||||
try {
|
||||
bpmnModeler = new BpmnModeler({
|
||||
container: modelerEl,
|
||||
keyboard: { bindTo: document },
|
||||
propertiesPanel: {
|
||||
parent: panelEl,
|
||||
},
|
||||
|
@ -58,7 +58,7 @@ export function findDataObjectReferenceShapes(children, dataObjectId) {
|
||||
}
|
||||
|
||||
export function idToHumanReadableName(id) {
|
||||
const words = id.match(/[A-Za-z][a-z]*/g) || [id];
|
||||
const words = id.match(/[A-Za-z][a-z]*|[0-9]+/g) || [id];
|
||||
return words.map(capitalize).join(' ');
|
||||
|
||||
function capitalize(word) {
|
||||
|
@ -31,7 +31,8 @@ export function DataObjectSelect(props) {
|
||||
|
||||
const setValue = value => {
|
||||
const businessObject = element.businessObject;
|
||||
for (const flowElem of businessObject.$parent.flowElements) {
|
||||
const dataObjects = findDataObjects(businessObject.$parent)
|
||||
for (const flowElem of dataObjects) {
|
||||
if (flowElem.$type === 'bpmn:DataObject' && flowElem.id === value) {
|
||||
commandStack.execute('element.updateModdleProperties', {
|
||||
element,
|
||||
|
66
test/spec/DataObjectInPoolsSpec.js
Normal file
66
test/spec/DataObjectInPoolsSpec.js
Normal file
@ -0,0 +1,66 @@
|
||||
import {
|
||||
BpmnPropertiesPanelModule,
|
||||
BpmnPropertiesProviderModule,
|
||||
} from 'bpmn-js-properties-panel';
|
||||
import TestContainer from 'mocha-test-container-support';
|
||||
import {
|
||||
bootstrapPropertiesPanel,
|
||||
changeInput,
|
||||
expectSelected,
|
||||
findEntry,
|
||||
findSelect,
|
||||
} from './helpers';
|
||||
import spiffModdleExtension from '../../app/spiffworkflow/moddle/spiffworkflow.json';
|
||||
import DataObject from '../../app/spiffworkflow/DataObject';
|
||||
|
||||
describe('Properties Panel for Data Objects', function () {
|
||||
const xml = require('./bpmn/data_objects_in_pools.bpmn').default;
|
||||
let container;
|
||||
|
||||
beforeEach(function () {
|
||||
container = TestContainer.get(this);
|
||||
});
|
||||
|
||||
beforeEach(
|
||||
bootstrapPropertiesPanel(xml, {
|
||||
container,
|
||||
debounceInput: false,
|
||||
additionalModules: [
|
||||
DataObject,
|
||||
BpmnPropertiesPanelModule,
|
||||
BpmnPropertiesProviderModule,
|
||||
],
|
||||
moddleExtensions: {
|
||||
spiffworkflow: spiffModdleExtension,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
it('should allow you to select other data objects within the same participant', async function () {
|
||||
// IF - a data object reference is selected
|
||||
const doREF = await expectSelected('pool1Do1_REF');
|
||||
expect(doREF).to.exist;
|
||||
|
||||
// THEN - a select Data Object section should appear in the properties panel
|
||||
const entry = findEntry('selectDataObject', container);
|
||||
const selector = findSelect(entry);
|
||||
changeInput(selector, 'pool1Do2');
|
||||
// then this data reference object now references that data object.
|
||||
const { businessObject } = doREF;
|
||||
expect(businessObject.get('dataObjectRef').id).to.equal('pool1Do2');
|
||||
});
|
||||
|
||||
it('should NOT allow you to select data objects within other participants', async function () {
|
||||
// IF - a data object reference is selected
|
||||
const doREF = await expectSelected('pool1Do1_REF');
|
||||
expect(doREF).to.exist;
|
||||
|
||||
// THEN - a select Data Object section should appear in the properties panel but pool2Do1 should not be an option
|
||||
const entry = findEntry('selectDataObject', container);
|
||||
const selector = findSelect(entry);
|
||||
expect(selector.length).to.equal(2);
|
||||
expect(selector[0].value === 'pool1Do2');
|
||||
expect(selector[1].value === 'pool1Do1');
|
||||
});
|
||||
|
||||
});
|
@ -6,9 +6,6 @@ import {
|
||||
import { BpmnPropertiesPanelModule, BpmnPropertiesProviderModule } from 'bpmn-js-properties-panel';
|
||||
import spiffModdleExtension from '../../app/spiffworkflow/moddle/spiffworkflow.json';
|
||||
import TestContainer from 'mocha-test-container-support';
|
||||
import DataObjectPropertiesProvider
|
||||
from '../../app/spiffworkflow/DataObject/propertiesPanel/DataObjectPropertiesProvider';
|
||||
import spiffworkflow from '../../app/spiffworkflow';
|
||||
import DataObject from '../../app/spiffworkflow/DataObject';
|
||||
|
||||
describe('Properties Panel for Data Objects', function() {
|
||||
@ -78,4 +75,17 @@ describe('Properties Panel for Data Objects', function() {
|
||||
expect(my_data_ref_1.businessObject.name).to.equal('My Nifty New Name');
|
||||
});
|
||||
|
||||
it('renaming a data object creates a lable without losing the numbers', async function() {
|
||||
|
||||
// IF - a process is selected, and the name of a data object is changed.
|
||||
let entry = findEntry('ProcessTest-dataObj-2-id', container);
|
||||
let textInput = findInput('text', entry);
|
||||
changeInput(textInput, 'MyObject1');
|
||||
let my_data_ref_1 = await expectSelected('my_data_ref_1');
|
||||
|
||||
// THEN - both the data object itself, and the label of any references are updated.
|
||||
expect(my_data_ref_1.businessObject.dataObjectRef.id).to.equal('MyObject1');
|
||||
expect(my_data_ref_1.businessObject.name).to.equal('My Object 1');
|
||||
});
|
||||
|
||||
});
|
||||
|
44
test/spec/bpmn/data_objects_in_pools.bpmn
Normal file
44
test/spec/bpmn/data_objects_in_pools.bpmn
Normal file
@ -0,0 +1,44 @@
|
||||
<?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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_19o7vxg" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.0.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.17.0">
|
||||
<bpmn:collaboration id="Collaboration_0jmlu5k">
|
||||
<bpmn:participant id="Participant_11j98s8" processRef="ProcessTest" />
|
||||
<bpmn:participant id="Participant_1d4d2vr" processRef="Process_1y9rx5q" />
|
||||
</bpmn:collaboration>
|
||||
<bpmn:process id="ProcessTest" name="Process Test" isExecutable="true">
|
||||
<bpmn:dataObjectReference id="pool1Do2_REF" name="Pool 1 Do 2" dataObjectRef="pool1Do2" />
|
||||
<bpmn:dataObject id="pool1Do2" />
|
||||
<bpmn:dataObject id="pool1Do1" />
|
||||
<bpmn:dataObjectReference id="pool1Do2_REF" name="Pool 1 Do 2" dataObjectRef="pool1Do2" />
|
||||
<bpmn:dataObjectReference id="pool1Do1_REF" name="Pool 1 Do 1" dataObjectRef="pool1Do1" />
|
||||
</bpmn:process>
|
||||
<bpmn:process id="Process_1y9rx5q">
|
||||
<bpmn:dataObject id="Pool2do" />
|
||||
<bpmn:dataObjectReference id="pool2Do2" name="Pool 2 Do" dataObjectRef="Pool2do" />
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_0jmlu5k">
|
||||
<bpmndi:BPMNShape id="Participant_11j98s8_di" bpmnElement="Participant_11j98s8" isHorizontal="true">
|
||||
<dc:Bounds x="290" y="270" width="300" height="140" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="pool1Do2_REF_di" bpmnElement="pool1Do2_REF">
|
||||
<dc:Bounds x="462" y="295" width="36" height="50" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds x="453" y="352" width="58" height="14" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="pool1Do1_REF_di" bpmnElement="pool1Do1_REF">
|
||||
<dc:Bounds x="372" y="295" width="36" height="50" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds x="365" y="352" width="58" height="14" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Participant_1d4d2vr_di" bpmnElement="Participant_1d4d2vr" isHorizontal="true">
|
||||
<dc:Bounds x="290" y="430" width="390" height="130" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="DataObjectReference_18xfjvh_di" bpmnElement="DataObjectReference_18xfjvh">
|
||||
<dc:Bounds x="372" y="465" width="36" height="50" />
|
||||
<bpmndi:BPMNLabel />
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
Loading…
x
Reference in New Issue
Block a user