DocumentationProps.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. 'use strict';
  2. var entryFactory = require('../../../factory/EntryFactory'),
  3. cmdHelper = require('../../../helper/CmdHelper');
  4. var ModelUtil = require('bpmn-js/lib/util/ModelUtil'),
  5. is = ModelUtil.is,
  6. getBusinessObject = ModelUtil.getBusinessObject;
  7. module.exports = function(group, element, bpmnFactory, translate) {
  8. var getValue = function(businessObject) {
  9. return function(element) {
  10. var documentations = businessObject && businessObject.get('documentation'),
  11. text = (documentations && documentations.length > 0) ? documentations[0].text : '';
  12. return { documentation: text };
  13. };
  14. };
  15. var setValue = function(businessObject) {
  16. return function(element, values) {
  17. var newObjectList = [];
  18. if (typeof values.documentation !== 'undefined' && values.documentation !== '') {
  19. newObjectList.push(bpmnFactory.create('bpmn:Documentation', {
  20. text: values.documentation
  21. }));
  22. }
  23. return cmdHelper.setList(element, businessObject, 'documentation', newObjectList);
  24. };
  25. };
  26. // Element Documentation
  27. var elementDocuEntry = entryFactory.textBox({
  28. id: 'documentation',
  29. label: translate('Element Documentation'),
  30. modelProperty: 'documentation'
  31. });
  32. elementDocuEntry.set = setValue(getBusinessObject(element));
  33. elementDocuEntry.get = getValue(getBusinessObject(element));
  34. group.entries.push(elementDocuEntry);
  35. var processRef;
  36. // Process Documentation when having a Collaboration Diagram
  37. if (is(element, 'bpmn:Participant')) {
  38. processRef = getBusinessObject(element).processRef;
  39. // do not show for collapsed Pools/Participants
  40. if (processRef) {
  41. var processDocuEntry = entryFactory.textBox({
  42. id: 'process-documentation',
  43. label: translate('Process Documentation'),
  44. modelProperty: 'documentation'
  45. });
  46. processDocuEntry.set = setValue(processRef);
  47. processDocuEntry.get = getValue(processRef);
  48. group.entries.push(processDocuEntry);
  49. }
  50. }
  51. };