correlation key names can be edited w/ burnettk cullerton

This commit is contained in:
jasquat 2022-08-17 16:01:33 -04:00
parent f5ce011f50
commit 85c2e03b88
3 changed files with 69 additions and 32 deletions

View File

@ -136,7 +136,7 @@ function DataObjectTextField(props) {
} }
}; };
const getValue = (parameter) => { const getValue = () => {
return dataObject.id; return dataObject.id;
}; };

View File

@ -135,15 +135,16 @@ export function findCorrelationKeys(businessObject) {
const currentKeys = rootElement.correlationKeys; const currentKeys = rootElement.correlationKeys;
for (const correlationKey in currentKeys) { for (const correlationKey in currentKeys) {
const currentCorrelation = rootElement.correlationKeys[correlationKey]; const currentCorrelation = rootElement.correlationKeys[correlationKey];
const currentProperty = {}; correlationKeys.push(currentCorrelation);
currentProperty.name = currentCorrelation.name; // const currentProperty = {};
currentProperty.refs = []; // currentProperty.name = currentCorrelation.name;
for (const correlationProperty in currentCorrelation.correlationPropertyRef) { // currentProperty.refs = [];
currentProperty.refs.push( // for (const correlationProperty in currentCorrelation.correlationPropertyRef) {
currentCorrelation.correlationPropertyRef[correlationProperty] // currentProperty.refs.push(
); // currentCorrelation.correlationPropertyRef[correlationProperty]
} // );
correlationKeys.push(currentProperty); // }
// correlationKeys.push(currentProperty);
} }
} }
} }

View File

@ -1,5 +1,5 @@
import { useService } from 'bpmn-js-properties-panel'; import { useService } from 'bpmn-js-properties-panel';
import { SimpleEntry } from '@bpmn-io/properties-panel'; import { SimpleEntry, TextFieldEntry } from '@bpmn-io/properties-panel';
import { findCorrelationKeys, getRoot } from '../MessageHelpers'; import { findCorrelationKeys, getRoot } from '../MessageHelpers';
/** /**
@ -10,17 +10,17 @@ import { findCorrelationKeys, getRoot } from '../MessageHelpers';
export function CorrelationKeysArray(props) { export function CorrelationKeysArray(props) {
const { element, moddle, commandStack } = props; const { element, moddle, commandStack } = props;
const correlationProperties = findCorrelationKeys(element.businessObject); const correlationKeys = findCorrelationKeys(element.businessObject);
const items = correlationProperties.map((correlationProperty, _index) => { const items = correlationKeys.map((correlationKey, index) => {
const id = `correlationGroup-${correlationProperty.name}`; const id = `correlationGroup-${index}`;
return { return {
id, id,
correlationProperty, label: correlationKey.name,
label: correlationProperty.name,
entries: correlationGroup({ entries: correlationGroup({
id, id,
element, element,
correlationProperty, correlationKey,
commandStack,
}), }),
autoFocusEntry: id, autoFocusEntry: id,
}; };
@ -48,38 +48,74 @@ export function CorrelationKeysArray(props) {
return { items, add }; return { items, add };
} }
// <bpmn:correlationKey name="lover"> <--- The CorrelationKeyGroup // <bpmn:correlationKey name="lover"> <--- The correlationGroup
// <bpmn:correlationPropertyRef>lover_name</bpmn:correlationPropertyRef> // <bpmn:correlationPropertyRef>lover_name</bpmn:correlationPropertyRef>
// <bpmn:correlationPropertyRef>lover_instrument</bpmn:correlationPropertyRef> // <bpmn:correlationPropertyRef>lover_instrument</bpmn:correlationPropertyRef>
// </bpmn:correlationKey> // </bpmn:correlationKey>
// <bpmn:correlationKey name="singer" /> // <bpmn:correlationKey name="singer" />
function correlationGroup(props) { function correlationGroup(props) {
const { correlationProperty } = props; const { correlationKey, commandStack } = props;
const id = `correlation-${correlationProperty.name}`; const id = `correlation-${correlationKey.name}`;
return correlationProperty.refs.map((cpRef, _index) => { const entries = [
return { {
id: `${id}-${cpRef.id}-group`, id: `${id}-${correlationKey.name}-key`,
component: CorrelationKeyTextField, component: CorrelationKeyTextField,
correlationProperty, correlationKey,
cpRef, commandStack,
}; },
}); ];
(correlationKey.correlationPropertyRef || []).forEach(
(correlationProperty) => {
entries.push({
id: `${id}-${correlationProperty.id}-group`,
component: CorrelationPropertyText,
correlationProperty,
});
}
);
return entries;
} }
function CorrelationKeyTextField(props) { function CorrelationKeyTextField(props) {
const { id, parameter, cpRef } = props; const { id, element, correlationKey, commandStack } = props;
const debounce = useService('debounceInput');
const setValue = (value) => {
commandStack.execute('element.updateModdleProperties', {
element,
moddleElement: correlationKey,
properties: {
name: value,
},
});
};
const getValue = () => {
return correlationKey.name;
};
return TextFieldEntry({
element,
id: `${id}-textField`,
getValue,
setValue,
debounce,
});
}
function CorrelationPropertyText(props) {
const { id, parameter, correlationProperty } = props;
const debounce = useService('debounceInput'); const debounce = useService('debounceInput');
const getValue = (_parameter) => { const getValue = () => {
return cpRef.id; return correlationProperty.id;
}; };
return SimpleEntry({ return SimpleEntry({
element: parameter, element: parameter,
id: `${id}-textField`, id: `${id}-textField`,
label: cpRef.id, label: correlationProperty.id,
editable: false,
getValue, getValue,
disabled: true, disabled: true,
debounce, debounce,