cmmn-js-properties-panel-flowable 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +112 -0
  3. package/dist/assets/cmmn-js-properties-panel.css +495 -0
  4. package/index.js +1 -0
  5. package/lib/PropertiesActivator.js +67 -0
  6. package/lib/PropertiesPanel.js +1264 -0
  7. package/lib/Utils.js +126 -0
  8. package/lib/cmd/MultiCommandHandler.js +32 -0
  9. package/lib/cmd/UpdateBusinessObjectHandler.js +100 -0
  10. package/lib/cmd/UpdateBusinessObjectListHandler.js +108 -0
  11. package/lib/cmd/index.js +25 -0
  12. package/lib/factory/CheckboxEntryFactory.js +68 -0
  13. package/lib/factory/EntryFactory.js +199 -0
  14. package/lib/factory/EntryFieldDescription.js +73 -0
  15. package/lib/factory/LabelFactory.js +38 -0
  16. package/lib/factory/SelectEntryFactory.js +75 -0
  17. package/lib/factory/TextBoxEntryFactory.js +42 -0
  18. package/lib/factory/TextInputEntryFactory.js +73 -0
  19. package/lib/factory/ValidationAwareTextInput.js +66 -0
  20. package/lib/helper/CmdHelper.js +76 -0
  21. package/lib/helper/CmmnElementHelper.js +232 -0
  22. package/lib/helper/ElementHelper.js +23 -0
  23. package/lib/helper/ExtensionElementsHelper.js +39 -0
  24. package/lib/helper/ListenerHelper.js +28 -0
  25. package/lib/index.js +13 -0
  26. package/lib/provider/cmmn/CmmnPropertiesProvider.js +183 -0
  27. package/lib/provider/cmmn/index.js +7 -0
  28. package/lib/provider/cmmn/parts/CallableProps.js +169 -0
  29. package/lib/provider/cmmn/parts/CaseProps.js +66 -0
  30. package/lib/provider/cmmn/parts/DefinitionDocumentationProps.js +24 -0
  31. package/lib/provider/cmmn/parts/DefinitionIdProps.js +22 -0
  32. package/lib/provider/cmmn/parts/DefinitionNameProps.js +43 -0
  33. package/lib/provider/cmmn/parts/DocumentationProps.js +21 -0
  34. package/lib/provider/cmmn/parts/IdProps.js +14 -0
  35. package/lib/provider/cmmn/parts/IfPartProps.js +110 -0
  36. package/lib/provider/cmmn/parts/NameProps.js +90 -0
  37. package/lib/provider/cmmn/parts/OnPartProps.js +61 -0
  38. package/lib/provider/cmmn/parts/PlanItemControlProps.js +214 -0
  39. package/lib/provider/cmmn/parts/implementation/ConditionProp.js +81 -0
  40. package/lib/provider/cmmn/parts/implementation/DocumentationProp.js +91 -0
  41. package/lib/provider/cmmn/parts/implementation/IdProp.js +42 -0
  42. package/lib/provider/cmmn/parts/implementation/NameProp.js +38 -0
  43. package/lib/provider/cmmn/parts/implementation/RuleProp.js +96 -0
  44. package/lib/provider/cmmn/parts/implementation/TransitionProp.js +81 -0
  45. package/lib/provider/flowable/FlowablePropertiesProvider.js +393 -0
  46. package/lib/provider/flowable/index.js +7 -0
  47. package/lib/provider/flowable/parts/CallableExtensionProps.js +250 -0
  48. package/lib/provider/flowable/parts/CaseExecutionListenerProps.js +31 -0
  49. package/lib/provider/flowable/parts/HistoryTimeToLiveProps.js +19 -0
  50. package/lib/provider/flowable/parts/HumanTaskProps.js +76 -0
  51. package/lib/provider/flowable/parts/ListenerDetailProps.js +32 -0
  52. package/lib/provider/flowable/parts/ListenerFieldInjectionProps.js +13 -0
  53. package/lib/provider/flowable/parts/RepeatOnStandardEventProps.js +144 -0
  54. package/lib/provider/flowable/parts/TaskListenerProps.js +27 -0
  55. package/lib/provider/flowable/parts/VariableListenerProps.js +27 -0
  56. package/lib/provider/flowable/parts/VariableMappingProps.js +361 -0
  57. package/lib/provider/flowable/parts/implementation/BusinessKeyProp.js +109 -0
  58. package/lib/provider/flowable/parts/implementation/ExtensionElements.js +248 -0
  59. package/lib/provider/flowable/parts/implementation/FieldInjection.js +281 -0
  60. package/lib/provider/flowable/parts/implementation/HistoryTimeToLiveProp.js +37 -0
  61. package/lib/provider/flowable/parts/implementation/ListenerDelegateProp.js +159 -0
  62. package/lib/provider/flowable/parts/implementation/ListenerElements.js +132 -0
  63. package/lib/provider/flowable/parts/implementation/ListenerEventTypeProp.js +118 -0
  64. package/lib/provider/flowable/parts/implementation/ScriptProp.js +161 -0
  65. package/package.json +72 -0
  66. package/styles/_mixins.less +79 -0
  67. package/styles/_variables.less +19 -0
  68. package/styles/config.json +46 -0
  69. package/styles/groups.less +71 -0
  70. package/styles/header.less +35 -0
  71. package/styles/properties.less +328 -0
  72. package/styles/tabs.less +90 -0
@@ -0,0 +1,73 @@
1
+ 'use strict';
2
+
3
+ var escapeHTML = require('../Utils').escapeHTML;
4
+
5
+ /**
6
+ * Create a linkified and HTML escaped entry field description.
7
+ *
8
+ * As a special feature, this description may contain both markdown,
9
+ * plain <a href> links and <br />
10
+ *
11
+ * @param {String} description
12
+ */
13
+ module.exports = function entryFieldDescription(description) {
14
+
15
+ // we tokenize the description to extract text, HTML and markdown links
16
+ // text, links and new lines are handled seperately
17
+
18
+ var escaped = [];
19
+
20
+ // match markdown [{TEXT}]({URL}) and HTML links <a href="{URL}">{TEXT}</a>
21
+ var pattern = /(?:\[([^\]]+)\]\((https?:\/\/[^)]+)\))|(?:<a href="(https?:\/\/[^"]+)">(.+?(?=<\/))<\/a>)/gi;
22
+
23
+ var index = 0;
24
+ var match;
25
+ var link, text;
26
+
27
+ while ((match = pattern.exec(description))) {
28
+
29
+ // escape + insert text before match
30
+ if (match.index > index) {
31
+ escaped.push(escapeText(description.substring(index, match.index)));
32
+ }
33
+
34
+ link = match[2] && encodeURI(match[2]) || match[3];
35
+ text = match[1] || match[4];
36
+
37
+ // insert safe link
38
+ escaped.push('<a href="' + link + '" target="_blank">' + escapeText(text) + '</a>');
39
+
40
+ index = match.index + match[0].length;
41
+ }
42
+
43
+ // escape and insert text after last match
44
+ if (index < description.length) {
45
+ escaped.push(escapeText(description.substring(index)));
46
+ }
47
+
48
+ return '<div class="cpp-field-description">' + escaped.join('') + '</div>';
49
+ };
50
+
51
+ function escapeText(text) {
52
+ var match, index = 0, escaped = [];
53
+
54
+ // match new line <br/> <br /> <br.... /> etc.
55
+ var pattern = /<br\s*\/?>/gi;
56
+
57
+ while ((match = pattern.exec(text))) {
58
+
59
+ if (match.index > index) {
60
+ escaped.push(escapeHTML(text.substring(index, match.index)));
61
+ }
62
+
63
+ escaped.push('<br />');
64
+
65
+ index = match.index + match[0].length;
66
+ }
67
+
68
+ if (index < text.length) {
69
+ escaped.push(escapeHTML(text.substring(index)));
70
+ }
71
+
72
+ return escaped.join('');
73
+ }
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * The label factory provides a label entry. For the label text
5
+ * it expects either a string provided by the options.labelText
6
+ * parameter or it could be generated programmatically using a
7
+ * function passed as the options.get parameter.
8
+ *
9
+ * @param {Object} options
10
+ * @param {string} options.id
11
+ * @param {string} [options.labelText]
12
+ * @param {Function} [options.get]
13
+ * @param {Function} [options.showLabel]
14
+ * @param {Boolean} [options.divider] adds a divider at the top of the label if true; default: false
15
+ */
16
+ var label = function(options) {
17
+ return {
18
+ id: options.id,
19
+ html: '<label data-value="label" ' +
20
+ 'data-show="showLabel" ' +
21
+ 'class="entry-label' + (options.divider ? ' divider' : '') + '">' +
22
+ '</label>',
23
+ get: function(element, node) {
24
+ if (typeof options.get === 'function') {
25
+ return options.get(element, node);
26
+ }
27
+ return { label: options.labelText };
28
+ },
29
+ showLabel: function(element, node) {
30
+ if (typeof options.showLabel === 'function') {
31
+ return options.showLabel(element, node);
32
+ }
33
+ return true;
34
+ }
35
+ };
36
+ };
37
+
38
+ module.exports = label;
@@ -0,0 +1,75 @@
1
+ 'use strict';
2
+
3
+ var escapeHTML = require('../Utils').escapeHTML;
4
+
5
+ var forEach = require('lodash/forEach');
6
+
7
+ var entryFieldDescription = require('./EntryFieldDescription');
8
+
9
+
10
+ var isList = function(list) {
11
+ return !(!list || Object.prototype.toString.call(list) !== '[object Array]');
12
+ };
13
+
14
+ var addEmptyParameter = function(list) {
15
+ list.unshift({ name: '', value: '' });
16
+ };
17
+
18
+ /**
19
+ * @param {Object} options
20
+ * @param {string} options.id
21
+ * @param {string} [options.label]
22
+ * @param {Array<Object>} options.selectOptions
23
+ * @param {string} options.modelProperty
24
+ * @param {boolean} options.emptyParameter
25
+ * @param {function} options.disabled
26
+ * @param {Object} defaultParameters
27
+ *
28
+ * @return {Object}
29
+ */
30
+ var selectbox = function(options, defaultParameters) {
31
+ var resource = defaultParameters,
32
+ label = options.label || resource.id,
33
+ selectOptions = options.selectOptions,
34
+ modelProperty = options.modelProperty,
35
+ emptyParameter = options.emptyParameter,
36
+ canBeDisabled = !!options.disabled && typeof options.disabled === 'function',
37
+ description = options.description;
38
+
39
+ if (isList(selectOptions)) {
40
+ if (emptyParameter) {
41
+ addEmptyParameter(selectOptions);
42
+ }
43
+ } else {
44
+ selectOptions = [ { name: '', value: '' } ];
45
+ }
46
+
47
+ resource.html =
48
+ '<label for="flowable-' + resource.id + '"' +
49
+ (canBeDisabled ? 'data-show="isDisabled" ' : '') + '>' + escapeHTML(label) + '</label>' +
50
+ '<select id="flowable-' + escapeHTML(resource.id) + '-select" name="' + escapeHTML(modelProperty) + '"' +
51
+ (canBeDisabled ? 'data-show="isDisabled" ' : '') + ' data-value>';
52
+
53
+ forEach(selectOptions, function(option) {
54
+ resource.html += '<option value="' + escapeHTML(option.value) + '">' + (option.name ? escapeHTML(option.name) : '') + '</option>';
55
+ });
56
+
57
+ resource.html += '</select>';
58
+
59
+ // add description below select box entry field
60
+ if (description) {
61
+ resource.html += entryFieldDescription(description);
62
+ }
63
+
64
+ if (canBeDisabled) {
65
+ resource.isDisabled = function() {
66
+ return !options.disabled.apply(resource, arguments);
67
+ };
68
+ }
69
+
70
+ resource.cssClasses = ['dropdown'];
71
+
72
+ return resource;
73
+ };
74
+
75
+ module.exports = selectbox;
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ var escapeHTML = require('../Utils').escapeHTML;
4
+
5
+ var entryFieldDescription = require('./EntryFieldDescription');
6
+
7
+
8
+ var textBox = function(options, defaultParameters) {
9
+
10
+ var resource = defaultParameters,
11
+ label = options.label || resource.id,
12
+ canBeShown = !!options.show && typeof options.show === 'function',
13
+ description = options.description;
14
+
15
+ resource.html =
16
+ '<label for="flowable-' + escapeHTML(resource.id) + '" ' +
17
+ (canBeShown ? 'data-show="isShown"' : '') +
18
+ '>' + escapeHTML(label) + '</label>' +
19
+ '<div class="cpp-field-wrapper" ' +
20
+ (canBeShown ? 'data-show="isShown"' : '') +
21
+ '>' +
22
+ '<div contenteditable="true" id="flowable-' + escapeHTML(resource.id) + '" ' +
23
+ 'name="' + escapeHTML(options.modelProperty) + '" />' +
24
+ '</div>';
25
+
26
+ // add description below text box entry field
27
+ if (description) {
28
+ resource.html += entryFieldDescription(description);
29
+ }
30
+
31
+ if (canBeShown) {
32
+ resource.isShown = function() {
33
+ return options.show.apply(resource, arguments);
34
+ };
35
+ }
36
+
37
+ resource.cssClasses = ['cpp-textbox'];
38
+
39
+ return resource;
40
+ };
41
+
42
+ module.exports = textBox;
@@ -0,0 +1,73 @@
1
+ 'use strict';
2
+
3
+ var escapeHTML = require('../Utils').escapeHTML;
4
+
5
+ var domQuery = require('min-dom').query;
6
+
7
+ var entryFieldDescription = require('./EntryFieldDescription');
8
+
9
+
10
+ var textField = function(options, defaultParameters) {
11
+
12
+ // Default action for the button next to the input-field
13
+ var defaultButtonAction = function(element, inputNode) {
14
+ var input = domQuery('input[name="' + options.modelProperty + '"]', inputNode);
15
+ input.value = '';
16
+
17
+ return true;
18
+ };
19
+
20
+ // default method to determine if the button should be visible
21
+ var defaultButtonShow = function(element, inputNode) {
22
+ var input = domQuery('input[name="' + options.modelProperty + '"]', inputNode);
23
+
24
+ return input.value !== '';
25
+ };
26
+
27
+ var resource = defaultParameters,
28
+ label = options.label || resource.id,
29
+ dataValueLabel = options.dataValueLabel,
30
+ buttonLabel = (options.buttonLabel || 'X'),
31
+ actionName = (typeof options.buttonAction != 'undefined') ? options.buttonAction.name : 'clear',
32
+ actionMethod = (typeof options.buttonAction != 'undefined') ? options.buttonAction.method : defaultButtonAction,
33
+ showName = (typeof options.buttonShow != 'undefined') ? options.buttonShow.name : 'canClear',
34
+ showMethod = (typeof options.buttonShow != 'undefined') ? options.buttonShow.method : defaultButtonShow,
35
+ canBeDisabled = !!options.disabled && typeof options.disabled === 'function',
36
+ description = options.description;
37
+
38
+ resource.html =
39
+ '<label for="flowable-' + resource.id + '" ' +
40
+ (canBeDisabled ? 'data-show="isDisabled" ' : '') +
41
+ (dataValueLabel ? 'data-value="' + escapeHTML(dataValueLabel) + '"' : '') + '>'+ escapeHTML(label) +'</label>' +
42
+ '<div class="cpp-field-wrapper" ' +
43
+ (canBeDisabled ? 'data-show="isDisabled"' : '') +
44
+ '>' +
45
+ '<input id="flowable-' + escapeHTML(resource.id) + '" type="text" name="' + escapeHTML(options.modelProperty) + '" ' +
46
+ ' />' +
47
+ '<button class="' + escapeHTML(actionName) + '" data-action="' + escapeHTML(actionName) +
48
+ '" data-show="' + escapeHTML(showName) + '" ' +
49
+ (canBeDisabled ? 'data-disabled="isDisabled"' : '') + '>' +
50
+ '<span>' + escapeHTML(buttonLabel) + '</span>' +
51
+ '</button>' +
52
+ '</div>';
53
+
54
+ // add description below text input entry field
55
+ if (description) {
56
+ resource.html += entryFieldDescription(description);
57
+ }
58
+
59
+ resource[actionName] = actionMethod;
60
+ resource[showName] = showMethod;
61
+
62
+ if (canBeDisabled) {
63
+ resource.isDisabled = function() {
64
+ return !options.disabled.apply(resource, arguments);
65
+ };
66
+ }
67
+
68
+ resource.cssClasses = ['cpp-textfield'];
69
+
70
+ return resource;
71
+ };
72
+
73
+ module.exports = textField;
@@ -0,0 +1,66 @@
1
+ 'use strict';
2
+
3
+ var textField = require('./TextInputEntryFactory');
4
+
5
+ /**
6
+ * This function is a wrapper around TextInputEntryFactory.
7
+ * It adds functionality to cache an invalid value entered in the
8
+ * text input, instead of setting it on the business object.
9
+ */
10
+ var validationAwareTextField = function(options, defaultParameters) {
11
+
12
+ var modelProperty = options.modelProperty,
13
+ defaultGet = defaultParameters.get,
14
+ defaultSet = defaultParameters.set;
15
+
16
+
17
+ defaultParameters.get = function(element, node) {
18
+ var value = this.__lastInvalidValue;
19
+
20
+ delete this.__lastInvalidValue;
21
+
22
+ var properties = {};
23
+
24
+ if (value !== undefined) {
25
+ properties[modelProperty] = value;
26
+ }
27
+ else {
28
+ properties = defaultGet(element, node);
29
+ }
30
+
31
+ return properties;
32
+ };
33
+
34
+ defaultParameters.set = function(element, values, node) {
35
+ var validationErrors = validate.apply(this, [ element, values, node ]),
36
+ propertyValue = values[modelProperty],
37
+ properties = {};
38
+
39
+ // make sure we do not update the id
40
+ if (validationErrors && validationErrors[modelProperty]) {
41
+
42
+ this.__lastInvalidValue = propertyValue;
43
+ properties = defaultGet(element, node);
44
+
45
+ } else {
46
+
47
+ properties[modelProperty] = propertyValue;
48
+
49
+ }
50
+
51
+ return defaultSet(element, properties, node);
52
+ };
53
+
54
+ var validate = defaultParameters.validate = function(element, values, node) {
55
+ var value = values[modelProperty] || this.__lastInvalidValue;
56
+
57
+ var property = {};
58
+ property[modelProperty] = value;
59
+
60
+ return options.validate(element, property, node);
61
+ };
62
+
63
+ return textField(options, defaultParameters);
64
+ };
65
+
66
+ module.exports = validationAwareTextField;
@@ -0,0 +1,76 @@
1
+ 'use strict';
2
+
3
+ var CmdHelper = {};
4
+ module.exports = CmdHelper;
5
+
6
+ CmdHelper.updateProperties = function(element, properties, shape) {
7
+ return {
8
+ cmd: 'element.updateProperties',
9
+ context: { element: element, properties: properties, shape: shape }
10
+ };
11
+ };
12
+
13
+ CmdHelper.updateSemanticParent = function(element, newParent, containment, shape) {
14
+ return {
15
+ cmd: 'element.updateSemanticParent',
16
+ context: {
17
+ element: element,
18
+ newParent: newParent,
19
+ containment: containment,
20
+ shape: shape
21
+ }
22
+ };
23
+ };
24
+
25
+ CmdHelper.updateBusinessObject = function(element, businessObject, newProperties) {
26
+ return {
27
+ cmd: 'properties-panel.update-businessobject',
28
+ context: {
29
+ element: element,
30
+ businessObject: businessObject,
31
+ properties: newProperties
32
+ }
33
+ };
34
+ };
35
+
36
+ CmdHelper.addElementsTolist = function(element, businessObject, listPropertyName, objectsToAdd) {
37
+ return {
38
+ cmd: 'properties-panel.update-businessobject-list',
39
+ context: {
40
+ element: element,
41
+ currentObject: businessObject,
42
+ propertyName: listPropertyName,
43
+ objectsToAdd: objectsToAdd
44
+ }
45
+ };
46
+ };
47
+
48
+ CmdHelper.removeElementsFromList = function(element, businessObject, listPropertyName, referencePropertyName, objectsToRemove) {
49
+
50
+ return {
51
+ cmd: 'properties-panel.update-businessobject-list',
52
+ context: {
53
+ element: element,
54
+ currentObject: businessObject,
55
+ propertyName: listPropertyName,
56
+ referencePropertyName: referencePropertyName,
57
+ objectsToRemove: objectsToRemove
58
+ }
59
+ };
60
+ };
61
+
62
+
63
+ CmdHelper.addAndRemoveElementsFromList = function(element, businessObject, listPropertyName, referencePropertyName, objectsToAdd, objectsToRemove) {
64
+
65
+ return {
66
+ cmd: 'properties-panel.update-businessobject-list',
67
+ context: {
68
+ element: element,
69
+ currentObject: businessObject,
70
+ propertyName: listPropertyName,
71
+ referencePropertyName: referencePropertyName,
72
+ objectsToAdd: objectsToAdd,
73
+ objectsToRemove: objectsToRemove
74
+ }
75
+ };
76
+ };
@@ -0,0 +1,232 @@
1
+ 'use strict';
2
+
3
+ var ModelUtil = require('cmmn-js/lib/util/ModelUtil'),
4
+ is = ModelUtil.is,
5
+ getBusinessObject = ModelUtil.getBusinessObject,
6
+ getDefinition = ModelUtil.getDefinition,
7
+ isCasePlanModel = ModelUtil.isCasePlanModel;
8
+
9
+ var isAny = require('cmmn-js/lib/features/modeling/util/ModelingUtil').isAny;
10
+
11
+ var filter = require('lodash/filter');
12
+
13
+ function isItemCapable(element) {
14
+ return isAny(element, [
15
+ 'cmmn:PlanItem',
16
+ 'cmmn:DiscretionaryItem',
17
+ 'cmmn:CaseFileItem'
18
+ ]);
19
+ }
20
+
21
+ module.exports.isItemCapable = isItemCapable;
22
+
23
+
24
+ function isCriterion(element) {
25
+ return is(element, 'cmmn:Criterion');
26
+ }
27
+
28
+ module.exports.isCriterion = isCriterion;
29
+
30
+
31
+ function isCMMNEdge(element) {
32
+ return is(element, 'cmmndi:CMMNEdge');
33
+ }
34
+
35
+ module.exports.isCMMNEdge = isCMMNEdge;
36
+
37
+
38
+ function isDiscretionaryConnection(element) {
39
+ return !getCMMNElementRef(element);
40
+ }
41
+
42
+ module.exports.isDiscretionaryConnection = isDiscretionaryConnection;
43
+
44
+
45
+ function isAssociationConnection(element) {
46
+ return is(getCMMNElementRef(element), 'cmmn:Association');
47
+ }
48
+
49
+ module.exports.isAssociationConnection = isAssociationConnection;
50
+
51
+
52
+ function isOnPartConnection(element) {
53
+ return is(getCMMNElementRef(element), 'cmmn:OnPart');
54
+ }
55
+
56
+ module.exports.isOnPartConnection = isOnPartConnection;
57
+
58
+
59
+ function getCMMNElementRef(element) {
60
+ var bo = getBusinessObject(element);
61
+ return bo && bo.cmmnElementRef;
62
+ }
63
+
64
+ module.exports.getCMMNElementRef = getCMMNElementRef;
65
+
66
+
67
+ function isTextAnnotation(element) {
68
+ return is(element, 'cmmn:TextAnnotation');
69
+ }
70
+
71
+ module.exports.isTextAnnotation = isTextAnnotation;
72
+
73
+
74
+ function isCMMNDiagram(element) {
75
+ return is(element, 'cmmndi:CMMNDiagram');
76
+ }
77
+
78
+ module.exports.isCMMNDiagram = isCMMNDiagram;
79
+
80
+
81
+ function isAssignable(element) {
82
+ return is(getDefinition(element), 'flowable:Assignable');
83
+ }
84
+
85
+ module.exports.isAssignable = isAssignable;
86
+
87
+
88
+ function isFormSupported(element) {
89
+ return is(getDefinition(element), 'flowable:FormSupported');
90
+ }
91
+
92
+ module.exports.isFormSupported = isFormSupported;
93
+
94
+
95
+ function isTask(element) {
96
+ return is(getDefinition(element), 'cmmn:Task');
97
+ }
98
+
99
+ module.exports.isTask = isTask;
100
+
101
+
102
+ function isHumanTask(element) {
103
+ return is(getDefinition(element), 'cmmn:HumanTask');
104
+ }
105
+
106
+ module.exports.isHumanTask = isHumanTask;
107
+
108
+
109
+ function isMilestone(element) {
110
+ return is(getDefinition(element), 'cmmn:Milestone');
111
+ }
112
+
113
+ module.exports.isMilestone = isMilestone;
114
+
115
+
116
+ function isEventListener(element) {
117
+ return is(getDefinition(element), 'cmmn:EventListener');
118
+ }
119
+
120
+ module.exports.isEventListener = isEventListener;
121
+
122
+
123
+ function isStage(element) {
124
+ return is(getDefinition(element), 'cmmn:Stage');
125
+ }
126
+
127
+ module.exports.isStage = isStage;
128
+
129
+
130
+ function isInOutBindingCapable(element) {
131
+ return isAny(getDefinition(element), [
132
+ 'cmmn:ProcessTask',
133
+ 'cmmn:CaseTask'
134
+ ]);
135
+ }
136
+
137
+ module.exports.isInOutBindingCapable = isInOutBindingCapable;
138
+
139
+
140
+ function getOutgoingOnParts(element, onPartFilter) {
141
+
142
+ return filter(element.outgoing, function(con) {
143
+
144
+ if (isOnPartConnection(con)) {
145
+
146
+ if (onPartFilter && getCMMNElementRef(con) !== onPartFilter) {
147
+ return false;
148
+ }
149
+
150
+ return true;
151
+
152
+ }
153
+
154
+ return false;
155
+
156
+ });
157
+
158
+ }
159
+
160
+ module.exports.getOutgoingOnParts = getOutgoingOnParts;
161
+
162
+
163
+ function isCallable(element) {
164
+ return isAny(getDefinition(element), [
165
+ 'cmmn:ProcessTask',
166
+ 'cmmn:CaseTask',
167
+ 'cmmn:DecisionTask'
168
+ ]);
169
+ }
170
+
171
+ module.exports.isCallable = isCallable;
172
+
173
+
174
+ function isPlanItem(element) {
175
+ return is(element, 'cmmn:PlanItem');
176
+ }
177
+
178
+ module.exports.isPlanItem = isPlanItem;
179
+
180
+
181
+ function isCaseExecutionListenerCapable(element) {
182
+
183
+ if (isCasePlanModel(element)) {
184
+ return true;
185
+ }
186
+
187
+ if (isPlanItem(element)) {
188
+
189
+ var definition = getDefinition(element);
190
+ return isAny(definition, [
191
+ 'cmmn:Task',
192
+ 'cmmn:Stage',
193
+ 'cmmn:Milestone'
194
+ ]);
195
+
196
+ }
197
+
198
+ return false;
199
+
200
+ }
201
+
202
+ module.exports.isCaseExecutionListenerCapable = isCaseExecutionListenerCapable;
203
+
204
+
205
+ function isTaskListenerCapable(element) {
206
+ return isPlanItem(element) && isHumanTask(element);
207
+ }
208
+
209
+ module.exports.isTaskListenerCapable = isTaskListenerCapable;
210
+
211
+
212
+ function isVariableListenerCapable(element) {
213
+
214
+ if (isCasePlanModel(element)) {
215
+ return true;
216
+ }
217
+
218
+ if (isPlanItem(element)) {
219
+
220
+ var definition = getDefinition(element);
221
+ return isAny(definition, [
222
+ 'cmmn:Task',
223
+ 'cmmn:Stage'
224
+ ]);
225
+
226
+ }
227
+
228
+ return false;
229
+
230
+ }
231
+
232
+ module.exports.isVariableListenerCapable = isVariableListenerCapable;
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var ElementHelper = {};
4
+ module.exports = ElementHelper;
5
+
6
+ /**
7
+ * Creates a new element and set the parent to it
8
+ *
9
+ * @method ElementHelper#createElement
10
+ *
11
+ * @param {String} elementType of the new element
12
+ * @param {Object} properties of the new element in key-value pairs
13
+ * @param {moddle.object} parent of the new element
14
+ * @param {BpmnFactory} factory which creates the new element
15
+ *
16
+ * @returns {djs.model.Base} element which is created
17
+ */
18
+ ElementHelper.createElement = function(elementType, properties, parent, factory) {
19
+ var element = factory.create(elementType, properties);
20
+ element.$parent = parent;
21
+
22
+ return element;
23
+ };