cmmn-js-properties-panel-flowable 2.0.0-next.2 → 2.0.0-next.4

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.
@@ -178,30 +178,6 @@ function isPlanItem(element) {
178
178
  module.exports.isPlanItem = isPlanItem;
179
179
 
180
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
181
  function isTaskListenerCapable(element) {
206
182
  return isPlanItem(element) && isHumanTask(element);
207
183
  }
@@ -209,29 +185,6 @@ function isTaskListenerCapable(element) {
209
185
  module.exports.isTaskListenerCapable = isTaskListenerCapable;
210
186
 
211
187
 
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;
233
-
234
-
235
188
  function isPlanItemLifecycleListenerCapable(element) {
236
189
 
237
190
  return isPlanItem(element) && isAny(getDefinition(element), [
@@ -0,0 +1,127 @@
1
+ 'use strict';
2
+
3
+ var forEach = require('lodash/forEach'),
4
+ isArray = require('lodash/isArray'),
5
+ isObject = require('lodash/isObject');
6
+
7
+
8
+ /**
9
+ * A check for the problems service of @jylups/cmmn-js: parts of a model
10
+ * from the Camunda version of the panel that Flowable does not read. They
11
+ * are kept on save, but have no effect in Flowable.
12
+ *
13
+ * @param {Function} translate
14
+ *
15
+ * @return {Function} check(definitions) -> problems
16
+ */
17
+ module.exports = function(translate) {
18
+
19
+ function notRead(element, message) {
20
+ return {
21
+ kind: 'not-read',
22
+ severity: 'info',
23
+ removedOnSave: false,
24
+ message: message,
25
+ businessObject: element
26
+ };
27
+ }
28
+
29
+ return function(definitions) {
30
+
31
+ var problems = [];
32
+
33
+ walk(definitions, function(element) {
34
+
35
+ var owner = ownerLabel(element);
36
+
37
+ if (element.$type === 'flowable:CaseExecutionListener') {
38
+ problems.push(notRead(element, translate(
39
+ 'The case execution listener of {owner} is not read by Flowable; use a lifecycle listener. ' +
40
+ 'It is kept when the model is saved.', { owner: owner })));
41
+ }
42
+
43
+ if (element.$type === 'flowable:VariableListener') {
44
+ problems.push(notRead(element, translate(
45
+ 'The variable listener of {owner} is not read by Flowable; use a variable event listener. ' +
46
+ 'It is kept when the model is saved.', { owner: owner })));
47
+ }
48
+
49
+ if (element.$type === 'flowable:In' || element.$type === 'flowable:Out') {
50
+
51
+ if (element.get('businessKey') !== undefined) {
52
+ problems.push(notRead(element, translate(
53
+ 'The business key mapping of {owner} is not read by Flowable; use the business key expression ' +
54
+ 'or inherit business key of the task. It is kept when the model is saved.', { owner: owner })));
55
+ }
56
+
57
+ if (element.get('variables') !== undefined) {
58
+ problems.push(notRead(element, translate(
59
+ 'The mapping of all variables of {owner} is not read by Flowable; use inherit variables ' +
60
+ 'of the task. It is kept when the model is saved.', { owner: owner })));
61
+ }
62
+
63
+ if (element.get('local') !== undefined) {
64
+ problems.push(notRead(element, translate(
65
+ 'Local of a variable mapping of {owner} is not read by Flowable. ' +
66
+ 'It is kept when the model is saved.', { owner: owner })));
67
+ }
68
+ }
69
+ });
70
+
71
+ return problems;
72
+ };
73
+ };
74
+
75
+
76
+ /**
77
+ * Visit the model elements contained in the given one, depth first.
78
+ */
79
+ function walk(element, fn) {
80
+
81
+ var visited = new Set(); // eslint-disable-line no-undef
82
+
83
+ function visit(element) {
84
+
85
+ if (!element || !element.$type || visited.has(element)) {
86
+ return;
87
+ }
88
+
89
+ visited.add(element);
90
+
91
+ fn(element);
92
+
93
+ forEach((element.$descriptor && element.$descriptor.properties) || [], function(property) {
94
+
95
+ if (property.isReference || property.isAttr) {
96
+ return;
97
+ }
98
+
99
+ var value = element[property.name];
100
+
101
+ forEach(isArray(value) ? value : [ value ], function(child) {
102
+ if (isObject(child)) {
103
+ visit(child);
104
+ }
105
+ });
106
+ });
107
+ }
108
+
109
+ visit(element);
110
+ }
111
+
112
+ /**
113
+ * The element whose extension elements contain the given one, by type and
114
+ * name or ID.
115
+ */
116
+ function ownerLabel(element) {
117
+ var owner = element.$parent && element.$parent.$parent;
118
+
119
+ if (!owner || !owner.$type) {
120
+ return 'an element';
121
+ }
122
+
123
+ var type = owner.$type.split(':').pop().replace(/([a-z])([A-Z])/g, '$1 $2').toLowerCase(),
124
+ name = owner.name || owner.id;
125
+
126
+ return name ? type + ' \'' + name + '\'' : type;
127
+ }
@@ -24,12 +24,15 @@ var ifPartProps = require('../cmmn/parts/IfPartProps'),
24
24
  taskProps = require('./parts/TaskProps'),
25
25
  eventListenerProps = require('./parts/EventListenerProps'),
26
26
  eventRegistryProps = require('./parts/EventRegistryProps'),
27
+ stageOverviewProps = require('./parts/StageOverviewProps'),
28
+ criterionProps = require('./parts/CriterionProps'),
27
29
  onPartProps = require('../cmmn/parts/OnPartProps'),
28
30
  variableMapping = require('./parts/VariableMappingProps');
29
31
 
30
32
  // plan item control properties
31
33
  var planItemControlProps = require('../cmmn/parts/PlanItemControlProps'),
32
34
  repeatOnStandardEventProps = require('./parts/RepeatOnStandardEventProps'),
35
+ repetitionRuleProps = require('./parts/RepetitionRuleProps'),
33
36
  itemControlRuleProps = require('./parts/ItemControlRuleProps');
34
37
 
35
38
  // definition props
@@ -40,9 +43,7 @@ var definitionIdProps = require('../cmmn/parts/DefinitionIdProps'),
40
43
  callableExtensionProps = require('./parts/CallableExtensionProps');
41
44
 
42
45
  // listener
43
- var caseExecutionListenerProps = require('./parts/CaseExecutionListenerProps'),
44
- variableListenerProps = require('./parts/VariableListenerProps'),
45
- taskListenerProps = require('./parts/TaskListenerProps'),
46
+ var taskListenerProps = require('./parts/TaskListenerProps'),
46
47
  lifecycleListenerProps = require('./parts/LifecycleListenerProps'),
47
48
  listenerDetailProps = require('./parts/ListenerDetailProps'),
48
49
  listenerFields = require('./parts/ListenerFieldInjectionProps');
@@ -54,23 +55,16 @@ var historyTimeToLive = require('./parts/HistoryTimeToLiveProps');
54
55
  var extensionsProps = require('./parts/ExtensionsProps');
55
56
 
56
57
  // problems of the model
57
- var problemsProps = require('./parts/ProblemsProps');
58
+ var problemsProps = require('./parts/ProblemsProps'),
59
+ flowableCheck = require('./FlowableCheck');
58
60
 
59
61
 
60
62
  var getListenerLabel = function(listener, translate) {
61
63
 
62
- if (is(listener, 'flowable:CaseExecutionListener')) {
63
- return translate('Case Execution Listener');
64
- }
65
-
66
64
  if (is(listener, 'flowable:TaskListener')) {
67
65
  return translate('Task Listener');
68
66
  }
69
67
 
70
- if (is(listener, 'flowable:VariableListener')) {
71
- return translate('Variable Listener');
72
- }
73
-
74
68
  if (is(listener, 'flowable:PlanItemLifecycleListener')) {
75
69
  return translate('Lifecycle Listener');
76
70
  }
@@ -106,11 +100,13 @@ function createGeneralTabGroups(element, cmmnFactory, elementRegistry, itemRegis
106
100
 
107
101
  onPartProps(detailsGroup, element, cmmnFactory, elementRegistry, itemRegistry, translate);
108
102
  ifPartProps(detailsGroup, element, cmmnFactory, elementRegistry, itemRegistry, translate);
103
+ criterionProps(detailsGroup, element, translate);
109
104
  humanTaskProps(detailsGroup, element, cmmnFactory, elementRegistry, itemRegistry, translate);
110
105
  callableProps(detailsGroup, element, cmmnFactory, elementRegistry, itemRegistry, translate);
111
106
  callableExtensionProps(detailsGroup, element, cmmnFactory, elementRegistry, itemRegistry, translate);
112
107
  taskProps.detailProps(detailsGroup, element, cmmnFactory, translate);
113
108
  eventListenerProps.eventListenerProps(detailsGroup, element, translate);
109
+ stageOverviewProps(detailsGroup, element, translate);
114
110
 
115
111
 
116
112
  var implementationGroup = {
@@ -170,6 +166,7 @@ function createRulesTabGroups(element, cmmnFactory, elementRegistry, itemRegistr
170
166
 
171
167
  planItemControlProps(itemControlGroup, element, cmmnFactory, elementRegistry, itemRegistry, cmmnRules, translate);
172
168
  repeatOnStandardEventProps(itemControlGroup, element, cmmnFactory, elementRegistry, itemRegistry, cmmnRules, translate);
169
+ repetitionRuleProps(itemControlGroup, element, itemRegistry, translate);
173
170
  itemControlRuleProps.planItemControlRuleProps(itemControlGroup, element, cmmnFactory, translate);
174
171
 
175
172
 
@@ -185,6 +182,9 @@ function createRulesTabGroups(element, cmmnFactory, elementRegistry, itemRegistr
185
182
  repeatOnStandardEventProps(defaultControlGroup, element, cmmnFactory, elementRegistry, itemRegistry, cmmnRules, translate, {
186
183
  isDefaultControl: true
187
184
  });
185
+ repetitionRuleProps(defaultControlGroup, element, itemRegistry, translate, {
186
+ isDefaultControl: true
187
+ });
188
188
  itemControlRuleProps.planItemControlRuleProps(defaultControlGroup, element, cmmnFactory, translate, {
189
189
  isDefaultControl: true
190
190
  });
@@ -224,23 +224,8 @@ function createVariablesTabGroups(element, cmmnFactory, elementRegistry, itemReg
224
224
 
225
225
  function createListenerTabGroups(element, cmmnFactory, elementRegistry, itemRegistry, cmmnRules, translate) {
226
226
 
227
- var caseExecutionListenerGroup = {
228
- id: 'caseExecutionListeners',
229
- label: translate('Case Execution Listeners'),
230
- entries: []
231
- };
232
-
233
- var caseExecutionListenerProvider = caseExecutionListenerProps(
234
- caseExecutionListenerGroup,
235
- element,
236
- cmmnFactory,
237
- elementRegistry,
238
- itemRegistry,
239
- cmmnRules,
240
- translate
241
- );
242
-
243
-
227
+ // Flowable reads task listeners and lifecycle listeners; the case
228
+ // execution and variable listeners of the Camunda version are not offered
244
229
  var taskListenerGroup = {
245
230
  id: 'taskListeners',
246
231
  label: translate('Task Listeners'),
@@ -258,23 +243,6 @@ function createListenerTabGroups(element, cmmnFactory, elementRegistry, itemRegi
258
243
  );
259
244
 
260
245
 
261
- var variableListenerGroup = {
262
- id: 'variableListeners',
263
- label: translate('Variable Listeners'),
264
- entries: []
265
- };
266
-
267
- var variableListenerProvider = variableListenerProps(
268
- variableListenerGroup,
269
- element,
270
- cmmnFactory,
271
- elementRegistry,
272
- itemRegistry,
273
- cmmnRules,
274
- translate
275
- );
276
-
277
-
278
246
  var lifecycleListenerGroup = {
279
247
  id: 'lifecycleListeners',
280
248
  label: translate('Lifecycle Listeners'),
@@ -297,16 +265,12 @@ function createListenerTabGroups(element, cmmnFactory, elementRegistry, itemRegi
297
265
 
298
266
 
299
267
  var listenerGroups = [
300
- caseExecutionListenerGroup,
301
268
  taskListenerGroup,
302
- variableListenerGroup,
303
269
  lifecycleListenerGroup
304
270
  ];
305
271
 
306
272
  var listenerProviders = [
307
- caseExecutionListenerProvider,
308
273
  taskListenerProvider,
309
- variableListenerProvider,
310
274
  planItemLifecycleListenerProvider,
311
275
  caseLifecycleListenerProvider
312
276
  ];
@@ -377,9 +341,7 @@ function createListenerTabGroups(element, cmmnFactory, elementRegistry, itemRegi
377
341
 
378
342
 
379
343
  return [
380
- caseExecutionListenerGroup,
381
344
  taskListenerGroup,
382
- variableListenerGroup,
383
345
  lifecycleListenerGroup,
384
346
  listenerDetailsGroup,
385
347
  listenerFieldsGroup
@@ -426,9 +388,14 @@ function createDefinitionTabGroups(element, cmmnFactory, elementRegistry, itemRe
426
388
  */
427
389
  function FlowablePropertiesProvider(eventBus, cmmnFactory, elementRegistry, itemRegistry, cmmnRules, translate, injector) {
428
390
 
429
- // the problems of the opened model, when the editor has them
391
+ // the problems of the opened model, when the editor has them, with the
392
+ // parts Flowable does not read
430
393
  var problems = injector && injector.get('problems', false);
431
394
 
395
+ if (problems && problems.addCheck) {
396
+ problems.addCheck(flowableCheck(translate));
397
+ }
398
+
432
399
  PropertiesActivator.call(this, eventBus);
433
400
 
434
401
  this.getTabs = function(element) {
@@ -2,12 +2,9 @@
2
2
 
3
3
  var entryFactory = require('../../../factory/EntryFactory');
4
4
 
5
- var BusinessKeyProp = require('./implementation/BusinessKeyProp');
6
-
7
5
  var cmdHelper = require('../../../helper/CmdHelper'),
8
6
  cmmnElementHelper = require('../../../helper/CmmnElementHelper'),
9
- isCallable = cmmnElementHelper.isCallable,
10
- isInOutBindingCapable = cmmnElementHelper.isInOutBindingCapable;
7
+ isCallable = cmmnElementHelper.isCallable;
11
8
 
12
9
  var ModelUtil = require('@jylups/cmmn-js/lib/util/ModelUtil'),
13
10
  getBusinessObject = ModelUtil.getBusinessObject,
@@ -235,16 +232,8 @@ module.exports = function(group, element, cmmnFactory, elementRegistry, itemRegi
235
232
 
236
233
  }));
237
234
 
238
- // businessKey only for ProcessTask and CaseTask
239
- if (isInOutBindingCapable(element)) {
240
- group.entries.push(BusinessKeyProp(element, cmmnFactory, translate, {
241
-
242
- id: 'callable-business-key',
243
- label: translate('Business Key'),
244
- modelProperty: 'callableBusinessKey',
245
- reference: 'definitionRef'
246
-
247
- }));
248
- }
235
+ // the business key of a case or process task is its flowable:businessKey
236
+ // and flowable:inheritBusinessKey (see ./TaskProps); Flowable does not read
237
+ // a business key on flowable:in
249
238
 
250
239
  };
@@ -0,0 +1,134 @@
1
+ 'use strict';
2
+
3
+ var entryFactory = require('../../../factory/EntryFactory'),
4
+ cmdHelper = require('../../../helper/CmdHelper');
5
+
6
+ var ModelUtil = require('@jylups/cmmn-js/lib/util/ModelUtil'),
7
+ is = ModelUtil.is,
8
+ isCasePlanModel = ModelUtil.isCasePlanModel,
9
+ getBusinessObject = ModelUtil.getBusinessObject;
10
+
11
+ var CmmnElementHelper = require('../../../helper/CmmnElementHelper'),
12
+ isCriterion = CmmnElementHelper.isCriterion,
13
+ isStage = CmmnElementHelper.isStage;
14
+
15
+
16
+ function getSentry(element) {
17
+ var criterion = getBusinessObject(element);
18
+
19
+ return criterion && criterion.get('sentryRef');
20
+ }
21
+
22
+ /**
23
+ * Whether the exit criterion is on a stage or the case plan model.
24
+ */
25
+ function isOnStage(element) {
26
+ return !!element.host && isStage(element.host);
27
+ }
28
+
29
+ function isOnCasePlanModel(element) {
30
+ return !!element.host && isCasePlanModel(element.host);
31
+ }
32
+
33
+ function selectBox(id, label, description, options, getTarget, property, translate, hideEntry) {
34
+
35
+ return entryFactory.selectBox({
36
+ id: id,
37
+ label: translate(label),
38
+ description: translate(description),
39
+ modelProperty: id,
40
+ selectOptions: options.map(function(option) {
41
+ return { name: option.name && translate(option.name), value: option.value };
42
+ }),
43
+
44
+ get: function(element) {
45
+ var target = getTarget(element),
46
+ values = {};
47
+
48
+ values[id] = (target && target.get(property)) || '';
49
+
50
+ return values;
51
+ },
52
+
53
+ set: function(element, values) {
54
+ var properties = {};
55
+
56
+ properties[property] = values[id] || undefined;
57
+
58
+ return cmdHelper.updateProperties(getTarget(element), properties, element);
59
+ },
60
+
61
+ hideEntry: hideEntry
62
+ });
63
+ }
64
+
65
+
66
+ /**
67
+ * What Flowable reads on the sentry of a criterion (the trigger mode) and
68
+ * on an exit criterion (what it does, and which instances it exits).
69
+ */
70
+ module.exports = function(group, element, translate) {
71
+
72
+ if (!isCriterion(element)) {
73
+ return;
74
+ }
75
+
76
+ group.entries.push(selectBox(
77
+ 'sentry-triggerMode',
78
+ 'Trigger Mode',
79
+ 'On event: the on parts must happen together, not remembered from earlier events',
80
+ [
81
+ { name: '', value: '' },
82
+ { name: 'Default', value: 'default' },
83
+ { name: 'On Event', value: 'onEvent' }
84
+ ],
85
+ getSentry,
86
+ 'flowable:triggerMode',
87
+ translate,
88
+ function(element) {
89
+ return !getSentry(element);
90
+ }
91
+ ));
92
+
93
+ if (!is(getBusinessObject(element), 'cmmn:ExitCriterion')) {
94
+ return;
95
+ }
96
+
97
+ // what a stage or the case plan model does when it exits
98
+ if (isOnStage(element)) {
99
+ group.entries.push(selectBox(
100
+ 'exitCriterion-exitEventType',
101
+ 'Exit Event Type',
102
+ 'Exit when empty; complete or force complete the stage instead',
103
+ [
104
+ { name: '', value: '' },
105
+ { name: 'Exit', value: 'exit' },
106
+ { name: 'Complete', value: 'complete' },
107
+ { name: 'Force Complete', value: 'forceComplete' }
108
+ ],
109
+ getBusinessObject,
110
+ 'flowable:exitEventType',
111
+ translate
112
+ ));
113
+ }
114
+
115
+ // which instances of a plan item exit
116
+ if (isOnCasePlanModel(element)) {
117
+ return;
118
+ }
119
+
120
+ group.entries.push(selectBox(
121
+ 'exitCriterion-exitType',
122
+ 'Exit Type',
123
+ 'Which instances of the plan item exit; all when empty',
124
+ [
125
+ { name: '', value: '' },
126
+ { name: 'Default', value: 'default' },
127
+ { name: 'Active Instances', value: 'activeInstances' },
128
+ { name: 'Active And Enabled Instances', value: 'activeAndEnabledInstances' }
129
+ ],
130
+ getBusinessObject,
131
+ 'flowable:exitType',
132
+ translate
133
+ ));
134
+ };
@@ -5,9 +5,7 @@ var ListenerEventTypeProp = require('./implementation/ListenerEventTypeProp'),
5
5
  LifecycleTransitionProp = require('./implementation/LifecycleTransitionProp');
6
6
 
7
7
  var CmmnElementHelper = require('../../../helper/CmmnElementHelper'),
8
- isCaseExecutionListenerCapable = CmmnElementHelper.isCaseExecutionListenerCapable,
9
8
  isTaskListenerCapable = CmmnElementHelper.isTaskListenerCapable,
10
- isVariableListenerCapable = CmmnElementHelper.isVariableListenerCapable,
11
9
  isPlanItemLifecycleListenerCapable = CmmnElementHelper.isPlanItemLifecycleListenerCapable,
12
10
  isCaseLifecycleListenerCapable = CmmnElementHelper.isCaseLifecycleListenerCapable;
13
11
 
@@ -19,9 +17,7 @@ module.exports = function(group, element, cmmnFactory, elementRegistry, itemRegi
19
17
  var getListener = options.getListener;
20
18
 
21
19
 
22
- if (!isCaseExecutionListenerCapable(element) &&
23
- !isTaskListenerCapable(element) &&
24
- !isVariableListenerCapable(element) &&
20
+ if (!isTaskListenerCapable(element) &&
25
21
  !isPlanItemLifecycleListenerCapable(element) &&
26
22
  !isCaseLifecycleListenerCapable(element)) {
27
23
  return;
@@ -0,0 +1,131 @@
1
+ 'use strict';
2
+
3
+ var entryFactory = require('../../../factory/EntryFactory'),
4
+ cmdHelper = require('../../../helper/CmdHelper');
5
+
6
+ var ModelUtil = require('@jylups/cmmn-js/lib/util/ModelUtil'),
7
+ getBusinessObject = ModelUtil.getBusinessObject,
8
+ isCasePlanModel = ModelUtil.isCasePlanModel,
9
+ getDefinition = ModelUtil.getDefinition;
10
+
11
+ var CmmnElementHelper = require('../../../helper/CmmnElementHelper'),
12
+ isTask = CmmnElementHelper.isTask,
13
+ isStage = CmmnElementHelper.isStage,
14
+ isMilestone = CmmnElementHelper.isMilestone;
15
+
16
+
17
+ var MAX_INSTANCE_COUNT = /^(unlimited|-1|[1-9]\d*)$/;
18
+
19
+
20
+ /**
21
+ * What Flowable reads on the repetition rule of the item control or the
22
+ * default control: the counter variable, the maximum instance count, and
23
+ * the collection to repeat the plan item for each element of.
24
+ */
25
+ module.exports = function(group, element, itemRegistry, translate, options) {
26
+
27
+ if (isCasePlanModel(element) || (!isTask(element) && !isStage(element) && !isMilestone(element))) {
28
+ return;
29
+ }
30
+
31
+ options = options || {};
32
+
33
+ var isDefaultControl = options.isDefaultControl,
34
+ idPrefix = (isDefaultControl ? 'default' : 'item') + 'Control-repetition-';
35
+
36
+ function getRepetitionRule(element) {
37
+ var bo = isDefaultControl ? getDefinition(element) : getBusinessObject(element),
38
+ control = bo && bo.get(isDefaultControl ? 'defaultControl' : 'itemControl');
39
+
40
+ return control && control.get('repetitionRule');
41
+ }
42
+
43
+ function update(element, properties) {
44
+ var bo = getBusinessObject(element);
45
+
46
+ return cmdHelper.updateProperties(getRepetitionRule(element), properties, itemRegistry.getShapes(bo));
47
+ }
48
+
49
+ function hideEntry(element) {
50
+ return !getRepetitionRule(element);
51
+ }
52
+
53
+ function textField(name, label, description, validate) {
54
+ var id = idPrefix + name;
55
+
56
+ return entryFactory.textField({
57
+ id: id,
58
+ label: translate(label),
59
+ description: description && translate(description),
60
+ modelProperty: name,
61
+
62
+ get: function(element) {
63
+ var rule = getRepetitionRule(element),
64
+ values = {};
65
+
66
+ values[name] = (rule && rule.get('flowable:' + name)) || '';
67
+
68
+ return values;
69
+ },
70
+
71
+ set: function(element, values) {
72
+ var properties = {};
73
+
74
+ properties['flowable:' + name] = values[name] || undefined;
75
+
76
+ return update(element, properties);
77
+ },
78
+
79
+ validate: validate,
80
+ hideEntry: hideEntry
81
+ });
82
+ }
83
+
84
+
85
+ group.entries.push(textField('counterVariable', 'Counter Variable',
86
+ 'Local variable with the number of the instance; repetitionCounter when empty'));
87
+
88
+ group.entries.push(entryFactory.checkbox({
89
+ id: idPrefix + 'ignoreCounterVariable',
90
+ label: translate('Ignore Counter Variable'),
91
+ modelProperty: 'ignoreCounterVariable',
92
+
93
+ get: function(element) {
94
+ var rule = getRepetitionRule(element),
95
+ value = rule && rule.get('flowable:ignoreCounterVariable');
96
+
97
+ return {
98
+ ignoreCounterVariable: !!value && value.toLowerCase() === 'true'
99
+ };
100
+ },
101
+
102
+ set: function(element, values) {
103
+ return update(element, {
104
+ 'flowable:ignoreCounterVariable': values.ignoreCounterVariable ? 'true' : undefined
105
+ });
106
+ },
107
+
108
+ hideEntry: hideEntry
109
+ }));
110
+
111
+ group.entries.push(textField('maxInstanceCount', 'Max Instance Count',
112
+ 'Instances at the same time, a number or unlimited',
113
+ function(element, values) {
114
+ var value = values.maxInstanceCount;
115
+
116
+ if (value && !MAX_INSTANCE_COUNT.test(value.trim())) {
117
+ return { maxInstanceCount: translate('Must be a number above 0, or unlimited') };
118
+ }
119
+
120
+ return {};
121
+ }));
122
+
123
+ group.entries.push(textField('collectionVariable', 'Collection Variable',
124
+ 'Collection, or an expression giving one; an instance is created for each element'));
125
+
126
+ group.entries.push(textField('elementVariable', 'Element Variable',
127
+ 'Local variable with the element of the instance'));
128
+
129
+ group.entries.push(textField('elementIndexVariable', 'Element Index Variable',
130
+ 'Local variable with the index of the element'));
131
+ };
@@ -0,0 +1,125 @@
1
+ 'use strict';
2
+
3
+ var entryFactory = require('../../../factory/EntryFactory'),
4
+ cmdHelper = require('../../../helper/CmdHelper');
5
+
6
+ var ModelUtil = require('@jylups/cmmn-js/lib/util/ModelUtil'),
7
+ is = ModelUtil.is,
8
+ isCasePlanModel = ModelUtil.isCasePlanModel,
9
+ getDefinition = ModelUtil.getDefinition;
10
+
11
+
12
+ var INTEGER = /^-?\d+$/;
13
+
14
+
15
+ function textField(id, label, property, translate, options) {
16
+
17
+ options = options || {};
18
+
19
+ return entryFactory.textField({
20
+ id: id,
21
+ label: translate(label),
22
+ description: options.description && translate(options.description),
23
+ modelProperty: id,
24
+
25
+ get: function(element) {
26
+ var definition = getDefinition(element),
27
+ values = {};
28
+
29
+ values[id] = (definition && definition.get(property)) || '';
30
+
31
+ return values;
32
+ },
33
+
34
+ set: function(element, values) {
35
+ var properties = {};
36
+
37
+ properties[property] = values[id] || undefined;
38
+
39
+ return cmdHelper.updateProperties(getDefinition(element), properties, element);
40
+ },
41
+
42
+ validate: options.validate
43
+ });
44
+ }
45
+
46
+
47
+ /**
48
+ * What Flowable reads on stages and milestones: whether and where they are
49
+ * shown in the stage overview, the business status they set, the milestone
50
+ * variable, and the auto complete condition of a stage.
51
+ */
52
+ module.exports = function(group, element, translate) {
53
+
54
+ var definition = getDefinition(element);
55
+
56
+ var isStage = is(definition, 'cmmn:Stage'),
57
+ isMilestone = is(definition, 'cmmn:Milestone');
58
+
59
+ if (!isStage && !isMilestone) {
60
+ return;
61
+ }
62
+
63
+ // the case plan model is not shown in the stage overview
64
+ if (!isCasePlanModel(element)) {
65
+
66
+ group.entries.push(textField(
67
+ 'stageOverview-includeInStageOverview',
68
+ 'Include In Stage Overview',
69
+ 'flowable:includeInStageOverview',
70
+ translate,
71
+ { description: 'Included when empty; false, or an expression' }
72
+ ));
73
+
74
+ group.entries.push(textField(
75
+ 'stageOverview-displayOrder',
76
+ 'Display Order',
77
+ 'flowable:displayOrder',
78
+ translate,
79
+ {
80
+ description: 'Order in the stage overview, a number',
81
+ validate: function(element, values) {
82
+ var value = values['stageOverview-displayOrder'];
83
+
84
+ if (value && !INTEGER.test(value.trim())) {
85
+ return { 'stageOverview-displayOrder': translate('Must be a whole number') };
86
+ }
87
+
88
+ return {};
89
+ }
90
+ }
91
+ ));
92
+
93
+ group.entries.push(textField(
94
+ 'stageOverview-businessStatus',
95
+ 'Business Status',
96
+ 'flowable:businessStatus',
97
+ translate,
98
+ {
99
+ description: isStage ?
100
+ 'Set on the case when the stage starts' :
101
+ 'Set on the case when the milestone is reached'
102
+ }
103
+ ));
104
+ }
105
+
106
+ if (isMilestone) {
107
+ group.entries.push(textField(
108
+ 'milestone-milestoneVariable',
109
+ 'Milestone Variable',
110
+ 'flowable:milestoneVariable',
111
+ translate,
112
+ { description: 'Set to true when the milestone is reached' }
113
+ ));
114
+ }
115
+
116
+ if (isStage) {
117
+ group.entries.push(textField(
118
+ 'stage-autoCompleteCondition',
119
+ 'Auto Complete Condition',
120
+ 'flowable:autoCompleteCondition',
121
+ translate,
122
+ { description: 'While it holds, the stage completes once no plan item is active' }
123
+ ));
124
+ }
125
+ };
@@ -33,6 +33,13 @@ function getVariableMappings(bo, type, reference) {
33
33
  });
34
34
  }
35
35
 
36
+ /**
37
+ * Whether a mapping writes to a variable or to an expression.
38
+ */
39
+ function getTargetType(mapping) {
40
+ return mapping && typeof mapping.targetExpression !== 'undefined' ? 'targetExpression' : 'target';
41
+ }
42
+
36
43
  function getInOutType(mapping) {
37
44
  var inOutType = 'source';
38
45
 
@@ -204,10 +211,6 @@ module.exports = function(group, element, cmmnFactory, elementRegistry, itemRegi
204
211
  {
205
212
  name: translate('Source Expression'),
206
213
  value: 'sourceExpression'
207
- },
208
- {
209
- name: translate('All'),
210
- value: 'variables'
211
214
  }
212
215
  ],
213
216
  modelProperty: 'inOutType',
@@ -227,14 +230,10 @@ module.exports = function(group, element, cmmnFactory, elementRegistry, itemRegi
227
230
  'variables' : undefined
228
231
  };
229
232
 
230
- if (inOutType === 'source') {
231
- props.source = '';
232
- }
233
- else if (inOutType === 'sourceExpression') {
233
+ if (inOutType === 'sourceExpression') {
234
234
  props.sourceExpression = '';
235
- }
236
- else if (inOutType === 'variables') {
237
- props.variables = 'all';
235
+ } else {
236
+ props.source = '';
238
237
  }
239
238
 
240
239
  var mapping = getSelected(element, node);
@@ -302,20 +301,61 @@ module.exports = function(group, element, cmmnFactory, elementRegistry, itemRegi
302
301
  }));
303
302
 
304
303
 
304
+ // target or target expression
305
+
306
+ group.entries.push(entryFactory.selectBox({
307
+ id: 'variableMapping-targetType',
308
+ label: translate('Target Type'),
309
+ selectOptions: [
310
+ { name: translate('Target'), value: 'target' },
311
+ { name: translate('Target Expression'), value: 'targetExpression' }
312
+ ],
313
+ modelProperty: 'targetType',
314
+ reference: 'definitionRef',
315
+ get: function(element, node) {
316
+ return {
317
+ targetType: getTargetType(getSelected(element, node) || {})
318
+ };
319
+ },
320
+ set: function(element, values, node) {
321
+ var mapping = getSelected(element, node),
322
+ current = getTargetType(mapping),
323
+ props = {};
324
+
325
+ if (values.targetType !== current) {
326
+ props[values.targetType] = mapping.get(current) || '';
327
+ props[current] = undefined;
328
+ }
329
+
330
+ return cmdHelper.updateBusinessObject(element, mapping, props);
331
+ },
332
+ disabled: function(element, node) {
333
+ return !isSelected(element, node);
334
+ }
335
+ }));
336
+
337
+
305
338
  group.entries.push(entryFactory.textField({
306
339
  id: 'variableMapping-target',
307
- label: translate('Target'),
340
+ dataValueLabel: 'targetLabel',
308
341
  modelProperty: 'target',
309
342
  reference: 'definitionRef',
310
343
  get: function(element, node) {
344
+ var mapping = getSelected(element, node) || {},
345
+ targetType = getTargetType(mapping);
346
+
311
347
  return {
312
- target: (getSelected(element, node) || {}).target
348
+ target: mapping[targetType],
349
+ targetLabel: targetType === 'targetExpression' ? translate('Target Expression') : translate('Target')
313
350
  };
314
351
  },
315
352
  set: function(element, values, node) {
316
- values.target = values.target || undefined;
317
- var mapping = getSelected(element, node);
318
- return cmdHelper.updateBusinessObject(element, mapping, values);
353
+ var mapping = getSelected(element, node),
354
+ props = {};
355
+
356
+ props[getTargetType(mapping)] = values.target || undefined;
357
+
358
+ return cmdHelper.updateBusinessObject(element, mapping, props);
319
359
  },
320
360
  validate: function(element, values, node) {
321
361
  var mapping = getSelected(element, node);
@@ -337,24 +377,60 @@ module.exports = function(group, element, cmmnFactory, elementRegistry, itemRegi
337
377
  }));
338
378
 
339
379
 
380
+ // the variable types Flowable converts the value from and to
381
+
382
+ [
383
+ [ 'sourceType', translate('Source Variable Type') ],
384
+ [ 'targetType', translate('Target Variable Type') ]
385
+ ].forEach(function(field) {
386
+
387
+ var property = field[0],
388
+ modelProperty = 'variable-' + property;
389
+
390
+ group.entries.push(entryFactory.textField({
391
+ id: 'variableMapping-variable-' + property,
392
+ label: field[1],
393
+ description: translate('For example string, integer or date'),
394
+ modelProperty: modelProperty,
395
+ reference: 'definitionRef',
396
+ get: function(element, node) {
397
+ var values = {};
398
+
399
+ values[modelProperty] = (getSelected(element, node) || {})[property];
400
+
401
+ return values;
402
+ },
403
+ set: function(element, values, node) {
404
+ var props = {};
405
+
406
+ props[property] = values[modelProperty] || undefined;
407
+
408
+ return cmdHelper.updateBusinessObject(element, getSelected(element, node), props);
409
+ },
410
+ disabled: function(element, node) {
411
+ return !isSelected(element, node);
412
+ }
413
+ }));
414
+ });
415
+
416
+
340
417
  group.entries.push(entryFactory.checkbox({
341
- id: 'variableMapping-local',
342
- label: translate('Local'),
343
- modelProperty: 'local',
418
+ id: 'variableMapping-transient',
419
+ label: translate('Transient'),
420
+ modelProperty: 'transient',
344
421
  reference: 'definitionRef',
345
422
  get: function(element, node) {
346
423
  return {
347
- local: (getSelected(element, node) || {}).local
424
+ 'transient': (getSelected(element, node) || {})['transient'] === 'true'
348
425
  };
349
426
  },
350
427
  set: function(element, values, node) {
351
- values.local = values.local || false;
352
- var mapping = getSelected(element, node);
353
- return cmdHelper.updateBusinessObject(element, mapping, values);
428
+ return cmdHelper.updateBusinessObject(element, getSelected(element, node), {
429
+ 'transient': values['transient'] ? 'true' : undefined
430
+ });
354
431
  },
355
432
  disabled: function(element, node) {
356
- var selectedMapping = getSelected(element, node);
357
- return !selectedMapping || is(selectedMapping, FLOWABLE_OUT_EXTENSION_ELEMENT);
433
+ return !isSelected(element, node);
358
434
  }
359
435
  }));
360
436
 
@@ -2,8 +2,6 @@
2
2
 
3
3
  var is = require('@jylups/cmmn-js/lib/util/ModelUtil').is;
4
4
 
5
- var TransitionProp = require('../../../cmmn/parts/implementation/TransitionProp');
6
-
7
5
  var cmdHelper = require('../../../../helper/CmdHelper'),
8
6
  entryFactory = require('../../../../factory/EntryFactory');
9
7
 
@@ -54,22 +52,6 @@ module.exports = function(element, translate, options) {
54
52
  };
55
53
 
56
54
 
57
- var caseExecutionListenerEventEntry = TransitionProp(element, translate, {
58
-
59
- id: 'caseExecutionListener' + idSuffix,
60
- label: label,
61
- modelProperty: modelProperty,
62
- reference: reference,
63
- emptyParameter: true,
64
-
65
- get: getEventType,
66
- set: setEventType,
67
- hideEntry: hideEntry('flowable:CaseExecutionListener'),
68
- validate: validate
69
-
70
- })[0];
71
-
72
-
73
55
  var taskListenerEventEntry = entryFactory.selectBox({
74
56
 
75
57
  id: 'taskListener' + idSuffix,
@@ -92,27 +74,6 @@ module.exports = function(element, translate, options) {
92
74
  });
93
75
 
94
76
 
95
- var variableListenerEventEntry = entryFactory.selectBox({
96
-
97
- id: 'variableListener' + idSuffix,
98
- label: label,
99
- modelProperty: modelProperty,
100
- reference: reference,
101
- selectOptions: [
102
- { name: translate('create'), value: 'create' },
103
- { name: translate('update'), value: 'update' },
104
- { name: translate('delete'), value: 'delete' }
105
- ],
106
- emptyParameter: true,
107
-
108
- get: getEventType,
109
- set: setEventType,
110
- hideEntry: hideEntry('flowable:VariableListener'),
111
- validate: validate
112
-
113
- });
114
-
115
-
116
- return [ caseExecutionListenerEventEntry, taskListenerEventEntry, variableListenerEventEntry ];
77
+ return [ taskListenerEventEntry ];
117
78
 
118
79
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cmmn-js-properties-panel-flowable",
3
- "version": "2.0.0-next.2",
3
+ "version": "2.0.0-next.4",
4
4
  "description": "A simple properties panel for cmmn-js with flowable namespaces",
5
5
  "scripts": {
6
6
  "lint": "eslint .",
@@ -28,12 +28,12 @@
28
28
  },
29
29
  "license": "MIT",
30
30
  "devDependencies": {
31
- "@jylups/cmmn-js": "^0.22.0-next.8",
31
+ "@jylups/cmmn-js": "^0.22.0-next.9",
32
32
  "chai": "^4.1.2",
33
33
  "diagram-js": "^15.29.0",
34
34
  "eslint": "^5.2.0",
35
35
  "eslint-plugin-bpmn-io": "^0.5.3",
36
- "flowable-cmmn-moddle": "^1.2.0-next.7",
36
+ "flowable-cmmn-moddle": "^1.2.0-next.9",
37
37
  "karma": "^4.1.0",
38
38
  "karma-chrome-launcher": "^2.2.0",
39
39
  "karma-firefox-launcher": "^1.0.1",
@@ -1,31 +0,0 @@
1
- 'use strict';
2
-
3
- var CmmnElementHelper = require('../../../helper/CmmnElementHelper'),
4
- isCaseExecutionListenerCapable = CmmnElementHelper.isCaseExecutionListenerCapable,
5
- isMilestone = CmmnElementHelper.isMilestone,
6
- isEventListener = CmmnElementHelper.isEventListener;
7
-
8
- var listenerElements = require('./implementation/ListenerElements');
9
-
10
- module.exports = function(group, element, cmmnFactory, elementRegistry, itemRegistry, cmmnRules, translate, options) {
11
-
12
- var initialEvent = isMilestone(element) || isEventListener(element) ? 'occur' : 'complete';
13
-
14
- var listenerProps = listenerElements(element, cmmnFactory, translate, {
15
- id: 'caseExecutionListeners',
16
- label: translate('Case Execution Listener'),
17
- type: 'flowable:CaseExecutionListener',
18
- initialEvent: initialEvent,
19
- isApplicable: isCaseExecutionListenerCapable
20
- });
21
-
22
- if (listenerProps.entries && listenerProps.entries.length) {
23
- group.entries = group.entries.concat(listenerProps.entries);
24
- }
25
-
26
- return {
27
- register : listenerProps.register,
28
- getSelectedListener: listenerProps.getSelectedListener
29
- };
30
-
31
- };
@@ -1,27 +0,0 @@
1
- 'use strict';
2
-
3
- var isVariableListenerCapable = require('../../../helper/CmmnElementHelper').isVariableListenerCapable;
4
-
5
- var listenerElements = require('./implementation/ListenerElements');
6
-
7
- module.exports = function(group, element, cmmnFactory, elementRegistry, itemRegistry, cmmnRules, translate, options) {
8
-
9
-
10
- var listenerProps = listenerElements(element, cmmnFactory, translate, {
11
- id: 'variableListeners',
12
- label: translate('Variable Listener'),
13
- type: 'flowable:VariableListener',
14
- initialEvent: 'update',
15
- isApplicable: isVariableListenerCapable
16
- });
17
-
18
- if (listenerProps.entries && listenerProps.entries.length) {
19
- group.entries = group.entries.concat(listenerProps.entries);
20
- }
21
-
22
- return {
23
- register : listenerProps.register,
24
- getSelectedListener: listenerProps.getSelectedListener
25
- };
26
-
27
- };
@@ -1,109 +0,0 @@
1
- 'use strict';
2
-
3
- var entryFactory = require('../../../../factory/EntryFactory');
4
-
5
- var extensionElementsHelper = require('../../../../helper/ExtensionElementsHelper'),
6
- elementHelper = require('../../../../helper/ElementHelper'),
7
- cmdHelper = require('../../../../helper/CmdHelper');
8
-
9
- var ModelUtil = require('@jylups/cmmn-js/lib/util/ModelUtil'),
10
- getDefinition = ModelUtil.getDefinition;
11
-
12
- var forEach = require('lodash/forEach');
13
-
14
-
15
- var BUSINESS_KEY_VALUE = '#{caseExecution.caseBusinessKey}';
16
-
17
- function getCamundaInWithBusinessKey(element) {
18
- var camundaIn = [],
19
- bo = getDefinition(element);
20
-
21
- var camundaInParams = bo && extensionElementsHelper.getExtensionElements(bo, 'flowable:In');
22
- if (camundaInParams) {
23
- forEach(camundaInParams, function(param) {
24
- if (param.businessKey) {
25
- camundaIn.push(param);
26
- }
27
- });
28
- }
29
- return camundaIn;
30
- }
31
-
32
- function setBusinessKey(element, cmmnFactory) {
33
- var bo = getDefinition(element),
34
- commands = [];
35
-
36
- var extensionElements = bo && bo.extensionElements;
37
-
38
- if (!extensionElements) {
39
- extensionElements = elementHelper.createElement('cmmn:ExtensionElements', { values: [] }, bo, cmmnFactory);
40
-
41
- commands.push(cmdHelper.updateProperties(bo, { extensionElements: extensionElements }));
42
- }
43
-
44
- var camundaIn = elementHelper.createElement(
45
- 'flowable:In',
46
- { 'businessKey': BUSINESS_KEY_VALUE },
47
- extensionElements,
48
- cmmnFactory
49
- );
50
-
51
- commands.push(cmdHelper.addAndRemoveElementsFromList(
52
- element,
53
- extensionElements,
54
- 'values',
55
- 'extensionElements',
56
- [ camundaIn ]
57
- ));
58
-
59
- return commands;
60
- }
61
-
62
- function deleteBusinessKey(element) {
63
- var camundaInExtensions = getCamundaInWithBusinessKey(element),
64
- commands = [];
65
-
66
- forEach(camundaInExtensions, function(elem) {
67
- commands.push(extensionElementsHelper.removeEntry(getDefinition(element), element, elem));
68
- });
69
-
70
- return commands;
71
- }
72
-
73
-
74
- module.exports = function(element, cmmnFactory, translate, options) {
75
-
76
- options = options || {};
77
-
78
- var id = options.id,
79
- label = options.label,
80
- reference = options.reference,
81
- modelProperty = options.modelProperty;
82
-
83
-
84
- var businessKeyEntry = entryFactory.checkbox({
85
- id: id || 'business-key',
86
- label: label || translate('Business Key'),
87
- modelProperty: modelProperty,
88
- reference: reference,
89
-
90
- get: function(element, node) {
91
- var camundaIn = getCamundaInWithBusinessKey(element);
92
-
93
- return {
94
- callableBusinessKey: !!(camundaIn && camundaIn.length > 0)
95
- };
96
- },
97
-
98
- set: function(element, values, node) {
99
- if (values.callableBusinessKey) {
100
- return setBusinessKey(element, cmmnFactory);
101
- } else {
102
- return deleteBusinessKey(element);
103
- }
104
- }
105
- });
106
-
107
- return businessKeyEntry;
108
-
109
- };