-
Notifications
You must be signed in to change notification settings - Fork 43
/
subProcess.vue
160 lines (151 loc) · 4.73 KB
/
subProcess.vue
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<template>
<crown-config
:highlighted="highlighted"
:paper="paper"
:graph="graph"
:shape="shape"
:node="node"
:nodeRegistry="nodeRegistry"
:moddle="moddle"
:collaboration="collaboration"
:process-node="processNode"
:plane-elements="planeElements"
:is-rendering="isRendering"
:boundary-event-dropdown-data="boundaryEventDropdownData"
:dropdown-data="dropdownData"
v-on="$listeners"
/>
</template>
<script>
import { util } from 'jointjs';
import portsConfig from '@/mixins/portsConfig';
import TaskShape from '@/components/nodes/task/shape';
import { taskHeight } from '@/components/nodes/task/taskConfig';
import store from '@/store';
import uniqBy from 'lodash/uniqBy';
import hasMarkers, { markerSize } from '@/mixins/hasMarkers';
import hideLabelOnDrag from '@/mixins/hideLabelOnDrag';
import { elementIdParser } from '@/components/nodes/subProcess/elementIdParser';
import CrownConfig from '@/components/crown/crownConfig/crownConfig';
import highlightConfig from '@/mixins/highlightConfig';
const labelPadding = 15;
const topAndBottomMarkersSpace = 2 * markerSize;
export default {
components: {
CrownConfig,
},
props: [
'graph',
'node',
'id',
'highlighted',
'nodeRegistry',
'moddle',
'paper',
'collaboration',
'processNode',
'planeElements',
'isRendering',
],
mixins: [highlightConfig, portsConfig, hasMarkers, hideLabelOnDrag],
data() {
return {
boundaryEventDropdownData: [
{
label: 'Boundary Timer Event',
nodeType: 'processmaker-modeler-boundary-timer-event',
dataTest: 'add-boundary-timer-event',
},
{
label: 'Boundary Error Event',
nodeType: 'processmaker-modeler-boundary-error-event',
dataTest: 'add-boundary-error-event',
},
{
label: 'Boundary Message Event',
nodeType: 'processmaker-modeler-boundary-message-event',
dataTest: 'add-boundary-message-event',
},
],
dropdownData: [
{
label: 'Task',
nodeType: 'processmaker-modeler-task',
dataTest: 'switch-to-user-task',
},
{
label: 'Manual Task',
nodeType: 'processmaker-modeler-manual-task',
dataTest: 'switch-to-manual-task',
},
{
label: 'Script Task',
nodeType: 'processmaker-modeler-script-task',
dataTest: 'switch-to-script-task',
},
{
label: 'Sub Process',
nodeType: 'processmaker-modeler-call-activity',
dataTest: 'switch-to-sub-process',
},
],
};
},
watch: {
'node.definition.name'(name) {
const { width } = this.node.diagram.bounds;
this.shape.attr('label/text', util.breakText(name, { width }));
/* Update shape height if label text overflows */
const labelHeight = this.shapeView.selectors.label.getBBox().height;
const { height } = this.shape.size();
if (labelHeight + labelPadding + topAndBottomMarkersSpace !== height) {
const newHeight = Math.max(labelHeight + labelPadding + topAndBottomMarkersSpace, taskHeight);
this.node.diagram.bounds.height = newHeight;
this.shape.resize(width, newHeight);
this.recalcMarkersAlignment();
}
},
'node.definition.calledElement'(calledElement) {
if (!calledElement) {
return;
}
const { ownerProcessId, processId } = elementIdParser(calledElement);
const calledSubProcess = store.getters.globalProcesses
.find(process => process.id == processId);
let calledElementName = calledSubProcess.name;
if (uniqBy(calledSubProcess.events, 'ownerProcessName').length > 1) {
const calledSubProcess = calledSubProcess.events.find(event => event.ownerProcessId == ownerProcessId);
calledElementName += ` (${calledSubProcess.ownerProcessName})`;
}
store.commit('updateNodeProp', {
node: this.node,
key: 'name',
value: calledElementName,
});
this.$emit('save-state');
},
'node.definition.callActivityType'(callActivityType) {
this.shape.attr('image/display', callActivityType === 'globalTask' ? 'none' : 'initial');
},
},
mounted() {
this.shape = new TaskShape();
let bounds = this.node.diagram.bounds;
this.shape.position(bounds.x, bounds.y);
this.shape.resize(bounds.width, bounds.height);
this.shape.attr({
body: {
rx: 8,
ry: 8,
strokeWidth: 4,
},
label: {
text: util.breakText(this.node.definition.get('name'), { width: bounds.width }),
fill: 'black',
},
});
this.shape.addTo(this.graph);
this.shape.component = this;
},
};
</script>