Merge pull request #57 from sartography/feature/dataObject-naming-with-dataState

DataObject reference Name Enhanced with dataState
This commit is contained in:
Dan Funk 2023-12-05 13:21:20 -05:00 committed by GitHub
commit b00abf00c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 396 additions and 69 deletions

View File

@ -5,7 +5,7 @@
*/
export function findDataObjects(parent, dataObjects) {
if (typeof(dataObjects) === 'undefined')
if (typeof (dataObjects) === 'undefined')
dataObjects = [];
let process;
if (!parent) {
@ -18,7 +18,7 @@ export function findDataObjects(parent, dataObjects) {
if (process.$type === 'bpmn:SubProcess')
findDataObjects(process.$parent, dataObjects);
}
if (typeof(process.flowElements) !== 'undefined') {
if (typeof (process.flowElements) !== 'undefined') {
for (const element of process.flowElements) {
if (element.$type === 'bpmn:DataObject')
dataObjects.push(element);
@ -68,3 +68,19 @@ export function idToHumanReadableName(id) {
return word.charAt(0).toUpperCase() + word.substring(1);
}
}
export function updateDataObjectReferencesName(parent, nameValue, dataObjectId, commandStack) {
const references = findDataObjectReferenceShapes(parent.children, dataObjectId);
for (const ref of references) {
const stateName = ref.businessObject.dataState && ref.businessObject.dataState.name ? ref.businessObject.dataState.name : '';
const newName = stateName ? `${nameValue} [${stateName}]` : nameValue;
commandStack.execute('element.updateProperties', {
element: ref,
moddleElement: ref.businessObject,
properties: {
name: newName,
},
changed: [ref],
});
}
}

View File

@ -87,6 +87,7 @@ export default class DataObjectInterceptor extends CommandInterceptor {
dataObject = existingDataObjects[0];
} else {
dataObject = bpmnFactory.create('bpmn:DataObject');
dataObject.name = idToHumanReadableName(dataObject.id);
}
// set the reference to the DataObject
shape.businessObject.dataObjectRef = dataObject;
@ -107,7 +108,7 @@ export default class DataObjectInterceptor extends CommandInterceptor {
element: shape,
moddleElement: shape.businessObject,
properties: {
name: idToHumanReadableName(shape.businessObject.dataObjectRef.id),
name: shape.businessObject.dataObjectRef.name,
},
});
}
@ -137,6 +138,7 @@ export default class DataObjectInterceptor extends CommandInterceptor {
}
}
});
}
}

View File

@ -0,0 +1,62 @@
import { is } from 'bpmn-js/lib/util/ModelUtil';
import { findDataObject, updateDataObjectReferencesName } from './DataObjectHelpers';
export default function DataObjectLabelEditingProvider(eventBus, directEditing, commandStack, modeling) {
let el;
// listen to dblclick on non-root elements
eventBus.on('element.dblclick', function (event) {
const { element } = event;
if (is(element.businessObject, 'bpmn:DataObjectReference')) {
let label = element.businessObject.name;
label = label.replace(/\s*\[.*?\]\s*$/, '');
modeling.updateLabel(element, label);
directEditing.activate(element);
el = element;
}
});
eventBus.on('directEditing.complete', function (event) {
const element = el;
if (element && is(element.businessObject, 'bpmn:DataObjectReference')) {
setTimeout(() => {
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
updateDataObjectReferencesName(element.parent, newLabel, dataObject.id, commandStack);
// Append the data state if it exists
if (dataState) {
newLabel += ` [${dataState}]`;
}
// Update the label with the data state
modeling.updateLabel(element, newLabel);
el = undefined;
}, 100);
}
});
}
DataObjectLabelEditingProvider.$inject = [
'eventBus',
'directEditing',
'commandStack',
'modeling'
];

View File

@ -3,17 +3,18 @@ import DataObjectRules from './DataObjectRules';
import RulesModule from 'diagram-js/lib/features/rules';
import DataObjectRenderer from './DataObjectRenderer';
import DataObjectPropertiesProvider from './propertiesPanel/DataObjectPropertiesProvider';
import DataObjectLabelEditingProvider from './DataObjectLabelEditingProvider';
export default {
__depends__: [
RulesModule
],
__init__: [ 'dataInterceptor', 'dataObjectRules', 'dataObjectRenderer', 'dataObjectPropertiesProvider' ],
__init__: [ 'dataInterceptor', 'dataObjectRules', 'dataObjectRenderer', 'dataObjectPropertiesProvider', 'dataObjectLabelEditingProvider' ],
dataInterceptor: [ 'type', DataObjectInterceptor ],
dataObjectRules: [ 'type', DataObjectRules ],
dataObjectRenderer: [ 'type', DataObjectRenderer ],
dataObjectPropertiesProvider: [ 'type', DataObjectPropertiesProvider ]
dataObjectPropertiesProvider: [ 'type', DataObjectPropertiesProvider ],
dataObjectLabelEditingProvider: [ 'type', DataObjectLabelEditingProvider ]
};

View File

@ -8,7 +8,9 @@ import { is } from 'bpmn-js/lib/util/ModelUtil';
import {
findDataObjects,
findDataObjectReferenceShapes,
updateDataObjectReferencesName,
idToHumanReadableName,
findDataObject,
} from '../DataObjectHelpers';
/**
@ -57,6 +59,7 @@ export function DataObjectArray(props) {
const newDataObject = moddle.create('bpmn:DataObject');
const newElements = process.get('flowElements');
newDataObject.id = moddle.ids.nextPrefixed('DataObject_');
newDataObject.name = idToHumanReadableName(newDataObject.id);
newDataObject.$parent = process;
newElements.push(newDataObject);
commandStack.execute('element.updateModdleProperties', {
@ -102,6 +105,13 @@ function DataObjectGroup(props) {
idPrefix,
dataObject,
},
{
id: `${idPrefix}-dataObjectName`,
component: DataObjectNameTextField,
isEdited: isTextFieldEntryEdited,
idPrefix,
dataObject,
}
];
}
@ -112,25 +122,26 @@ function DataObjectTextField(props) {
const debounce = useService('debounceInput');
const setValue = (value) => {
commandStack.execute('element.updateModdleProperties', {
element,
moddleElement: dataObject,
properties: {
id: value,
},
});
try {
// Check if new dataObject Id is not unique
if(findDataObject(element.businessObject, value) !== undefined){
alert('Data Object ID Should be unique');
return;
}
// Also update the label of all the references
const references = findDataObjectReferenceShapes(element.children, dataObject.id);
for (const ref of references) {
commandStack.execute('element.updateProperties', {
element: ref,
moddleElement: ref.businessObject,
// let doName = idToHumanReadableName(value);
commandStack.execute('element.updateModdleProperties', {
element,
moddleElement: dataObject,
properties: {
name: idToHumanReadableName(value),
id: value,
// name: doName
},
changed: [ref], // everything is already marked as changed, don't recalculate.
});
// Update references name
// updateDataObjectReferencesName(element, doName, value, commandStack);
} catch (error) {
console.log('Set Value Error : ', error);
}
};
@ -147,3 +158,38 @@ function DataObjectTextField(props) {
debounce,
});
}
function DataObjectNameTextField(props) {
const { idPrefix, element, parameter, dataObject } = props;
const commandStack = useService('commandStack');
const debounce = useService('debounceInput');
const setValue = (value) => {
// Update references name
updateDataObjectReferencesName(element, value, dataObject.id, commandStack);
// Update dataObject name
commandStack.execute('element.updateModdleProperties', {
element,
moddleElement: dataObject,
properties: {
name: value,
},
});
};
const getValue = () => {
return dataObject.name;
};
return TextFieldEntry({
element: parameter,
id: `${idPrefix}-name`,
label: 'Data Object Name',
getValue,
setValue,
debounce,
});
}

View File

@ -1,7 +1,8 @@
import { is, isAny } from 'bpmn-js/lib/util/ModelUtil';
import { ListGroup, isTextFieldEntryEdited } from '@bpmn-io/properties-panel';
import { ListGroup, isTextFieldEntryEdited, TextFieldEntry } from '@bpmn-io/properties-panel';
import { DataObjectSelect } from './DataObjectSelect';
import { DataObjectArray } from './DataObjectArray';
import { useService } from 'bpmn-js-properties-panel';
const LOW_PRIORITY = 500;
@ -10,13 +11,20 @@ export default function DataObjectPropertiesProvider(
translate,
moddle,
commandStack,
elementRegistry
elementRegistry,
modeling,
bpmnFactory
) {
this.getGroups = function (element) {
return function (groups) {
if (is(element, 'bpmn:DataObjectReference')) {
const generalGroup = groups.find(group => group.id === 'general');
if (generalGroup) {
generalGroup.entries = generalGroup.entries.filter(entry => entry.id !== 'name');
}
groups.push(
createDataObjectSelector(element, translate, moddle, commandStack)
createDataObjectSelector(element, translate, moddle, commandStack, modeling, bpmnFactory)
);
}
if (
@ -45,6 +53,8 @@ DataObjectPropertiesProvider.$inject = [
'moddle',
'commandStack',
'elementRegistry',
'modeling',
'bpmnFactory'
];
/**
@ -54,7 +64,7 @@ DataObjectPropertiesProvider.$inject = [
* @param moddle
* @returns entries
*/
function createDataObjectSelector(element, translate, moddle, commandStack) {
function createDataObjectSelector(element, translate, moddle, commandStack, modeling, bpmnFactory) {
return {
id: 'data_object_properties',
label: translate('Data Object Properties'),
@ -67,6 +77,15 @@ function createDataObjectSelector(element, translate, moddle, commandStack) {
moddle,
commandStack,
},
{
id: 'selectDataState',
element,
component: createDataStateTextField,
moddle,
commandStack,
modeling,
bpmnFactory
}
],
};
}
@ -98,3 +117,61 @@ function createDataObjectEditor(
return dataObjectArray;
}
}
function createDataStateTextField(props) {
const { id, element, commandStack, modeling, bpmnFactory } = props;
const debounce = useService('debounceInput');
const setValue = (value) => {
const businessObject = element.businessObject;
// Check if the element is a DataObjectReference
if (!is(businessObject, 'bpmn:DataObjectReference')) {
console.error('The element is not a DataObjectReference.');
return;
}
// Create a new DataState or update the existing one
let dataState = businessObject.dataState;
if (!dataState) {
dataState = bpmnFactory.create('bpmn:DataState', {
id: 'DataState_' + businessObject.id,
name: value
});
} else {
dataState.name = value;
}
// Update the DataObjectReference with new or updated DataState
modeling.updateProperties(element, {
dataState: dataState
});
// Extract the original name
const originalName = businessObject.name.split(' [')[0];
// Update the label of the DataObjectReference
const newName = (value) ? originalName + ' [' + value + ']' : originalName;
modeling.updateProperties(element, {
name: newName
});
};
const getValue = () => {
const businessObject = element.businessObject;
return businessObject.dataState ? businessObject.dataState.name : '';
};
return TextFieldEntry({
element,
id: `${id}-textField`,
name: 'spiffworkflow:DataStateLabel',
label: 'Enter Data State of this reference?',
description: 'Enter the Data State for this reference.',
getValue,
setValue,
debounce,
});
}

View File

@ -1,6 +1,6 @@
import {useService } from 'bpmn-js-properties-panel';
import { useService } from 'bpmn-js-properties-panel';
import { SelectEntry } from '@bpmn-io/properties-panel';
import {findDataObjects, idToHumanReadableName} from '../DataObjectHelpers';
import { findDataObjects } from '../DataObjectHelpers';
/**
* Finds the value of the given type within the extensionElements
@ -32,20 +32,25 @@ export function DataObjectSelect(props) {
const setValue = value => {
const businessObject = element.businessObject;
const dataObjects = findDataObjects(businessObject.$parent)
for (const flowElem of dataObjects) {
if (flowElem.$type === 'bpmn:DataObject' && flowElem.id === value) {
for (const dataObject of dataObjects) {
if (dataObject.$type === 'bpmn:DataObject' && dataObject.id === value) {
commandStack.execute('element.updateModdleProperties', {
element,
element: element,
moddleElement: businessObject,
properties: {
dataObjectRef: flowElem
dataObjectRef: dataObject
}
});
// Construct the new name by : the dataObject name and the current state
const stateName = businessObject.dataState && businessObject.dataState.name ? businessObject.dataState.name : '';
const newName = stateName ? `${dataObject.name} [${stateName}]` : dataObject.name;
// Update the name property of the DataObjectReference
commandStack.execute('element.updateProperties', {
element,
moddleElement: businessObject,
element: element,
properties: {
'name': idToHumanReadableName(flowElem.id)
name: newName
}
});
}
@ -58,7 +63,7 @@ export function DataObjectSelect(props) {
let dataObjects = findDataObjects(parent);
let options = [];
dataObjects.forEach(dataObj => {
options.push({label: dataObj.id, value: dataObj.id})
options.push({ label: dataObj.id, value: dataObj.id })
});
return options;
}
@ -68,9 +73,9 @@ export function DataObjectSelect(props) {
element={element}
description={"Select the Data Object this represents."}
label={"Which Data Object does this reference?"}
getValue={ getValue }
setValue={ setValue }
getOptions={ getOptions }
getValue={getValue}
setValue={setValue}
getOptions={getOptions}
debounce={debounce}
/>;

View File

@ -6,6 +6,7 @@ import DataObjectInterceptor from './DataObject/DataObjectInterceptor';
import DataObjectRules from './DataObject/DataObjectRules';
import DataObjectRenderer from './DataObject/DataObjectRenderer';
import DataObjectPropertiesProvider from './DataObject/propertiesPanel/DataObjectPropertiesProvider';
import DataObjectLabelEditingProvider from './DataObject/DataObjectLabelEditingProvider';
import DataStorePropertiesProvider from './DataStoreReference/propertiesPanel/DataStorePropertiesProvider';
import DataStoreInterceptor from './DataStoreReference/DataStoreInterceptor';
import ConditionsPropertiesProvider from './conditions/propertiesPanel/ConditionsPropertiesProvider';
@ -24,6 +25,7 @@ export default {
'dataObjectInterceptor',
'dataObjectRules',
'dataObjectPropertiesProvider',
'dataObjectLabelEditingProvider',
'dataStoreInterceptor',
'dataStorePropertiesProvider',
'conditionsPropertiesProvider',
@ -44,6 +46,7 @@ export default {
dataObjectRules: ['type', DataObjectRules],
dataObjectRenderer: ['type', DataObjectRenderer],
dataObjectPropertiesProvider: ['type', DataObjectPropertiesProvider],
dataObjectLabelEditingProvider: ['type', DataObjectLabelEditingProvider],
dataStoreInterceptor: ['type', DataStoreInterceptor],
dataStorePropertiesProvider: ['type', DataStorePropertiesProvider],
conditionsPropertiesProvider: ['type', ConditionsPropertiesProvider],

View File

@ -10,7 +10,7 @@ import {
idToHumanReadableName,
} from '../../app/spiffworkflow/DataObject/DataObjectHelpers';
describe('DataObject Interceptor', function() {
describe('DataObject Interceptor', function () {
let xml = require('./bpmn/empty_diagram.bpmn').default;
@ -23,7 +23,7 @@ describe('DataObject Interceptor', function() {
]
}));
it('New Data Object References should create a data object if none exist.', inject(function(canvas, modeling) {
it('New Data Object References should create a data object if none exist.', inject(function (canvas, modeling) {
// IF - a new dataObjectReference is created
let rootShape = canvas.getRootElement();
@ -37,7 +37,7 @@ describe('DataObject Interceptor', function() {
}));
it('New Data Object References should connect to the first available data Object if it exists', inject(function(canvas, modeling) {
it('New Data Object References should connect to the first available data Object if it exists', inject(function (canvas, modeling) {
// IF - two dataObjectReferences are created
let rootShape = canvas.getRootElement();
@ -54,7 +54,7 @@ describe('DataObject Interceptor', function() {
}));
it('Deleting a data object reference does not delete the data object, unless it is the last reference', inject(function(canvas, modeling) {
it('Deleting a data object reference does not delete the data object, unless it is the last reference', inject(function (canvas, modeling) {
// IF - two dataObjectReferences are created
let rootShape = canvas.getRootElement();
@ -71,7 +71,7 @@ describe('DataObject Interceptor', function() {
expect(dataObjects.length).to.equal(1);
}));
it('Deleting all the data references will also delete the data object', inject(function(canvas, modeling) {
it('Deleting all the data references will also delete the data object', inject(function (canvas, modeling) {
// IF - two dataObjectReferences are created
let rootShape = canvas.getRootElement();
@ -89,7 +89,7 @@ describe('DataObject Interceptor', function() {
expect(dataObjects.length).to.equal(0);
}));
it('Creating a new Reference will update the name to match the DataObject', inject(function(canvas, modeling) {
it('Creating a new Reference will update the name to match the DataObject', inject(function (canvas, modeling) {
// IF - a Data Reference Exists
let rootShape = canvas.getRootElement();
@ -101,7 +101,7 @@ describe('DataObject Interceptor', function() {
expect(dataObjectRefShape1.businessObject.name).to.equal(human_readable_name);
}));
it('should allow you to add a data object to a subprocess', inject(function(canvas, modeling, elementRegistry) {
it('should allow you to add a data object to a subprocess', inject(function (canvas, modeling, elementRegistry) {
// IF - A data object reference is added to a sup-process
let subProcessShape = elementRegistry.get('my_subprocess');
@ -117,7 +117,7 @@ describe('DataObject Interceptor', function() {
expect(dataObjects.length).to.equal(1);
}));
it('Data objects in a process should be visible in a subprocess', inject(function(canvas, modeling, elementRegistry) {
it('Data objects in a process should be visible in a subprocess', inject(function (canvas, modeling, elementRegistry) {
let subProcessShape = elementRegistry.get('my_subprocess');
let subProcess = subProcessShape.businessObject;
@ -132,7 +132,7 @@ describe('DataObject Interceptor', function() {
expect(dataObjects.length).to.equal(1);
}));
it('Data objects in a subprocess should not be visible in a process', inject(function(canvas, modeling, elementRegistry) {
it('Data objects in a subprocess should not be visible in a process', inject(function (canvas, modeling, elementRegistry) {
let subProcessShape = elementRegistry.get('my_subprocess');
let subProcess = subProcessShape.businessObject;
@ -147,7 +147,7 @@ describe('DataObject Interceptor', function() {
expect(dataObjects.length).to.equal(0);
}));
it('References inside subprocesses should be visible in a process', inject(function(canvas, modeling, elementRegistry) {
it('References inside subprocesses should be visible in a process', inject(function (canvas, modeling, elementRegistry) {
let rootShape = canvas.getRootElement();
const refOne = modeling.createShape({ type: 'bpmn:DataObjectReference' },

View File

@ -1,18 +1,30 @@
import {
bootstrapPropertiesPanel, changeInput,
bootstrapPropertiesPanel,
changeInput,
expectSelected,
findEntry, findInput, findSelect,
findEntry,
findInput,
findSelect
} from './helpers';
import { BpmnPropertiesPanelModule, BpmnPropertiesProviderModule } from 'bpmn-js-properties-panel';
import {
inject,
} from 'bpmn-js/test/helper';
import {
BpmnPropertiesPanelModule,
BpmnPropertiesProviderModule
} from 'bpmn-js-properties-panel';
import spiffModdleExtension from '../../app/spiffworkflow/moddle/spiffworkflow.json';
import TestContainer from 'mocha-test-container-support';
import DataObject from '../../app/spiffworkflow/DataObject';
describe('Properties Panel for Data Objects', function() {
describe('Properties Panel for Data Objects', function () {
let xml = require('./bpmn/diagram.bpmn').default;
let container;
beforeEach(function() {
beforeEach(function () {
container = TestContainer.get(this);
});
@ -29,7 +41,7 @@ describe('Properties Panel for Data Objects', function() {
},
}));
it('should allow you to see a list of data objects', async function() {
it('should allow you to see a list of data objects', async function () {
// IF - a data object reference is selected
let my_data_ref_1 = await expectSelected('my_data_ref_1');
@ -45,8 +57,7 @@ describe('Properties Panel for Data Objects', function() {
expect(selector.length).to.equal(3);
});
it('selecting a different data object should change the data model.', async function() {
it('selecting a different data object should change the data model.', async function () {
// IF - a data object reference is selected
let my_data_ref_1 = await expectSelected('my_data_ref_1');
@ -62,20 +73,23 @@ describe('Properties Panel for Data Objects', function() {
expect(businessObject.get('dataObjectRef').id).to.equal('my_third_data_object');
});
it('renaming a data object, changes to the label of references', async function() {
// Notice: Test Case for Data Object ID Changes No Longer Required
// With our new feature implementation, changing a Data Object ID is now independent of altering
// its Data Reference Name. This decoupling eliminates the need for the specific test case previously required for these changes.
// it('renaming a data object, changes to the label of references', 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, 'my_nifty_new_name');
let my_data_ref_1 = await expectSelected('my_data_ref_1');
// // 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, 'my_nifty_new_name');
// 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('my_nifty_new_name');
expect(my_data_ref_1.businessObject.name).to.equal('My Nifty New Name');
});
// // THEN - both the data object itself, and the label of any references are updated.
// expect(my_data_ref_1.businessObject.dataObjectRef.id).to.equal('my_nifty_new_name');
// 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() {
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);
@ -85,7 +99,97 @@ describe('Properties Panel for Data Objects', function() {
// 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');
// Notice: Test Case for Data Object ID Changes No Longer Required
// expect(my_data_ref_1.businessObject.name).to.equal('My Object 1');
});
it('renaming a data object ID, does not change the label of references', 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, 'my_nifty_new_name');
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('my_nifty_new_name');
expect(my_data_ref_1.businessObject.name).not.to.equal('My Nifty New Name');
});
it('renaming a data object name, does change the label of references', async function () {
let entry = findEntry('ProcessTest-dataObj-2-name', container);
let textInput = findInput('text', entry);
let newDataObjectName = 'A New Data Object Name';
changeInput(textInput, newDataObjectName);
let my_data_ref_1 = await expectSelected('my_data_ref_1');
let my_data_ref_2 = await expectSelected('my_data_ref_2');
// THEN - the label of any references are updated.
expect(my_data_ref_1.businessObject.name).to.equal(newDataObjectName);
expect(my_data_ref_2.businessObject.name).to.equal(newDataObjectName);
// Test References with DataState
let my_data_ref_3 = await expectSelected('my_data_ref_3');
let my_data_ref_3_DataState = my_data_ref_3.businessObject.dataState.name;
expect(my_data_ref_3.businessObject.name).to.equal(`${newDataObjectName} [${my_data_ref_3_DataState}]`);
});
it('renaming a data object reference state, does change the label its reference', async function () {
let my_data_ref_1 = await expectSelected('my_data_ref_1');
let dtObjCurrentName = my_data_ref_1.businessObject.name;
let entry = findEntry('selectDataState-textField', container);
let idInput = findInput('text', entry);
let nwState = "New State";
// Change Data State
changeInput(idInput, nwState);
// Expect new DataObjectRef Name to be like 'DataObjectRefName [DataState]'
expect(my_data_ref_1.businessObject.name).to.equal(`${dtObjCurrentName} [${nwState}]`);
expect(my_data_ref_1.businessObject.name).not.to.equal(dtObjCurrentName);
});
it('selecting a different data object should not change the data object reference name.', async function () {
// IF - a data object reference is selected
let my_data_ref_1 = await expectSelected('my_data_ref_1');
let entry = findEntry('selectDataObject', container);
let selector = findSelect(entry);
let businessObject = my_data_ref_1.businessObject;
changeInput(selector, 'my_third_data_object');
expect(businessObject.get('dataObjectRef').id).to.equal('my_third_data_object');
expect(businessObject.name).to.equal('D3');
expect(businessObject.name).not.to.equal('my_data_object');
});
it('should not allow two dataObjects to have the same ID', inject(async function (canvas, modeling) {
// Creating the first dataObject
let rootShape = canvas.getRootElement();
const dataObject1 = modeling.createShape({ type: 'bpmn:DataObject' },
{ x: 100, y: 100 }, rootShape);
// Creating the second dataObject
const dataObject2 = modeling.createShape({ type: 'bpmn:DataObject' },
{ x: 150, y: 100 }, rootShape);
await expectSelected(dataObject2.id);
let entry = findEntry('dataObjectId', container);
let idInput = findInput('text', entry);
const duplicateId = dataObject1.businessObject.id;
changeInput(idInput, duplicateId);
// Check that the ID change is not successful
expect(dataObject2.businessObject.id).not.to.equal(duplicateId);
}));
});

View File

@ -38,7 +38,7 @@
<bpmn:script>elizabeth="awesome"</bpmn:script>
</bpmn:scriptTask>
<bpmn:dataObject id="my_other_data_object" />
<bpmn:dataObject id="my_third_data_object" />
<bpmn:dataObject id="my_third_data_object" name="D3" />
<bpmn:dataObjectReference id="my_data_ref_1" name="my_data_object" dataObjectRef="my_data_object" />
<bpmn:sequenceFlow id="Flow_132laxn" sourceRef="task_confirm" targetRef="business_rule_task" />
<bpmn:userTask id="task_confirm" name="confirm contentment">
@ -61,6 +61,11 @@
</camunda:properties>
</bpmn:extensionElements>
</bpmn:dataObjectReference>
<bpmn:dataObjectReference id="my_data_ref_3" name="my_data_object" dataObjectRef="my_data_object">
<bpmn:dataState id="DataState_my_data_ref_3" name="OK" />
</bpmn:dataObjectReference>
<bpmn:dataObject id="my_data_object" />
<bpmn:sequenceFlow id="Flow_1lu1qyz" sourceRef="business_rule_task" targetRef="Event_14wzv4j" />
<bpmn:businessRuleTask id="business_rule_task">
@ -119,6 +124,12 @@
<dc:Bounds x="451" y="322" width="78" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="DataObjectReference_08bm73g_di" bpmnElement="my_data_ref_3">
<dc:Bounds x="472" y="265" width="36" height="50" />
<bpmndi:BPMNLabel>
<dc:Bounds x="451" y="322" width="78" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="dataInput_1" bpmnElement="num_dogs">
<dc:Bounds x="172" y="85" width="36" height="50" />
<bpmndi:BPMNLabel>