DocumentationProps.js
1.99 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
64
65
66
67
68
69
70
71
72
73
'use strict';
var entryFactory = require('../../../factory/EntryFactory'),
cmdHelper = require('../../../helper/CmdHelper');
var ModelUtil = require('bpmn-js/lib/util/ModelUtil'),
is = ModelUtil.is,
getBusinessObject = ModelUtil.getBusinessObject;
module.exports = function(group, element, bpmnFactory, translate) {
var getValue = function(businessObject) {
return function(element) {
var documentations = businessObject && businessObject.get('documentation'),
text = (documentations && documentations.length > 0) ? documentations[0].text : '';
return { documentation: text };
};
};
var setValue = function(businessObject) {
return function(element, values) {
var newObjectList = [];
if (typeof values.documentation !== 'undefined' && values.documentation !== '') {
newObjectList.push(bpmnFactory.create('bpmn:Documentation', {
text: values.documentation
}));
}
return cmdHelper.setList(element, businessObject, 'documentation', newObjectList);
};
};
// Element Documentation
var elementDocuEntry = entryFactory.textBox({
id: 'documentation',
label: translate('Element Documentation'),
modelProperty: 'documentation'
});
elementDocuEntry.set = setValue(getBusinessObject(element));
elementDocuEntry.get = getValue(getBusinessObject(element));
group.entries.push(elementDocuEntry);
var processRef;
// Process Documentation when having a Collaboration Diagram
if (is(element, 'bpmn:Participant')) {
processRef = getBusinessObject(element).processRef;
// do not show for collapsed Pools/Participants
if (processRef) {
var processDocuEntry = entryFactory.textBox({
id: 'process-documentation',
label: translate('Process Documentation'),
modelProperty: 'documentation'
});
processDocuEntry.set = setValue(processRef);
processDocuEntry.get = getValue(processRef);
group.entries.push(processDocuEntry);
}
}
};