Handle Manual Changes

This commit is contained in:
theaubmov 2023-12-02 16:30:58 +01:00
parent f3d5a94c99
commit cc2482ad43
2 changed files with 36 additions and 17 deletions

View File

@ -1,13 +1,10 @@
import { is, isAny } from 'bpmn-js/lib/util/ModelUtil';
import { ListGroup, isTextFieldEntryEdited, TextFieldEntry } from '@bpmn-io/properties-panel';
import { useService } from 'bpmn-js-properties-panel';
import { is } from 'bpmn-js/lib/util/ModelUtil';
import { findDataObject, findDataObjectReferenceShapes, findDataObjects } from './DataObjectHelpers';
const LOW_PRIORITY = 500;
export default function DataObjectLabelEditingProvider(eventBus, canvas, directEditing, commandStack, modeling) {
console.log('DataObjectLabelEditingProvider', eventBus, canvas, directEditing, commandStack, modeling, this);
directEditing.registerProvider(LOW_PRIORITY, this);
let el;
@ -21,27 +18,50 @@ export default function DataObjectLabelEditingProvider(eventBus, canvas, directE
modeling.updateLabel(element, label);
directEditing.activate(element);
el = element;
console.log('IS ACTIVE', directEditing.isActive(element))
}
});
eventBus.on('directEditing.activate', async function (event) {
console.log('directEditing.activate', event);
const { element } = event.active;
if (is(element.businessObject, 'bpmn:DataObjectReference')) {
console.log('directEditing.activate bpmn:DataObjectReference', element, directEditing);
// modeling.updateLabel(element, 'newLabel');
// directEditing.activate(element);
}
if (is(element.businessObject, 'bpmn:DataObjectReference')) { }
});
eventBus.on('directEditing.complete', function (event) {
const element = el;
if (element && is(element.businessObject, 'bpmn:DataObjectReference')) {
const process = element.parent.businessObject;
const dataObject = findDataObject(process, element.businessObject.dataObjectRef.id);
const dataState = element.businessObject.dataState && element.businessObject.dataState.name;
let newLabel = element.businessObject.name;
commandStack.execute('element.updateModdleProperties', {
element,
moddleElement: dataObject,
properties: {
name: newLabel,
},
});
// Update references name
const references = findDataObjectReferenceShapes(element.parent.children, dataObject.id);
for (const ref of references) {
const stateName = ref.businessObject.dataState && ref.businessObject.dataState.name ? ref.businessObject.dataState.name : '';
const newName = stateName ? `${newLabel} [${stateName}]` : newLabel;
commandStack.execute('element.updateProperties', {
element: ref,
moddleElement: ref.businessObject,
properties: {
name: newName,
},
changed: [ref],
});
}
// Append the data state if it exists
if (dataState) {
newLabel += ` [${dataState}]`;
@ -51,6 +71,7 @@ export default function DataObjectLabelEditingProvider(eventBus, canvas, directE
modeling.updateLabel(element, newLabel);
el = undefined;
}
});

View File

@ -13,8 +13,7 @@ export default function DataObjectPropertiesProvider(
commandStack,
elementRegistry,
modeling,
bpmnFactory,
eventBus
bpmnFactory
) {
this.getGroups = function (element) {
return function (groups) {
@ -55,8 +54,7 @@ DataObjectPropertiesProvider.$inject = [
'commandStack',
'elementRegistry',
'modeling',
'bpmnFactory',
'eventBus'
'bpmnFactory'
];
/**