2022-10-12 14:21:19 +00:00
|
|
|
import { ListGroup } from '@bpmn-io/properties-panel';
|
|
|
|
import { is, isAny } from 'bpmn-js/lib/util/ModelUtil';
|
|
|
|
import scriptGroup, { SCRIPT_TYPE } from './SpiffScriptGroup';
|
|
|
|
import {
|
|
|
|
ServiceTaskParameterArray,
|
|
|
|
ServiceTaskOperatorSelect, ServiceTaskResultTextInput,
|
|
|
|
} from './SpiffExtensionServiceProperties';
|
2022-11-07 19:35:53 +00:00
|
|
|
import {OPTION_TYPE, SpiffExtensionSelect} from './SpiffExtensionSelect';
|
|
|
|
import {SpiffExtensionLaunchButton} from './SpiffExtensionLaunchButton';
|
|
|
|
import {SpiffExtensionTextArea} from './SpiffExtensionTextArea';
|
2022-10-12 14:21:19 +00:00
|
|
|
|
|
|
|
const LOW_PRIORITY = 500;
|
|
|
|
|
|
|
|
export default function ExtensionsPropertiesProvider(
|
|
|
|
propertiesPanel,
|
|
|
|
translate,
|
|
|
|
moddle,
|
|
|
|
commandStack,
|
2022-10-31 21:02:34 +00:00
|
|
|
elementRegistry,
|
2022-10-12 14:21:19 +00:00
|
|
|
) {
|
|
|
|
this.getGroups = function (element) {
|
|
|
|
return function (groups) {
|
|
|
|
if (is(element, 'bpmn:ScriptTask')) {
|
|
|
|
groups.push(
|
|
|
|
createScriptGroup(element, translate, moddle, commandStack)
|
|
|
|
);
|
|
|
|
} else if (
|
|
|
|
isAny(element, ['bpmn:Task', 'bpmn:CallActivity', 'bpmn:SubProcess'])
|
|
|
|
) {
|
2022-10-31 21:02:34 +00:00
|
|
|
groups.push(preScriptPostScriptGroup(element, translate, moddle, commandStack));
|
2022-10-12 14:21:19 +00:00
|
|
|
}
|
|
|
|
if (is(element, 'bpmn:UserTask')) {
|
|
|
|
groups.push(createUserGroup(element, translate, moddle, commandStack));
|
|
|
|
}
|
|
|
|
if (is(element, 'bpmn:BusinessRuleTask')) {
|
|
|
|
groups.push(
|
|
|
|
createBusinessRuleGroup(element, translate, moddle, commandStack)
|
|
|
|
);
|
|
|
|
}
|
2022-10-31 21:02:34 +00:00
|
|
|
if (isAny(element, ['bpmn:ManualTask', 'bpmn:UserTask', 'bpmn:EndEvent'])) {
|
2022-10-12 14:21:19 +00:00
|
|
|
groups.push(
|
2022-10-31 21:02:34 +00:00
|
|
|
createUserInstructionsGroup (
|
2022-10-12 14:21:19 +00:00
|
|
|
element,
|
|
|
|
translate,
|
|
|
|
moddle,
|
|
|
|
commandStack
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (is(element, 'bpmn:ServiceTask')) {
|
|
|
|
groups.push(
|
|
|
|
createServiceGroup(element, translate, moddle, commandStack)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return groups;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
propertiesPanel.registerProvider(LOW_PRIORITY, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
ExtensionsPropertiesProvider.$inject = [
|
|
|
|
'propertiesPanel',
|
|
|
|
'translate',
|
|
|
|
'moddle',
|
|
|
|
'commandStack',
|
|
|
|
'elementRegistry',
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a group to the properties panel for the script task that allows you
|
|
|
|
* to set the script.
|
|
|
|
* @param element
|
|
|
|
* @param translate
|
|
|
|
* @returns The components to add to the properties panel. */
|
|
|
|
function createScriptGroup(element, translate, moddle, commandStack) {
|
|
|
|
return {
|
|
|
|
id: 'spiff_script',
|
|
|
|
label: translate('Script'),
|
|
|
|
entries: scriptGroup({
|
|
|
|
element,
|
|
|
|
moddle,
|
|
|
|
scriptType: SCRIPT_TYPE.bpmn,
|
|
|
|
label: 'Script',
|
|
|
|
description: 'Code to execute.',
|
|
|
|
translate,
|
|
|
|
commandStack,
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a section to the properties' panel for NON-Script tasks, so that
|
|
|
|
* you can define a pre-script and a post-script for modifying data as it comes and out.
|
|
|
|
* @param element
|
|
|
|
* @param translate
|
|
|
|
* @param moddle For altering the underlying XML File.
|
|
|
|
* @returns The components to add to the properties panel.
|
|
|
|
*/
|
2022-10-31 21:02:34 +00:00
|
|
|
function preScriptPostScriptGroup(element, translate, moddle, commandStack) {
|
2022-10-12 14:21:19 +00:00
|
|
|
return {
|
|
|
|
id: 'spiff_pre_post_scripts',
|
2022-10-31 21:02:34 +00:00
|
|
|
label: translate('Pre/Post Scripts'),
|
2022-10-12 14:21:19 +00:00
|
|
|
entries: [
|
|
|
|
...scriptGroup({
|
|
|
|
element,
|
|
|
|
moddle,
|
2022-10-31 21:02:34 +00:00
|
|
|
commandStack,
|
2022-10-12 14:21:19 +00:00
|
|
|
translate,
|
|
|
|
scriptType: SCRIPT_TYPE.pre,
|
|
|
|
label: 'Pre-Script',
|
|
|
|
description: 'code to execute prior to this task.',
|
|
|
|
}),
|
|
|
|
...scriptGroup({
|
|
|
|
element,
|
|
|
|
moddle,
|
2022-10-31 21:02:34 +00:00
|
|
|
commandStack,
|
2022-10-12 14:21:19 +00:00
|
|
|
translate,
|
|
|
|
scriptType: SCRIPT_TYPE.post,
|
|
|
|
label: 'Post-Script',
|
|
|
|
description: 'code to execute after this task.',
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a group on the main panel with a select box (for choosing the Data Object to connect)
|
|
|
|
* @param element
|
|
|
|
* @param translate
|
|
|
|
* @param moddle
|
|
|
|
* @returns entries
|
|
|
|
*/
|
|
|
|
function createUserGroup(element, translate, moddle, commandStack) {
|
|
|
|
return {
|
|
|
|
id: 'user_task_properties',
|
2022-10-31 21:02:34 +00:00
|
|
|
label: translate('Web Form (with Json Schemas)'),
|
2022-10-12 14:21:19 +00:00
|
|
|
entries: [
|
|
|
|
{
|
|
|
|
element,
|
|
|
|
moddle,
|
|
|
|
commandStack,
|
2022-11-07 19:35:53 +00:00
|
|
|
component: SpiffExtensionSelect,
|
|
|
|
optionType: OPTION_TYPE.json_files,
|
|
|
|
name: 'formJsonSchemaFilename',
|
2022-10-12 14:21:19 +00:00
|
|
|
label: translate('JSON Schema Filename'),
|
2022-11-07 19:35:53 +00:00
|
|
|
description: translate('Form Description (RSJF)'),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
component: SpiffExtensionLaunchButton,
|
|
|
|
element,
|
2022-10-12 14:21:19 +00:00
|
|
|
name: 'formJsonSchemaFilename',
|
2022-11-07 19:35:53 +00:00
|
|
|
label: translate('Launch Editor'),
|
|
|
|
event: 'spiff.file.edit',
|
|
|
|
description: translate('Edit the form description'),
|
2022-10-12 14:21:19 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
element,
|
|
|
|
moddle,
|
|
|
|
commandStack,
|
2022-11-07 19:35:53 +00:00
|
|
|
component: SpiffExtensionSelect,
|
|
|
|
optionType: OPTION_TYPE.json_files,
|
2022-10-12 14:21:19 +00:00
|
|
|
label: translate('UI Schema Filename'),
|
2022-11-07 19:35:53 +00:00
|
|
|
event: 'spiff.file.edit',
|
|
|
|
description: translate('Rules for displaying the form. (RSJF Schema)'),
|
2022-10-12 14:21:19 +00:00
|
|
|
name: 'formUiSchemaFilename',
|
|
|
|
},
|
2022-11-07 19:35:53 +00:00
|
|
|
{
|
|
|
|
component: SpiffExtensionLaunchButton,
|
|
|
|
element,
|
|
|
|
name: 'formUiSchemaFilename',
|
|
|
|
label: translate('Launch Editor'),
|
|
|
|
event: 'spiff.file.edit',
|
|
|
|
description: translate('Edit the form schema'),
|
|
|
|
},
|
2022-10-12 14:21:19 +00:00
|
|
|
],
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-11-07 19:35:53 +00:00
|
|
|
* Select and launch for Business Rules
|
|
|
|
*
|
2022-10-12 14:21:19 +00:00
|
|
|
* @param element
|
|
|
|
* @param translate
|
|
|
|
* @param moddle
|
2022-11-07 19:35:53 +00:00
|
|
|
* @param commandStack
|
|
|
|
* @returns {{entries: [{moddle, component: ((function(*): preact.VNode<any>)|*), name: string, description, label, commandStack, element},{component: ((function(*): preact.VNode<any>)|*), name: string, description, label, event: string, element}], id: string, label}}
|
2022-10-12 14:21:19 +00:00
|
|
|
*/
|
|
|
|
function createBusinessRuleGroup(element, translate, moddle, commandStack) {
|
|
|
|
return {
|
|
|
|
id: 'business_rule_properties',
|
|
|
|
label: translate('Business Rule Properties'),
|
|
|
|
entries: [
|
|
|
|
{
|
|
|
|
element,
|
|
|
|
moddle,
|
|
|
|
commandStack,
|
2022-11-07 19:35:53 +00:00
|
|
|
component: SpiffExtensionSelect,
|
|
|
|
optionType: OPTION_TYPE.dmn_files,
|
|
|
|
name: 'spiffworkflow:calledDecisionId',
|
|
|
|
label: translate('Select Decision Table'),
|
|
|
|
description: translate('Select a decision table from the list'),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element,
|
|
|
|
component: SpiffExtensionLaunchButton,
|
|
|
|
name: 'spiffworkflow:calledDecisionId',
|
|
|
|
label: translate('Launch Editor'),
|
|
|
|
event: 'spiff.dmn.edit',
|
|
|
|
description: translate('Modify the Decision Table'),
|
2022-10-12 14:21:19 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a group on the main panel with a text box (for choosing the information to display to the user)
|
|
|
|
* @param element
|
|
|
|
* @param translate
|
|
|
|
* @param moddle
|
|
|
|
* @returns entries
|
|
|
|
*/
|
2022-10-31 21:02:34 +00:00
|
|
|
function createUserInstructionsGroup (
|
2022-10-12 14:21:19 +00:00
|
|
|
element,
|
|
|
|
translate,
|
|
|
|
moddle,
|
|
|
|
commandStack
|
|
|
|
) {
|
|
|
|
return {
|
2022-10-31 21:02:34 +00:00
|
|
|
id: 'instructions',
|
|
|
|
label: translate('Instructions'),
|
2022-10-12 14:21:19 +00:00
|
|
|
entries: [
|
2022-11-07 19:35:53 +00:00
|
|
|
{
|
2022-10-12 14:21:19 +00:00
|
|
|
element,
|
|
|
|
moddle,
|
|
|
|
commandStack,
|
2022-11-07 19:35:53 +00:00
|
|
|
component: SpiffExtensionTextArea,
|
|
|
|
name: 'spiffworkflow:instructionsForEndUser',
|
2022-10-31 21:02:34 +00:00
|
|
|
label: 'Instructions',
|
|
|
|
description: 'The instructions to display when completing this task.',
|
2022-11-07 19:35:53 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
element,
|
|
|
|
moddle,
|
|
|
|
commandStack,
|
|
|
|
component: SpiffExtensionLaunchButton,
|
|
|
|
name: 'spiffworkflow:instructionsForEndUser',
|
|
|
|
label: translate('Launch Editor'),
|
|
|
|
event: 'spiff.markdown.edit',
|
|
|
|
listenEvent: 'spiff.markdown.update',
|
|
|
|
description: translate('Edit the form schema'),
|
|
|
|
}
|
2022-10-12 14:21:19 +00:00
|
|
|
],
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a group on the main panel with a text box (for choosing the dmn to connect)
|
|
|
|
* @param element
|
|
|
|
* @param translate
|
|
|
|
* @param moddle
|
|
|
|
* @returns entries
|
|
|
|
*/
|
|
|
|
function createServiceGroup(element, translate, moddle, commandStack) {
|
|
|
|
return {
|
|
|
|
id: 'service_task_properties',
|
|
|
|
label: translate('Spiffworkflow Service Properties'),
|
|
|
|
entries: [
|
|
|
|
{
|
|
|
|
element,
|
|
|
|
moddle,
|
|
|
|
commandStack,
|
|
|
|
component: ServiceTaskOperatorSelect,
|
|
|
|
translate,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element,
|
|
|
|
moddle,
|
|
|
|
commandStack,
|
|
|
|
component: ServiceTaskResultTextInput,
|
|
|
|
translate,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'serviceTaskParameters',
|
|
|
|
label: translate('Parameters'),
|
|
|
|
component: ListGroup,
|
|
|
|
...ServiceTaskParameterArray({
|
|
|
|
element,
|
|
|
|
moddle,
|
|
|
|
translate,
|
2022-10-19 20:16:54 +00:00
|
|
|
commandStack
|
2022-10-12 14:21:19 +00:00
|
|
|
}),
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
}
|