mirror of
https://github.com/sartography/bpmn-js-spiffworkflow.git
synced 2025-02-23 13:08:11 +00:00
Committing to share w/the machine
This commit is contained in:
parent
265191220c
commit
04175a7516
@ -50,15 +50,39 @@ function processCorrelationProperty(correlationProperty, message) {
|
|||||||
return expressions
|
return expressions
|
||||||
}
|
}
|
||||||
|
|
||||||
export function findCorrelationKeys(element) {
|
export function findCorrelationProperties(element) {
|
||||||
const root = getRoot(element);
|
const root = getRoot(element);
|
||||||
const correlationProperties = [];
|
const correlationProperties = [];
|
||||||
for (const rootElement of root.rootElements) {
|
for (const rootElement of root.rootElements) {
|
||||||
if (rootElement.$type === 'bpmn:CorrelationProperty') {
|
if (rootElement.$type === 'bpmn:CorrelationProperty') {
|
||||||
correlationProperties.push(rootElement);
|
correlationProperties.push(rootElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return correlationProperties;
|
return correlationProperties
|
||||||
|
}
|
||||||
|
|
||||||
|
export function findCorrelationKeys(element) {
|
||||||
|
const root = getRoot(element);
|
||||||
|
const correlationKeys = [];
|
||||||
|
for (const rootElement of root.rootElements) {
|
||||||
|
if (rootElement.$type === 'bpmn:Collaboration') {
|
||||||
|
const currentKeys = rootElement.correlationKeys;
|
||||||
|
for (let correlationKey in currentKeys) {
|
||||||
|
let correlationProperties = [];
|
||||||
|
const currentCorrelation = rootElement.correlationKeys[correlationKey];
|
||||||
|
let currentProperty = {}
|
||||||
|
currentProperty.name = currentCorrelation.name;
|
||||||
|
currentProperty.refs = [];
|
||||||
|
for (let correlationProperty in currentCorrelation.correlationPropertyRef) {
|
||||||
|
console.log("findCorrelationKeys: propertyRef", correlationProperty);
|
||||||
|
currentProperty.refs.push(currentCorrelation.correlationPropertyRef[correlationProperty]);
|
||||||
|
}
|
||||||
|
correlationKeys.push(currentProperty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return correlationKeys
|
||||||
}
|
}
|
||||||
|
|
||||||
export function findMessageModdleElements(element) {
|
export function findMessageModdleElements(element) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { useService } from 'bpmn-js-properties-panel';
|
import { useService } from 'bpmn-js-properties-panel';
|
||||||
import {
|
import {
|
||||||
isTextFieldEntryEdited,
|
isTextFieldEntryEdited, ListGroup,
|
||||||
TextFieldEntry,
|
TextFieldEntry,
|
||||||
} from '@bpmn-io/properties-panel';
|
} from '@bpmn-io/properties-panel';
|
||||||
import { without } from 'min-dash';
|
import { without } from 'min-dash';
|
||||||
@ -9,7 +9,7 @@ import {
|
|||||||
findDataObjects,
|
findDataObjects,
|
||||||
findDataReferenceShapes,
|
findDataReferenceShapes,
|
||||||
} from '../../DataObject/DataObjectHelpers';
|
} from '../../DataObject/DataObjectHelpers';
|
||||||
import {findCorrelationKeys} from '../MessageHelpers';
|
import { findCorrelationProperties, findCorrelationKeys, getRoot } from '../MessageHelpers';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -26,15 +26,17 @@ export function CorrelationKeysArray(props) {
|
|||||||
|
|
||||||
const correlationProperties = findCorrelationKeys(element.businessObject);
|
const correlationProperties = findCorrelationKeys(element.businessObject);
|
||||||
const items = correlationProperties.map((correlationProperty, index) => {
|
const items = correlationProperties.map((correlationProperty, index) => {
|
||||||
const id = `correlation-${correlationProperty.id}`;
|
const id = `correlationGroup-${correlationProperty.name}`;
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
label: correlationProperty.id,
|
correlationProperty,
|
||||||
entries: CorrelationKeyGroup({
|
label: correlationProperty.name,
|
||||||
id,
|
entries: correlationProperty.refs,
|
||||||
element,
|
// entries: correlationGroup({
|
||||||
correlationProperty,
|
// id,
|
||||||
}),
|
// element,
|
||||||
|
// correlationProperty,
|
||||||
|
// }),
|
||||||
autoFocusEntry: id,
|
autoFocusEntry: id,
|
||||||
// remove: removeFactory({ element, correlationProperty, commandStack, elementRegistry })
|
// remove: removeFactory({ element, correlationProperty, commandStack, elementRegistry })
|
||||||
};
|
};
|
||||||
@ -42,19 +44,14 @@ export function CorrelationKeysArray(props) {
|
|||||||
|
|
||||||
function add(event) {
|
function add(event) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
const newCorrelationProperty = moddle.create('bpmn:CorrelationProperty');
|
const newCorrelationKey = moddle.create('bpmn:CorrelationKey');
|
||||||
const newElements = correlationProperties;
|
newCorrelationKey.name = moddle.ids.nextPrefixed('CorrelationKey_');
|
||||||
newCorrelationProperty.id = moddle.ids.nextPrefixed('CorrelationProperty_');
|
console.log('newCorrelationKey', newCorrelationKey);
|
||||||
newElements.push(newCorrelationProperty);
|
|
||||||
console.log('element', element);
|
|
||||||
commandStack.execute('element.updateModdleProperties', {
|
commandStack.execute('element.updateModdleProperties', {
|
||||||
element,
|
element,
|
||||||
moddleElement: element.businessObject,
|
moddleElement: element.businessObject,
|
||||||
properties: {
|
newElements: newCorrelationKey
|
||||||
flowElements: newElements,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
// moddle.updateModdleProperties(element, updatedBusinessObject, update);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { items, add };
|
return { items, add };
|
||||||
@ -87,6 +84,21 @@ function removeFactory(props) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function correlationGroup(props) {
|
||||||
|
const { element, correlationProperty } = props;
|
||||||
|
const id = `correlation-${correlationProperty.id}`;
|
||||||
|
return {
|
||||||
|
id,
|
||||||
|
label: correlationProperty.id,
|
||||||
|
entries: CorrelationKeyGroup({
|
||||||
|
id,
|
||||||
|
element,
|
||||||
|
correlationProperty,
|
||||||
|
}),
|
||||||
|
autoFocusEntry: id,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function CorrelationKeyGroup(props) {
|
function CorrelationKeyGroup(props) {
|
||||||
const { idPrefix, correlationProperty } = props;
|
const { idPrefix, correlationProperty } = props;
|
||||||
|
|
||||||
@ -132,13 +144,14 @@ function CorrelationKeyTextField(props) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getValue = (parameter) => {
|
const getValue = (parameter) => {
|
||||||
return correlationProperty.name;
|
return correlationProperty.refs;
|
||||||
};
|
};
|
||||||
|
|
||||||
return TextFieldEntry({
|
return ListGroup({
|
||||||
element: parameter,
|
element: parameter,
|
||||||
|
items: correlationProperty.refs,
|
||||||
id: `${idPrefix}-textField`,
|
id: `${idPrefix}-textField`,
|
||||||
label: 'Correlation Key',
|
label: 'Correlation Properties',
|
||||||
getValue,
|
getValue,
|
||||||
setValue,
|
setValue,
|
||||||
debounce,
|
debounce,
|
||||||
|
@ -31,12 +31,38 @@ export function MessageCorrelationsArray(props) {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
function add(event) {}
|
function add(event) {
|
||||||
|
event.stopPropagation();
|
||||||
|
const newRetrievalExpression = moddle.create('bpmn:CorrelationPropertyRetrievalExpression');
|
||||||
|
const newElements = formalExpressions;
|
||||||
|
newRetrievalExpression.messageRef = element.businessObject.messageRef;
|
||||||
|
newElements.push(newRetrievalExpression);
|
||||||
|
console.log('element', element);
|
||||||
|
commandStack.execute('element.updateModdleProperties', {
|
||||||
|
element,
|
||||||
|
moddleElement: element.businessObject,
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return { items, add }
|
return { items, add }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function MessageKeyGroup(props) {
|
||||||
|
const { idPrefix, keys } = props;
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
id: `${idPrefix}-group`,
|
||||||
|
component: MessageCorrelationGroup,
|
||||||
|
isEdited: isTextFieldEntryEdited,
|
||||||
|
idPrefix,
|
||||||
|
formalExpression: keys
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
function MessageCorrelationGroup(props) {
|
function MessageCorrelationGroup(props) {
|
||||||
const { idPrefix, formalExpression } = props;
|
const { idPrefix, formalExpression } = props;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import TestContainer from 'mocha-test-container-support';
|
import TestContainer from 'mocha-test-container-support';
|
||||||
import { bootstrapPropertiesPanel, expectSelected, findEntry, findGroupEntry, findInput, findSelect, findTextarea } from './helpers';
|
import { bootstrapPropertiesPanel, expectSelected, findEntry, findGroupEntry, findInput, findSelect, findTextarea, findButtonByClass, pressButton, findDivByClass } from './helpers';
|
||||||
import { BpmnPropertiesPanelModule, BpmnPropertiesProviderModule } from 'bpmn-js-properties-panel';
|
import { BpmnPropertiesPanelModule, BpmnPropertiesProviderModule } from 'bpmn-js-properties-panel';
|
||||||
import spiffModdleExtension from '../../app/spiffworkflow/moddle/spiffworkflow.json';
|
import spiffModdleExtension from '../../app/spiffworkflow/moddle/spiffworkflow.json';
|
||||||
import messages from '../../app/spiffworkflow/messages';
|
import messages from '../../app/spiffworkflow/messages';
|
||||||
@ -91,4 +91,35 @@ describe('Messages should work', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should add a new correlation when clicked', async function() {
|
||||||
|
|
||||||
|
// Select the second Task
|
||||||
|
const send_shape = await expectSelected('ActivitySendLetter');
|
||||||
|
expect(send_shape, "Can't find Send Task").to.exist;
|
||||||
|
|
||||||
|
const buttonClass = "bio-properties-panel-group-header-button bio-properties-panel-add-entry";
|
||||||
|
let button = findButtonByClass(buttonClass, container);
|
||||||
|
pressButton(button);
|
||||||
|
|
||||||
|
console.log(button);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add a new Correlation Key when clicked', async function() {
|
||||||
|
const divClass = "bio-properties-panel-list";
|
||||||
|
const divs = findDivByClass(divClass, container);
|
||||||
|
|
||||||
|
const buttonClass = "bio-properties-panel-group-header-button bio-properties-panel-add-entry";
|
||||||
|
let button = findButtonByClass(buttonClass, container);
|
||||||
|
pressButton(button);
|
||||||
|
|
||||||
|
// THEN - a select Data Object section should appear in the properties panel
|
||||||
|
let entry = findGroupEntry('correlation_keys', container);
|
||||||
|
expect(entry).to.exist;
|
||||||
|
|
||||||
|
let divs2 = findDivByClass(divClass, container);
|
||||||
|
|
||||||
|
console.log(button);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -10,8 +10,6 @@
|
|||||||
<bpmn:messageFlow id="Flow_0vonyt2" sourceRef="Participant_1tlkvw1" targetRef="Event_06829ki" />
|
<bpmn:messageFlow id="Flow_0vonyt2" sourceRef="Participant_1tlkvw1" targetRef="Event_06829ki" />
|
||||||
<bpmn:correlationKey name="lover">
|
<bpmn:correlationKey name="lover">
|
||||||
<bpmn:correlationPropertyRef>lover_name</bpmn:correlationPropertyRef>
|
<bpmn:correlationPropertyRef>lover_name</bpmn:correlationPropertyRef>
|
||||||
</bpmn:correlationKey>
|
|
||||||
<bpmn:correlationKey name="instrument">
|
|
||||||
<bpmn:correlationPropertyRef>lover_instrument</bpmn:correlationPropertyRef>
|
<bpmn:correlationPropertyRef>lover_instrument</bpmn:correlationPropertyRef>
|
||||||
</bpmn:correlationKey>
|
</bpmn:correlationKey>
|
||||||
<bpmn:correlationKey name="singer" />
|
<bpmn:correlationKey name="singer" />
|
||||||
|
@ -119,6 +119,10 @@ export function findButton(id, container) {
|
|||||||
return domQuery(`button[id='${ id }']`, container);
|
return domQuery(`button[id='${ id }']`, container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function findButtonByClass(buttonClass, container) {
|
||||||
|
return domQuery(`button[class='${ buttonClass }']`, container)
|
||||||
|
}
|
||||||
|
|
||||||
export function findSelect(container) {
|
export function findSelect(container) {
|
||||||
return domQuery('select', container);
|
return domQuery('select', container);
|
||||||
}
|
}
|
||||||
@ -131,6 +135,10 @@ export function pressButton(button) {
|
|||||||
fireEvent.click(button);
|
fireEvent.click(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function findDivByClass(divClass, container) {
|
||||||
|
return domQuery(`div[class='${ divClass }']`, container)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user