ruoyi-vue-nocode/ruoyi-ui/ruoyi-bpmnjs/resources/properties-panel/helper/EventDefinitionHelper.js

58 lines
1.8 KiB
JavaScript
Raw Normal View History

2022-08-11 16:10:41 +08:00
'use strict';
var getBusinessObject = require('bpmn-js/lib/util/ModelUtil').getBusinessObject,
is = require('bpmn-js/lib/util/ModelUtil').is,
forEach = require('lodash/forEach');
var EventDefinitionHelper = {};
module.exports = EventDefinitionHelper;
EventDefinitionHelper.getEventDefinition = function(element, eventType) {
var bo = getBusinessObject(element),
eventDefinition = null;
if (bo.eventDefinitions) {
forEach(bo.eventDefinitions, function(event) {
if (is(event, eventType)) {
eventDefinition = event;
}
});
}
return eventDefinition;
};
EventDefinitionHelper.getTimerEventDefinition = function(element) {
return this.getEventDefinition(element, 'bpmn:TimerEventDefinition');
};
EventDefinitionHelper.getMessageEventDefinition = function(element) {
return this.getEventDefinition(element, 'bpmn:MessageEventDefinition');
};
EventDefinitionHelper.getSignalEventDefinition = function(element) {
return this.getEventDefinition(element, 'bpmn:SignalEventDefinition');
};
EventDefinitionHelper.getErrorEventDefinition = function(element) {
return this.getEventDefinition(element, 'bpmn:ErrorEventDefinition');
};
EventDefinitionHelper.getEscalationEventDefinition = function(element) {
return this.getEventDefinition(element, 'bpmn:EscalationEventDefinition');
};
EventDefinitionHelper.getCompensateEventDefinition = function(element) {
return this.getEventDefinition(element, 'bpmn:CompensateEventDefinition');
};
EventDefinitionHelper.getLinkEventDefinition = function(element) {
return this.getEventDefinition(element, 'bpmn:LinkEventDefinition');
};
EventDefinitionHelper.getConditionalEventDefinition = function(element) {
return this.getEventDefinition(element, 'bpmn:ConditionalEventDefinition');
};