mirror of
https://github.com/sartography/bpmn-js-spiffworkflow.git
synced 2025-02-23 04:58:08 +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
|
||||
}
|
||||
|
||||
export function findCorrelationKeys(element) {
|
||||
export function findCorrelationProperties(element) {
|
||||
const root = getRoot(element);
|
||||
const correlationProperties = [];
|
||||
for (const rootElement of root.rootElements) {
|
||||
if (rootElement.$type === 'bpmn:CorrelationProperty') {
|
||||
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) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { useService } from 'bpmn-js-properties-panel';
|
||||
import {
|
||||
isTextFieldEntryEdited,
|
||||
isTextFieldEntryEdited, ListGroup,
|
||||
TextFieldEntry,
|
||||
} from '@bpmn-io/properties-panel';
|
||||
import { without } from 'min-dash';
|
||||
@ -9,7 +9,7 @@ import {
|
||||
findDataObjects,
|
||||
findDataReferenceShapes,
|
||||
} 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 items = correlationProperties.map((correlationProperty, index) => {
|
||||
const id = `correlation-${correlationProperty.id}`;
|
||||
const id = `correlationGroup-${correlationProperty.name}`;
|
||||
return {
|
||||
id,
|
||||
label: correlationProperty.id,
|
||||
entries: CorrelationKeyGroup({
|
||||
id,
|
||||
element,
|
||||
correlationProperty,
|
||||
}),
|
||||
correlationProperty,
|
||||
label: correlationProperty.name,
|
||||
entries: correlationProperty.refs,
|
||||
// entries: correlationGroup({
|
||||
// id,
|
||||
// element,
|
||||
// correlationProperty,
|
||||
// }),
|
||||
autoFocusEntry: id,
|
||||
// remove: removeFactory({ element, correlationProperty, commandStack, elementRegistry })
|
||||
};
|
||||
@ -42,19 +44,14 @@ export function CorrelationKeysArray(props) {
|
||||
|
||||
function add(event) {
|
||||
event.stopPropagation();
|
||||
const newCorrelationProperty = moddle.create('bpmn:CorrelationProperty');
|
||||
const newElements = correlationProperties;
|
||||
newCorrelationProperty.id = moddle.ids.nextPrefixed('CorrelationProperty_');
|
||||
newElements.push(newCorrelationProperty);
|
||||
console.log('element', element);
|
||||
const newCorrelationKey = moddle.create('bpmn:CorrelationKey');
|
||||
newCorrelationKey.name = moddle.ids.nextPrefixed('CorrelationKey_');
|
||||
console.log('newCorrelationKey', newCorrelationKey);
|
||||
commandStack.execute('element.updateModdleProperties', {
|
||||
element,
|
||||
moddleElement: element.businessObject,
|
||||
properties: {
|
||||
flowElements: newElements,
|
||||
},
|
||||
newElements: newCorrelationKey
|
||||
});
|
||||
// moddle.updateModdleProperties(element, updatedBusinessObject, update);
|
||||
}
|
||||
|
||||
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) {
|
||||
const { idPrefix, correlationProperty } = props;
|
||||
|
||||
@ -132,13 +144,14 @@ function CorrelationKeyTextField(props) {
|
||||
};
|
||||
|
||||
const getValue = (parameter) => {
|
||||
return correlationProperty.name;
|
||||
return correlationProperty.refs;
|
||||
};
|
||||
|
||||
return TextFieldEntry({
|
||||
return ListGroup({
|
||||
element: parameter,
|
||||
items: correlationProperty.refs,
|
||||
id: `${idPrefix}-textField`,
|
||||
label: 'Correlation Key',
|
||||
label: 'Correlation Properties',
|
||||
getValue,
|
||||
setValue,
|
||||
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 }
|
||||
|
||||
}
|
||||
|
||||
function MessageKeyGroup(props) {
|
||||
const { idPrefix, keys } = props;
|
||||
|
||||
return [
|
||||
{
|
||||
id: `${idPrefix}-group`,
|
||||
component: MessageCorrelationGroup,
|
||||
isEdited: isTextFieldEntryEdited,
|
||||
idPrefix,
|
||||
formalExpression: keys
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
function MessageCorrelationGroup(props) {
|
||||
const { idPrefix, formalExpression } = props;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
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 spiffModdleExtension from '../../app/spiffworkflow/moddle/spiffworkflow.json';
|
||||
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:correlationKey name="lover">
|
||||
<bpmn:correlationPropertyRef>lover_name</bpmn:correlationPropertyRef>
|
||||
</bpmn:correlationKey>
|
||||
<bpmn:correlationKey name="instrument">
|
||||
<bpmn:correlationPropertyRef>lover_instrument</bpmn:correlationPropertyRef>
|
||||
</bpmn:correlationKey>
|
||||
<bpmn:correlationKey name="singer" />
|
||||
|
@ -119,6 +119,10 @@ export function findButton(id, container) {
|
||||
return domQuery(`button[id='${ id }']`, container);
|
||||
}
|
||||
|
||||
export function findButtonByClass(buttonClass, container) {
|
||||
return domQuery(`button[class='${ buttonClass }']`, container)
|
||||
}
|
||||
|
||||
export function findSelect(container) {
|
||||
return domQuery('select', container);
|
||||
}
|
||||
@ -131,6 +135,10 @@ export function pressButton(button) {
|
||||
fireEvent.click(button);
|
||||
}
|
||||
|
||||
export function findDivByClass(divClass, container) {
|
||||
return domQuery(`div[class='${ divClass }']`, container)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user