allow attaching pre/post scripts to MI task or instance tasks
This commit is contained in:
parent
877424a55a
commit
b8179146b9
|
@ -1,4 +1,8 @@
|
|||
import { ListGroup } from '@bpmn-io/properties-panel';
|
||||
import {
|
||||
ListGroup,
|
||||
CheckboxEntry,
|
||||
isCheckboxEntryEdited,
|
||||
} from '@bpmn-io/properties-panel';
|
||||
import { is, isAny } from 'bpmn-js/lib/util/ModelUtil';
|
||||
import scriptGroup, { SCRIPT_TYPE } from './SpiffScriptGroup';
|
||||
import {
|
||||
|
@ -117,32 +121,69 @@ function createScriptGroup(element, translate, moddle, commandStack) {
|
|||
* @returns The components to add to the properties panel.
|
||||
*/
|
||||
function preScriptPostScriptGroup(element, translate, moddle, commandStack) {
|
||||
const entries = [
|
||||
...scriptGroup({
|
||||
element,
|
||||
moddle,
|
||||
commandStack,
|
||||
translate,
|
||||
scriptType: SCRIPT_TYPE.pre,
|
||||
label: 'Pre-Script',
|
||||
description: 'code to execute prior to this task.',
|
||||
}),
|
||||
...scriptGroup({
|
||||
element,
|
||||
moddle,
|
||||
commandStack,
|
||||
translate,
|
||||
scriptType: SCRIPT_TYPE.post,
|
||||
label: 'Post-Script',
|
||||
description: 'code to execute after this task.',
|
||||
}),
|
||||
];
|
||||
const loopCharacteristics = element.businessObject.loopCharacteristics;
|
||||
if (typeof(loopCharacteristics) !== 'undefined') {
|
||||
entries.push({
|
||||
id: 'scriptValence',
|
||||
component: ScriptValenceCheckbox,
|
||||
isEdited: isCheckboxEntryEdited,
|
||||
commandStack,
|
||||
});
|
||||
}
|
||||
return {
|
||||
id: 'spiff_pre_post_scripts',
|
||||
label: translate('Pre/Post Scripts'),
|
||||
entries: [
|
||||
...scriptGroup({
|
||||
element,
|
||||
moddle,
|
||||
commandStack,
|
||||
translate,
|
||||
scriptType: SCRIPT_TYPE.pre,
|
||||
label: 'Pre-Script',
|
||||
description: 'code to execute prior to this task.',
|
||||
}),
|
||||
...scriptGroup({
|
||||
element,
|
||||
moddle,
|
||||
commandStack,
|
||||
translate,
|
||||
scriptType: SCRIPT_TYPE.post,
|
||||
label: 'Post-Script',
|
||||
description: 'code to execute after this task.',
|
||||
}),
|
||||
],
|
||||
entries: entries,
|
||||
};
|
||||
}
|
||||
|
||||
function ScriptValenceCheckbox(props) {
|
||||
|
||||
const { element, commandStack } = props;
|
||||
|
||||
const getValue = () => {
|
||||
return element.businessObject.loopCharacteristics.scriptsOnInstances;
|
||||
};
|
||||
|
||||
const setValue = (value) => {
|
||||
const loopCharacteristics = element.businessObject.loopCharacteristics;
|
||||
loopCharacteristics.scriptsOnInstances = value || undefined;
|
||||
commandStack.execute('element.updateModdleProperties', {
|
||||
element,
|
||||
moddleElement: loopCharacteristics,
|
||||
});
|
||||
};
|
||||
|
||||
return CheckboxEntry({
|
||||
element,
|
||||
id: 'selectScriptValence',
|
||||
label: 'Run scripts on instances',
|
||||
description: 'By default, scripts will attach to the multiinstance task',
|
||||
getValue,
|
||||
setValue,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a group on the main panel with a select box (for choosing the Data Object to connect)
|
||||
* @param element
|
||||
|
|
|
@ -241,6 +241,20 @@
|
|||
"type": "String"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "scriptsOnInstances",
|
||||
"extends": [
|
||||
"bpmn:MultiInstanceLoopCharacteristics",
|
||||
"bpmn:StandardLoopCharacteristics"
|
||||
],
|
||||
"properties": [
|
||||
{
|
||||
"name": "scriptsOnInstances",
|
||||
"isAttr": true,
|
||||
"type": "Boolean"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue