From c574ceba766b56be43633c24694294363a4da4f2 Mon Sep 17 00:00:00 2001 From: burnettk Date: Fri, 18 Nov 2022 10:03:38 -0500 Subject: [PATCH] Squashed 'bpmn-js-spiffworkflow/' changes from 4f23f860..e92f48da e92f48da minor fixes to the Bpmn-js-subworkflow spec. af88025a Merge remote-tracking branch 'origin/main' into feature/call_activity_selection f3bd1e56 Minor tweak to bpmn-js-spiffworkflow 9207ef45 Minor tweak, in the hopes of getting a text box to update correctly. 084f4646 Fixing a bug in the Call Activity's handing of an update. c9035994 Return the event bus when calling a search. git-subtree-dir: bpmn-js-spiffworkflow git-subtree-split: e92f48da7cb4416310af71bb1699caaca87324cd --- README.md | 49 ++++++++++--------- app/app.js | 11 +++++ .../CallActivityPropertiesProvider.js | 23 ++++++--- .../propertiesPanel/SpiffExtensionSelect.js | 5 +- test/spec/CallActivitySpec.js | 3 +- 5 files changed, 58 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 43c3eb8e5..de473b9f3 100644 --- a/README.md +++ b/README.md @@ -71,30 +71,31 @@ the behavior of the editor making it easier for your end users. There are many this in the app.js file. Below is a table of all the events that are sent and accepted: -| Event Name | Description | Fired or Acceped | Parameters | Description | -|--------------------------------|------------------------------------------------------------------------------| ---------------- |----------------------|--------------------------------------------------------------------------| -| spiff.service\_tasks.requested | Request a list of available services that can be called from a service task. | Fired | \- | | -| spiff.service\_tasks.returned | Provides a list of services. | Recieved | serviceTaskOperators | ex: \[{id:'Chuck Facts', parameters\[{id:'category', type:'string'}\]}\] | -| spiff.script.edit | Request to edit a python script in some sort of facy editor. | Fired | scriptType | one of: script, preScript, postScript | -| | | | value | The actual python script | -| | | | element | The element that needs updating | -| | | | eventBus | Used by receiver to fire back an event | -| spiff.script.update | Update a python script to a new value. | Recieved | scriptType | one of: script, preScript, postScript | -| | | | value | The updated script | -| | | | element | The element that needs updating | -| spiff.markdown.edit | Request to edit markdown in a fancy editor. | Fired | element | The element that needs updating | -| | | | value | The current markdown content | -| spiff.markdown.update | Update Markdown content for a paticular elements 'instructions'. | Recieved | element | The element that needs updating | -| | | | value | Tne updated Markdown content | -| spiff.callactivity.edit | Requst to edit a call activity by process id. | Fired | processId | The Process the users wants to edit | -| spiff.callactivity.search | Requst to search for a call activity | Fired | | | -| spiff.callactivity.update | Update the process id from a call activity (based on search) | Fired | processId | The Process the users wants to edit | -| spiff.file.edit | request to edit a file, but file name. | Fired | value | The file name the user wants to edit | -| spiff.dmn.edit | request to edit a dmn by process id. | Fired | value | The DMN id the user wants to edit | -| spiff.json\_files.requested | request a list of local json files. | Fired | optionType | The type of options required ('json' or 'dmn') | -| spff.dmn\_files.requested | request of list of local dmn files. | | | | -| spiff.json\_files.returned | Return a list of available json files | Recieved | options | \[{lable:'My Label', value:'1'}\] | -| spff.dmn\_files.returned | Return a list of available dmn files. | Recieved | options | \[{lable:'My Label', value:'1'}\] | +| Event Name | Description | Fired or Acceped | Parameters | Description | +|--------------------------------|------------------------------------------------------------------|---------|----------------------|--------------------------------------------------------------------------| +| spiff.service\_tasks.requested | Request a list of available services for service task. | Fired | \- | | +| spiff.service\_tasks.returned | Provides a list of services. | Recieved | serviceTaskOperators | ex: \[{id:'Chuck Facts', parameters\[{id:'category', type:'string'}\]}\] | +| spiff.script.edit | Request to edit a python script in some sort of facy editor. | Fired | scriptType | one of: script, preScript, postScript | +| | | | value | The actual python script | +| | | | element | The element that needs updating | +| | | | eventBus | Used by receiver to fire back an event | +| spiff.script.update | Update a python script to a new value. | Recieved | scriptType | one of: script, preScript, postScript | +| | | | value | The updated script | +| | | | element | The element that needs updating | +| spiff.markdown.edit | Request to edit markdown in a fancy editor. | Fired | element | The element that needs updating | +| | | | value | The current markdown content | +| spiff.markdown.update | Update Markdown content for a paticular elements 'instructions'. | Recieved | element | The element that needs updating | +| | | | value | Tne updated Markdown content | +| spiff.callactivity.edit | Requst to edit a call activity by process id. | Fired | processId | The Process the users wants to edit | +| spiff.callactivity.search | Requst to search for a call activity | Fired | processUd | The currently seleted process id | +| | | | eventBus | For sending back the selected process id. | +| spiff.callactivity.update | Update the process id from a call activity (based on search) | Received | processId | The Process the users wants to edit | +| spiff.file.edit | request to edit a file, but file name. | Fired | value | The file name the user wants to edit | +| spiff.dmn.edit | request to edit a dmn by process id. | Fired | value | The DMN id the user wants to edit | +| spiff.json\_files.requested | request a list of local json files. | Fired | optionType | The type of options required ('json' or 'dmn') | +| spff.dmn\_files.requested | request of list of local dmn files. | | | | +| spiff.json\_files.returned | Return a list of available json files | Recieved | options | \[{lable:'My Label', value:'1'}\] | +| spff.dmn\_files.returned | Return a list of available dmn files. | Recieved | options | \[{lable:'My Label', value:'1'}\] | diff --git a/app/app.js b/app/app.js index 00eac02e4..3876df3d2 100644 --- a/app/app.js +++ b/app/app.js @@ -181,6 +181,17 @@ bpmnModeler.on('spiff.dmn_files.requested', (event) => { }); }); +// As call activites might refernce processes across the system +// it should be possible to search for a paticular call activity. +bpmnModeler.on('spiff.callactivity.search', (event) => { + console.log("Firing call activity update", event.element) + event.eventBus.fire('spiff.callactivity.update', { + value: 'searched_bpmn_id', + element: event.element, + }); +}); + + // This handles the download and upload buttons - it isn't specific to // the BPMN modeler or these extensions, just a quick way to allow you to // create and save files, so keeping it outside the example. diff --git a/app/spiffworkflow/callActivity/propertiesPanel/CallActivityPropertiesProvider.js b/app/spiffworkflow/callActivity/propertiesPanel/CallActivityPropertiesProvider.js index c5d20851a..8aee91db6 100644 --- a/app/spiffworkflow/callActivity/propertiesPanel/CallActivityPropertiesProvider.js +++ b/app/spiffworkflow/callActivity/propertiesPanel/CallActivityPropertiesProvider.js @@ -98,20 +98,29 @@ function CalledElementTextField(props) { } function FindProcessButton(props) { - const { element } = props; + const { element, commandStack } = props; const eventBus = useService('eventBus'); return HeaderButton({ id: 'spiffworkflow-search-call-activity-button', class: 'spiffworkflow-properties-panel-button', onClick: () => { const processId = getCalledElementValue(element); - eventBus.fire('spiff.callactivity.search', { - element, - processId, - }); - // Listen for a response, to update the script. + + // First, set up the listen, then fire the event, just + // in case we are testing and things are happening superfast. eventBus.once('spiff.callactivity.update', (response) => { - element.businessObject.calledElement = response.value; + commandStack.execute('element.updateProperties', { + element: response.element, + moddleElement: response.element.businessObject, + properties: { + calledElement: response.value, + }, + }); + }); + eventBus.fire('spiff.callactivity.search', { + processId, + eventBus, + element }); }, children: 'Search', diff --git a/app/spiffworkflow/extensions/propertiesPanel/SpiffExtensionSelect.js b/app/spiffworkflow/extensions/propertiesPanel/SpiffExtensionSelect.js index 5bc6f505b..9f7bbbaa3 100644 --- a/app/spiffworkflow/extensions/propertiesPanel/SpiffExtensionSelect.js +++ b/app/spiffworkflow/extensions/propertiesPanel/SpiffExtensionSelect.js @@ -53,7 +53,10 @@ export function SpiffExtensionSelect(props) { } const getOptions = () => { const optionList = []; - if (optionType in spiffExtensionOptions) { + if ( + optionType in spiffExtensionOptions && + spiffExtensionOptions[optionType] !== null + ) { spiffExtensionOptions[optionType].forEach((opt) => { optionList.push({ label: opt.label, diff --git a/test/spec/CallActivitySpec.js b/test/spec/CallActivitySpec.js index b2110bb03..56c52cee6 100644 --- a/test/spec/CallActivitySpec.js +++ b/test/spec/CallActivitySpec.js @@ -102,8 +102,9 @@ describe('Call Activities should work', function () { }); await pressButton(button); expect(launchEvent.processId).to.exist; + expect(launchEvent.element).to.exist; - eventBus.fire('spiff.callactivity.update', {value: 'searchedProcessId'}); + eventBus.fire('spiff.callactivity.update', {value: 'searchedProcessId', element: launchEvent.element}); const textInput = domQuery('input', entry); expect(businessObject.get('calledElement')).to.equal('searchedProcessId');