dbd12cb631242faadd21724b63d380db10059a0d
[sdc/sdc-workflow-designer.git] /
1 import inherits from 'inherits';
2
3 import ImplementationTypeHelper from 'bpmn-js-properties-panel/lib/helper/ImplementationTypeHelper';
4 import ServiceTaskDelegateProps from 'bpmn-js-properties-panel/lib/provider/camunda/parts/ServiceTaskDelegateProps';
5 import workflowImplementationType from './implementation/WorkflowImplementationType';
6 import workflowActivity from './implementation/WorkflowActivity';
7 import { implementationType as implementationTypeConst } from './implementation/implementationConstants';
8
9 const getImplementationType = element => {
10     let implementationType = ImplementationTypeHelper.getImplementationType(
11         element
12     );
13
14     if (!implementationType) {
15         const bo = getBusinessObject(element);
16         if (bo) {
17             if (
18                 typeof bo.get(implementationTypeConst.ACTIVITY) !== 'undefined'
19             ) {
20                 return 'workflowActivity';
21             }
22         }
23     }
24
25     return implementationType;
26 };
27
28 const getBusinessObject = element =>
29     ImplementationTypeHelper.getServiceTaskLikeBusinessObject(element);
30
31 const isDmnCapable = element => ImplementationTypeHelper.isDmnCapable(element);
32
33 const isExternalCapable = element =>
34     ImplementationTypeHelper.isExternalCapable(element);
35
36 const isServiceTaskLike = element =>
37     ImplementationTypeHelper.isServiceTaskLike(element);
38
39 function WorkflowServiceTaskDelegateProps(
40     group,
41     element,
42     config,
43     bpmnFactory,
44     translate
45 ) {
46     ServiceTaskDelegateProps.call(this, group, element, bpmnFactory, translate);
47
48     if (isServiceTaskLike(getBusinessObject(element))) {
49         group.entries = group.entries.filter(
50             entry => entry.id !== 'implementation'
51         );
52
53         group.entries = [
54             ...workflowImplementationType(
55                 element,
56                 bpmnFactory,
57                 {
58                     getBusinessObject: getBusinessObject,
59                     getImplementationType: getImplementationType,
60                     hasDmnSupport: isDmnCapable(element),
61                     hasExternalSupport: isExternalCapable(
62                         getBusinessObject(element)
63                     ),
64                     hasServiceTaskLikeSupport: true
65                 },
66                 translate
67             ),
68             ...group.entries,
69             ...workflowActivity(
70                 element,
71                 config,
72                 bpmnFactory,
73                 {
74                     getBusinessObject: getBusinessObject,
75                     getImplementationType: getImplementationType
76                 },
77                 translate
78             )
79         ];
80     }
81 }
82
83 inherits(WorkflowServiceTaskDelegateProps, ServiceTaskDelegateProps);
84
85 export default WorkflowServiceTaskDelegateProps;