diff --git a/app/spiffworkflow/DataObject/DataObjectHelpers.js b/app/spiffworkflow/DataObject/DataObjectHelpers.js new file mode 100644 index 0000000..b5c90d4 --- /dev/null +++ b/app/spiffworkflow/DataObject/DataObjectHelpers.js @@ -0,0 +1,19 @@ + +export function findDataObjects(process) { + + let dataObjects = []; + for (const element of process.flowElements) { + if (element.$type === 'bpmn:DataObject') { + dataObjects.push(element); + } + } + return dataObjects; +} + +export function findDataObject(process, id) { + for (const dataObj of findDataObjects(process)) { + if (dataObj.id === id) { + return dataObj; + } + } +} diff --git a/app/spiffworkflow/DataObject/DataObjectInterceptor.js b/app/spiffworkflow/DataObject/DataObjectInterceptor.js index 6b1d4d6..bdbfb2d 100644 --- a/app/spiffworkflow/DataObject/DataObjectInterceptor.js +++ b/app/spiffworkflow/DataObject/DataObjectInterceptor.js @@ -1,5 +1,6 @@ import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor'; import { is } from 'bpmn-js/lib/util/ModelUtil'; +import { findDataObjects } from './DataObjectHelpers'; var HIGH_PRIORITY = 1500; /** @@ -56,13 +57,3 @@ export default class DataObjectInterceptor extends CommandInterceptor { } DataObjectInterceptor.$inject = [ 'eventBus', 'bpmnFactory', 'bpmnUpdater' ]; - -function findDataObjects(process) { - let dataObjects = []; - for (const element of process.flowElements) { - if (element.$type === 'bpmn:DataObject') { - dataObjects.push(element); - } - } - return dataObjects; -} diff --git a/app/spiffworkflow/PropertiesPanel/parts/DataObjectArray.js b/app/spiffworkflow/PropertiesPanel/parts/DataObjectArray.js index 6111c5e..d993d5e 100644 --- a/app/spiffworkflow/PropertiesPanel/parts/DataObjectArray.js +++ b/app/spiffworkflow/PropertiesPanel/parts/DataObjectArray.js @@ -1,6 +1,7 @@ import { useService } from 'bpmn-js-properties-panel'; import { isTextFieldEntryEdited, TextFieldEntry } from '@bpmn-io/properties-panel'; import { without } from 'min-dash'; +import { findDataObjects } from '../../DataObject/DataObjectHelpers'; /** * Provides a list of data objects, and allows you to add / remove data objects, and change their ids. @@ -72,17 +73,6 @@ function removeFactory(props) { }; } - -function findDataObjects(process) { - let dataObjects = []; - for (const element of process.flowElements) { - if (element.$type === 'bpmn:DataObject') { - dataObjects.push(element); - } - } - return dataObjects; -} - function DataObjectGroup(props) { const { idPrefix, diff --git a/test/spec/DataObjectInterceptorSpec.js b/test/spec/DataObjectInterceptorSpec.js index 1b43d25..4cc39a7 100644 --- a/test/spec/DataObjectInterceptorSpec.js +++ b/test/spec/DataObjectInterceptorSpec.js @@ -1,9 +1,10 @@ -import { bootstrapPropertiesPanel, findDataObjects } from './helpers'; +import { bootstrapPropertiesPanel } from './helpers'; import dataObjectInterceptor from '../../app/spiffworkflow/DataObject'; import { BpmnPropertiesPanelModule, BpmnPropertiesProviderModule } from 'bpmn-js-properties-panel'; import { inject, } from 'bpmn-js/test/helper'; +import { findDataObjects } from '../../app/spiffworkflow/DataObject/DataObjectHelpers'; describe('DataObject Interceptor', function() { diff --git a/test/spec/ProcessPropsSpec.js b/test/spec/ProcessPropsSpec.js index 89607a6..ff4d24b 100644 --- a/test/spec/ProcessPropsSpec.js +++ b/test/spec/ProcessPropsSpec.js @@ -3,8 +3,7 @@ import { } from 'min-dom'; import { bootstrapPropertiesPanel, changeInput, - expectSelected, findDataObject, findDataObjects, - findEntry, findGroupEntry, findInput + expectSelected, findEntry, findGroupEntry, findInput } from './helpers'; import { BpmnPropertiesPanelModule, BpmnPropertiesProviderModule } from 'bpmn-js-properties-panel'; import SpiffWorkflowPropertiesProvider from '../../app/spiffworkflow/PropertiesPanel'; @@ -12,6 +11,7 @@ import SpiffWorkflowPropertiesProvider from '../../app/spiffworkflow/PropertiesP import spiffModdleExtension from '../../app/spiffworkflow/moddle/spiffworkflow.json'; import TestContainer from 'mocha-test-container-support'; import { fireEvent } from '@testing-library/preact'; +import { findDataObject, findDataObjects } from '../../app/spiffworkflow/DataObject/DataObjectHelpers'; describe('Properties Panel for a Process', function() { let xml = require('./diagram.bpmn').default; diff --git a/test/spec/helpers.js b/test/spec/helpers.js index 6bc385f..317ec3b 100644 --- a/test/spec/helpers.js +++ b/test/spec/helpers.js @@ -122,24 +122,7 @@ export function pressButton(button) { fireEvent.click(button); } -export function findDataObjects(process) { - let dataObjects = []; - for (const element of process.flowElements) { - if (element.$type === 'bpmn:DataObject') { - dataObjects.push(element); - } - } - return dataObjects; -} - -export function findDataObject(process, id) { - for (const dataObj of findDataObjects(process)) { - if (dataObj.id === id) { - return dataObj; - } - } -} /**