NameProps.js
1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
'use strict';
var nameEntryFactory = require('./implementation/Name'),
createCategoryValue = require('../../../helper/CategoryHelper').createCategoryValue,
is = require('bpmn-js/lib/util/ModelUtil').is,
getBusinessObject = require('bpmn-js/lib/util/ModelUtil').getBusinessObject;
module.exports = function(group, element, bpmnFactory, canvas, translate) {
function initializeCategory(semantic) {
var rootElement = canvas.getRootElement(),
definitions = getBusinessObject(rootElement).$parent,
categoryValue = createCategoryValue(definitions, bpmnFactory);
semantic.categoryValueRef = categoryValue;
}
function setGroupName(element, values) {
var bo = getBusinessObject(element),
categoryValueRef = bo.categoryValueRef;
if (!categoryValueRef) {
initializeCategory(bo);
}
// needs direct call to update categoryValue properly
return {
cmd: 'element.updateLabel',
context: {
element: element,
newLabel: values.categoryValue
}
};
}
function getGroupName(element) {
var bo = getBusinessObject(element),
value = (bo.categoryValueRef || {}).value;
return { categoryValue: value };
}
if (!is(element, 'bpmn:Collaboration')) {
var options;
if (is(element, 'bpmn:TextAnnotation')) {
options = { modelProperty: 'text', label: translate('Text') };
} else if (is(element, 'bpmn:Group')) {
options = {
modelProperty: 'categoryValue',
label: translate('Category Value'),
get: getGroupName,
set: setGroupName
};
}
// name
group.entries = group.entries.concat(nameEntryFactory(element, options, translate));
}
};