ConditionalEventDefinition.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. 'use strict';
  2. var entryFactory = require('../../../../factory/EntryFactory'),
  3. cmdHelper = require('../../../../helper/CmdHelper');
  4. var is = require('bpmn-js/lib/util/ModelUtil').is,
  5. isEventSubProcess = require('bpmn-js/lib/util/DiUtil').isEventSubProcess;
  6. module.exports = function(group, element, bpmnFactory, conditionalEventDefinition, elementRegistry, translate) {
  7. var getValue = function(modelProperty) {
  8. return function(element) {
  9. var modelPropertyValue = conditionalEventDefinition.get('camunda:' + modelProperty);
  10. var value = {};
  11. value[modelProperty] = modelPropertyValue;
  12. return value;
  13. };
  14. };
  15. var setValue = function(modelProperty) {
  16. return function(element, values) {
  17. var props = {};
  18. props['camunda:' + modelProperty] = values[modelProperty] || undefined;
  19. return cmdHelper.updateBusinessObject(element, conditionalEventDefinition, props);
  20. };
  21. };
  22. group.entries.push(entryFactory.textField({
  23. id: 'variableName',
  24. label: translate('Variable Name'),
  25. modelProperty : 'variableName',
  26. get: getValue('variableName'),
  27. set: setValue('variableName')
  28. }));
  29. var isConditionalStartEvent =
  30. is(element, 'bpmn:StartEvent') && !isEventSubProcess(element.parent);
  31. if (!isConditionalStartEvent) {
  32. group.entries.push(entryFactory.textField({
  33. id: 'variableEvent',
  34. label: translate('Variable Event'),
  35. description: translate('Specify more than one variable change event as a comma separated list.'),
  36. modelProperty : 'variableEvent',
  37. get: getValue('variableEvent'),
  38. set: setValue('variableEvent')
  39. }));
  40. }
  41. };