diff --git a/app/spiffworkflow/InputOutput/IoInterceptor.js b/app/spiffworkflow/InputOutput/IoInterceptor.js index 1150a3d..7cb3eeb 100644 --- a/app/spiffworkflow/InputOutput/IoInterceptor.js +++ b/app/spiffworkflow/InputOutput/IoInterceptor.js @@ -43,7 +43,6 @@ export default class IoInterceptor extends CommandInterceptor { } else { collectionAdd(ioSpecification.get('dataOutputs'), dataIO); } - } }); diff --git a/app/spiffworkflow/PropertiesPanel/SpiffWorkflowPropertiesProvider.js b/app/spiffworkflow/PropertiesPanel/SpiffWorkflowPropertiesProvider.js index 0c22a8c..0038fdf 100644 --- a/app/spiffworkflow/PropertiesPanel/SpiffWorkflowPropertiesProvider.js +++ b/app/spiffworkflow/PropertiesPanel/SpiffWorkflowPropertiesProvider.js @@ -1,6 +1,6 @@ import scriptProps, { SCRIPT_TYPE } from './parts/ScriptProps'; import { is, isAny } from 'bpmn-js/lib/util/ModelUtil'; -import dataObjectProps from './parts/DataObjectProps'; +import dataObjectProps from './parts/DataReferenceProps'; const LOW_PRIORITY = 500; diff --git a/app/spiffworkflow/PropertiesPanel/parts/DataObjectProps.js b/app/spiffworkflow/PropertiesPanel/parts/DataReferenceProps.js similarity index 52% rename from app/spiffworkflow/PropertiesPanel/parts/DataObjectProps.js rename to app/spiffworkflow/PropertiesPanel/parts/DataReferenceProps.js index a4c5426..90ec97e 100644 --- a/app/spiffworkflow/PropertiesPanel/parts/DataObjectProps.js +++ b/app/spiffworkflow/PropertiesPanel/parts/DataReferenceProps.js @@ -1,23 +1,37 @@ -import { SelectEntry, isTextFieldEntryEdited} from '@bpmn-io/properties-panel'; +import { Group, ListGroup, SelectEntry, isTextFieldEntryEdited, TextEntry } from '@bpmn-io/properties-panel'; import {useService} from 'bpmn-js-properties-panel'; +import {getBusinessObject} from 'bpmn-js/lib/util/ModelUtil'; +import {remove as collectionRemove} from 'diagram-js/lib/util/Collections'; /** - * Allows for the creation and deletion of Data Objects - * and connecting those data objects to Data References. + * Allows you to associate the selected Data Reference to a + * data object. Many references can point to the same data object. + * Also allows you to select which Data Objects are available + * in the system overall. * @param dataElement The selected Data Object Reference * @param moddle For updating the underlying xml object * @returns {[{component: (function(*)), isEdited: *, id: string, element},{component: (function(*)), isEdited: *, id: string, element}]} */ export default function (dataElement, moddle) { + return [ { - id: 'dataObjects', + id: 'selectDataObject', dataElement, component: DataObjectSelector, isEdited: isTextFieldEntryEdited, moddle: moddle, }, - ]; + { + id: 'editDataObjects', + dataElement, + label: 'Available Data Objects', + component: Group, + entries: [ + ...DataObjectProps({dataElement, moddle}) + ] + } + ]; } /** @@ -79,3 +93,56 @@ function DataObjectSelector(props) { debounce={debounce} />; } + +/** + * Provides a list of data objects, and allows you to add / remove data objects, and change their ids. + * @param props + * @constructor + */ +function DataObjectProps(props) { + + const moddle = props.moddle; + const id = props.id; + const element = props.dataElement; + + const businessObject = element.businessObject; + const parent = businessObject.$parent; + + let dataObjects = [] + for (const element of parent.flowElements) { + if (element.$type === 'bpmn:DataObject') { + dataObjects.push(element) + } + } + + const entries = dataObjects.map((dataObject, index) => { + + return { + id: dataObject.id, + label: dataObject.id, + autoFocusEntry: dataObject.id, + remove: removeDataObject({ dataObject }) + }; + }); + + return entries + + function removeDataObject({ dataObject }) { + return function(event) { + const parent = dataObject.$parent + collectionRemove(parent, dataObject); + }; + } + + function addFactory({ bpmnFactory, commandStack, element }) { + return function(event) { + event.stopPropagation(); + + const businessObject = element.businessObject.$parent; + businessObject.add('bpmn:DataObject') + }; + } + + + +} diff --git a/app/spiffworkflow/PropertiesPanel/parts/ScriptProps.js b/app/spiffworkflow/PropertiesPanel/parts/ScriptProps.js index 04b79c8..5fac393 100644 --- a/app/spiffworkflow/PropertiesPanel/parts/ScriptProps.js +++ b/app/spiffworkflow/PropertiesPanel/parts/ScriptProps.js @@ -69,46 +69,40 @@ function PythonScript(props) { const getScriptObject = () => { const bizObj = element.businessObject; if (type === SCRIPT_TYPE.bpmn) { - return bizObj.script || ''; + return bizObj; + } + if (!bizObj.extensionElements) { + return null; } else { - if (!bizObj.extensionElements) { - return null; - } else { - return bizObj.extensionElements.values.filter(function(e) { - return e.$instanceOf(type); - })[0]; - } + return bizObj.extensionElements.values.filter(function(e) { + return e.$instanceOf(type); + })[0]; } }; const getValue = () => { - const script = getScriptObject(); - if (script) { - return (script.text); + const scriptObj = getScriptObject() + if (scriptObj) { + return scriptObj.script; } else { - return (''); + return "" } }; const setValue = value => { const businessObject = element.businessObject; - if (type === SCRIPT_TYPE.bpmn) { - return modeling.updateProperties(element, { - scriptFormat: 'python', - script: value - }); - } else { - let script = getScriptObject(); - if (!script) { - script = moddle.create(type); + let scriptObj = getScriptObject() + // Create the script object if needed. + if (!scriptObj) { + scriptObj = moddle.create(type); + if (type !== SCRIPT_TYPE.bpmn) { if (!businessObject.extensionElements) { businessObject.extensionElements = moddle.create('bpmn:ExtensionElements'); } - businessObject.extensionElements.get('values').push(script); + businessObject.extensionElements.get('values').push(scriptObj); } - script.text = value; - return script; } + scriptObj.script = value; }; return my_data_ref_2 Property_1w1963p + elizabeth="awesome" @@ -39,12 +40,6 @@ - - - - - - @@ -60,19 +55,13 @@ + + + - - - - - - - - - @@ -88,6 +77,18 @@ + + + + + + + + + + + + @@ -98,4 +99,4 @@ - \ No newline at end of file +