From 906d9d2efe1fe659288242358040326313e18318 Mon Sep 17 00:00:00 2001 From: Alexis Zeghers <42282939+AZeghers@users.noreply.github.com> Date: Fri, 12 Feb 2021 14:43:53 +0100 Subject: [PATCH] feat(errors): add errors subsection to support error event definitions Closes #422 --- .../camunda/CamundaPropertiesProvider.js | 15 ++- lib/provider/camunda/parts/ErrorsProps.js | 16 +++ .../camunda/parts/implementation/Errors.js | 97 +++++++++++++++++++ package-lock.json | 8 +- package.json | 2 +- 5 files changed, 131 insertions(+), 7 deletions(-) create mode 100644 lib/provider/camunda/parts/ErrorsProps.js create mode 100644 lib/provider/camunda/parts/implementation/Errors.js diff --git a/lib/provider/camunda/CamundaPropertiesProvider.js b/lib/provider/camunda/CamundaPropertiesProvider.js index c13eda381..7b786824d 100644 --- a/lib/provider/camunda/CamundaPropertiesProvider.js +++ b/lib/provider/camunda/CamundaPropertiesProvider.js @@ -46,7 +46,8 @@ var elementTemplateDescriptionProps = require('./element-templates/parts/Descrip // Input/Output var inputParameters = require('./parts/InputParametersProps'), - outputParameters = require('./parts/OutputParametersProps'); + outputParameters = require('./parts/OutputParametersProps'), + errorsProps = require('./parts/ErrorsProps'); // Connector var connectorDetails = require('./parts/ConnectorDetailProps'), @@ -420,9 +421,19 @@ function createInputOutputTabGroups(element, bpmnFactory, elementTemplates, tran outputParameters(outputParametersGroup, element, bpmnFactory, elementTemplates, translate); + var errorsGroup = { + id: 'errors', + label: translate('Errors'), + entries: [] + }; + + errorsProps(errorsGroup, element, bpmnFactory, elementTemplates, translate); + return [ inputParametersGroup, - outputParametersGroup + outputParametersGroup, + + errorsGroup ]; } diff --git a/lib/provider/camunda/parts/ErrorsProps.js b/lib/provider/camunda/parts/ErrorsProps.js new file mode 100644 index 000000000..266029dae --- /dev/null +++ b/lib/provider/camunda/parts/ErrorsProps.js @@ -0,0 +1,16 @@ +'use strict'; + +var errors = require('./implementation/Errors'); + +module.exports = function(group, element, bpmnFactory, elementTemplates, translate) { + + var template = elementTemplates.get(element); + + if (template) { + return; + } + + var errorsEntry = errors(element, bpmnFactory, {}, translate); + + group.entries = group.entries.concat(errorsEntry.entries); +}; diff --git a/lib/provider/camunda/parts/implementation/Errors.js b/lib/provider/camunda/parts/implementation/Errors.js new file mode 100644 index 000000000..9e2ca66b1 --- /dev/null +++ b/lib/provider/camunda/parts/implementation/Errors.js @@ -0,0 +1,97 @@ +'use strict'; + +var is = require('bpmn-js/lib/util/ModelUtil').is, + getBusinessObject = require('bpmn-js/lib/util/ModelUtil').getBusinessObject; + +var elementHelper = require('../../../../helper/ElementHelper'), + cmdHelper = require('../../../../helper/CmdHelper'); + +var domQuery = require('min-dom').query; + +function supportsErrors(element) { + return is(element, 'bpmn:ServiceTask'); +} + +module.exports = function(element, bpmnFactory, options, translate) { + + options = options || {}; + + var result = {}; + + var entries = result.entries = []; + + if (!supportsErrors(element)) { + return result; + } + + entries.push( + getErrorsHeading(element, bpmnFactory, { + type: 'camunda:ErrorEventDefinition', + prop: 'errorEventDefinition', + prefix: 'Error' + })); + + return result; +}; + +function getErrorsHeading(element, bpmnFactory, options) { + var prefix = options.prefix; + + var entry = { + id: prefix + '-heading', + cssClasses: [ 'bpp-input-output' ], + html: '