ProcessProps.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. 'use strict';
  2. var is = require('bpmn-js/lib/util/ModelUtil').is,
  3. entryFactory = require('../../../factory/EntryFactory'),
  4. participantHelper = require('../../../helper/ParticipantHelper'),
  5. getBusinessObject = require('bpmn-js/lib/util/ModelUtil').getBusinessObject,
  6. nameEntryFactory = require('./implementation/Name'),
  7. utils = require('../../../Utils');
  8. module.exports = function(group, element, translate, options) {
  9. var businessObject = getBusinessObject(element);
  10. var processIdDescription = options && options.processIdDescription;
  11. if (is(element, 'bpmn:Process') || (is(element, 'bpmn:Participant') && businessObject.get('processRef'))) {
  12. /**
  13. * processId
  14. */
  15. if (is(element, 'bpmn:Participant')) {
  16. var idEntry = entryFactory.validationAwareTextField({
  17. id: 'process-id',
  18. label: translate('Process Id'),
  19. description: processIdDescription && translate(processIdDescription),
  20. modelProperty: 'processId'
  21. });
  22. // in participants we have to change the default behavior of set and get
  23. idEntry.get = function(element) {
  24. var properties = participantHelper.getProcessBusinessObject(element, 'id');
  25. return { processId: properties.id };
  26. };
  27. idEntry.set = function(element, values) {
  28. return participantHelper.modifyProcessBusinessObject(element, 'id', { id: values.processId });
  29. };
  30. idEntry.validate = function(element, values) {
  31. var idValue = values.processId;
  32. var bo = getBusinessObject(element);
  33. var processIdError = utils.isIdValid(bo.processRef, idValue, translate);
  34. return processIdError ? { processId: processIdError } : {};
  35. };
  36. group.entries.push(idEntry);
  37. /**
  38. * process name
  39. */
  40. var processNameEntry = nameEntryFactory(element, {
  41. id: 'process-name',
  42. label: translate('Process Name')
  43. })[0];
  44. // in participants we have to change the default behavior of set and get
  45. processNameEntry.get = function(element) {
  46. return participantHelper.getProcessBusinessObject(element, 'name');
  47. };
  48. processNameEntry.set = function(element, values) {
  49. return participantHelper.modifyProcessBusinessObject(element, 'name', values);
  50. };
  51. group.entries.push(processNameEntry);
  52. }
  53. }
  54. };