Skip to content

Commit 89d67dc

Browse files
authored
prettier w/ burnettk (#135)
Co-authored-by: jasquat <[email protected]>
1 parent 4779c13 commit 89d67dc

File tree

72 files changed

+2198
-1797
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2198
-1797
lines changed

app/spiffworkflow/DataObject/DataObjectHelpers.js

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
*/
66

77
export function findDataObjects(parent, dataObjects) {
8-
if (typeof (dataObjects) === 'undefined')
9-
dataObjects = [];
8+
if (typeof dataObjects === 'undefined') dataObjects = [];
109
let process;
1110
if (!parent) {
1211
return [];
@@ -18,10 +17,9 @@ export function findDataObjects(parent, dataObjects) {
1817
if (process.$type === 'bpmn:SubProcess')
1918
findDataObjects(process.$parent, dataObjects);
2019
}
21-
if (typeof (process.flowElements) !== 'undefined') {
20+
if (typeof process.flowElements !== 'undefined') {
2221
for (const element of process.flowElements) {
23-
if (element.$type === 'bpmn:DataObject')
24-
dataObjects.push(element);
22+
if (element.$type === 'bpmn:DataObject') dataObjects.push(element);
2523
}
2624
}
2725
return dataObjects;
@@ -40,23 +38,27 @@ export function findDataObjectReferences(children, dataObjectId) {
4038
return [];
4139
}
4240
return children.flatMap((child) => {
43-
if (child.$type == 'bpmn:DataObjectReference' && child.dataObjectRef.id == dataObjectId)
41+
if (
42+
child.$type == 'bpmn:DataObjectReference' &&
43+
child.dataObjectRef.id == dataObjectId
44+
)
4445
return [child];
4546
else if (child.$type == 'bpmn:SubProcess')
4647
return findDataObjectReferences(child.get('flowElements'), dataObjectId);
47-
else
48-
return [];
48+
else return [];
4949
});
5050
}
5151

5252
export function findDataObjectReferenceShapes(children, dataObjectId) {
5353
return children.flatMap((child) => {
54-
if (child.type == 'bpmn:DataObjectReference' && child.businessObject.dataObjectRef.id == dataObjectId)
54+
if (
55+
child.type == 'bpmn:DataObjectReference' &&
56+
child.businessObject.dataObjectRef.id == dataObjectId
57+
)
5558
return [child];
5659
else if (child.type == 'bpmn:SubProcess')
5760
return findDataObjectReferenceShapes(child.children, dataObjectId);
58-
else
59-
return [];
61+
else return [];
6062
});
6163
}
6264

@@ -69,10 +71,21 @@ export function idToHumanReadableName(id) {
6971
}
7072
}
7173

72-
export function updateDataObjectReferencesName(parent, nameValue, dataObjectId, commandStack) {
73-
const references = findDataObjectReferenceShapes(parent.children, dataObjectId);
74+
export function updateDataObjectReferencesName(
75+
parent,
76+
nameValue,
77+
dataObjectId,
78+
commandStack
79+
) {
80+
const references = findDataObjectReferenceShapes(
81+
parent.children,
82+
dataObjectId
83+
);
7484
for (const ref of references) {
75-
const stateName = ref.businessObject.dataState && ref.businessObject.dataState.name ? ref.businessObject.dataState.name : '';
85+
const stateName =
86+
ref.businessObject.dataState && ref.businessObject.dataState.name
87+
? ref.businessObject.dataState.name
88+
: '';
7689
const newName = stateName ? `${nameValue} [${stateName}]` : nameValue;
7790
commandStack.execute('element.updateProperties', {
7891
element: ref,

app/spiffworkflow/DataObject/DataObjectInterceptor.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@ const HIGH_PRIORITY = 1500;
2121
* 4) Don't allow someone to move a DataObjectReference from one process to another process.
2222
*/
2323
export default class DataObjectInterceptor extends CommandInterceptor {
24-
2524
constructor(eventBus, bpmnFactory, commandStack, bpmnUpdater) {
2625
super(eventBus);
2726

2827
/* The default behavior is to move the data object into whatever object the reference is being created in.
2928
* If a data object already has a parent, don't change it.
3029
*/
31-
bpmnUpdater.updateSemanticParent = (businessObject, parentBusinessObject) => {
30+
bpmnUpdater.updateSemanticParent = (
31+
businessObject,
32+
parentBusinessObject
33+
) => {
3234
// Special case for participant - which is a valid place to drop a data object, but it needs to be added
3335
// to the particpant's Process (which isn't directly accessible in BPMN.io
3436
let realParent = parentBusinessObject;
@@ -42,20 +44,24 @@ export default class DataObjectInterceptor extends CommandInterceptor {
4244
// when the shape is deleted, but not interested in refactoring at the moment.
4345
if (realParent != null) {
4446
const flowElements = realParent.get('flowElements');
45-
const existingElement = flowElements.find(i => i.id === 1);
47+
const existingElement = flowElements.find((i) => i.id === 1);
4648
if (!existingElement) {
4749
flowElements.push(businessObject);
4850
}
4951
}
5052
} else if (is(businessObject, 'bpmn:DataObject')) {
5153
// For data objects, only update the flowElements for new data objects, and set the parent so it doesn't get moved.
52-
if (typeof (businessObject.$parent) === 'undefined') {
54+
if (typeof businessObject.$parent === 'undefined') {
5355
const flowElements = realParent.get('flowElements');
5456
flowElements.push(businessObject);
5557
businessObject.$parent = realParent;
5658
}
5759
} else {
58-
bpmnUpdater.__proto__.updateSemanticParent.call(bpmnUpdater, businessObject, parentBusinessObject);
60+
bpmnUpdater.__proto__.updateSemanticParent.call(
61+
bpmnUpdater,
62+
businessObject,
63+
parentBusinessObject
64+
);
5965
}
6066
};
6167

@@ -131,15 +137,22 @@ export default class DataObjectInterceptor extends CommandInterceptor {
131137
}
132138
const flowElements = parent.get('flowElements');
133139
collectionRemove(flowElements, shape.businessObject);
134-
const references = findDataObjectReferences(flowElements, dataObject.id);
140+
const references = findDataObjectReferences(
141+
flowElements,
142+
dataObject.id
143+
);
135144
if (references.length === 0) {
136145
const dataFlowElements = dataObject.$parent.get('flowElements');
137146
collectionRemove(dataFlowElements, dataObject);
138147
}
139148
}
140149
});
141-
142150
}
143151
}
144152

145-
DataObjectInterceptor.$inject = ['eventBus', 'bpmnFactory', 'commandStack', 'bpmnUpdater'];
153+
DataObjectInterceptor.$inject = [
154+
'eventBus',
155+
'bpmnFactory',
156+
'commandStack',
157+
'bpmnUpdater',
158+
];
Lines changed: 64 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,77 @@
11
import { is } from 'bpmn-js/lib/util/ModelUtil';
2-
import { findDataObject, updateDataObjectReferencesName } from './DataObjectHelpers';
2+
import {
3+
findDataObject,
4+
updateDataObjectReferencesName,
5+
} from './DataObjectHelpers';
36

4-
export default function DataObjectLabelEditingProvider(eventBus, directEditing, commandStack, modeling) {
7+
export default function DataObjectLabelEditingProvider(
8+
eventBus,
9+
directEditing,
10+
commandStack,
11+
modeling
12+
) {
13+
let el;
514

6-
let el;
15+
// listen to dblclick on non-root elements
16+
eventBus.on('element.dblclick', function (event) {
17+
const { element } = event;
18+
if (is(element.businessObject, 'bpmn:DataObjectReference')) {
19+
let label = element.businessObject.name;
20+
label = label.replace(/\s*\[.*?\]\s*$/, '');
21+
modeling.updateLabel(element, label);
22+
directEditing.activate(element);
23+
el = element;
24+
}
25+
});
726

8-
// listen to dblclick on non-root elements
9-
eventBus.on('element.dblclick', function (event) {
10-
const { element } = event;
11-
if (is(element.businessObject, 'bpmn:DataObjectReference')) {
12-
let label = element.businessObject.name;
13-
label = label.replace(/\s*\[.*?\]\s*$/, '');
14-
modeling.updateLabel(element, label);
15-
directEditing.activate(element);
16-
el = element;
17-
}
18-
});
19-
20-
eventBus.on('directEditing.complete', function (event) {
21-
22-
const element = el;
27+
eventBus.on('directEditing.complete', function (event) {
28+
const element = el;
2329

24-
if (element && is(element.businessObject, 'bpmn:DataObjectReference')) {
30+
if (element && is(element.businessObject, 'bpmn:DataObjectReference')) {
31+
setTimeout(() => {
32+
const process = element.parent.businessObject;
33+
const dataObject = findDataObject(
34+
process,
35+
element.businessObject.dataObjectRef.id
36+
);
37+
const dataState =
38+
element.businessObject.dataState &&
39+
element.businessObject.dataState.name;
2540

26-
setTimeout(() => {
27-
const process = element.parent.businessObject;
28-
const dataObject = findDataObject(process, element.businessObject.dataObjectRef.id);
29-
const dataState = element.businessObject.dataState && element.businessObject.dataState.name;
41+
let newLabel = element.businessObject.name;
3042

31-
let newLabel = element.businessObject.name;
43+
commandStack.execute('element.updateModdleProperties', {
44+
element,
45+
moddleElement: dataObject,
46+
properties: {
47+
name: newLabel,
48+
},
49+
});
3250

33-
commandStack.execute('element.updateModdleProperties', {
34-
element,
35-
moddleElement: dataObject,
36-
properties: {
37-
name: newLabel,
38-
},
39-
});
51+
// Update references name
52+
updateDataObjectReferencesName(
53+
element.parent,
54+
newLabel,
55+
dataObject.id,
56+
commandStack
57+
);
4058

41-
// Update references name
42-
updateDataObjectReferencesName(element.parent, newLabel, dataObject.id, commandStack);
43-
44-
// Append the data state if it exists
45-
if (dataState) {
46-
newLabel += ` [${dataState}]`;
47-
}
48-
49-
// Update the label with the data state
50-
modeling.updateLabel(element, newLabel);
51-
el = undefined;
52-
}, 100);
59+
// Append the data state if it exists
60+
if (dataState) {
61+
newLabel += ` [${dataState}]`;
5362
}
54-
});
63+
64+
// Update the label with the data state
65+
modeling.updateLabel(element, newLabel);
66+
el = undefined;
67+
}, 100);
68+
}
69+
});
5570
}
5671

5772
DataObjectLabelEditingProvider.$inject = [
58-
'eventBus',
59-
'directEditing',
60-
'commandStack',
61-
'modeling'
62-
];
73+
'eventBus',
74+
'directEditing',
75+
'commandStack',
76+
'modeling',
77+
];

app/spiffworkflow/DataObject/DataObjectRenderer.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import BaseRenderer from 'diagram-js/lib/draw/BaseRenderer';
22

3-
import {
4-
attr as svgAttr
5-
} from 'tiny-svg';
3+
import { attr as svgAttr } from 'tiny-svg';
64

75
import { getBusinessObject, is } from 'bpmn-js/lib/util/ModelUtil';
86
import { isAny } from 'bpmn-js/lib/features/modeling/util/ModelingUtil';
@@ -21,7 +19,7 @@ export default class DataObjectRenderer extends BaseRenderer {
2119
}
2220

2321
canRender(element) {
24-
return isAny(element, [ 'bpmn:DataObjectReference' ]) && !element.labelTarget;
22+
return isAny(element, ['bpmn:DataObjectReference']) && !element.labelTarget;
2523
}
2624

2725
drawShape(parentNode, element) {
@@ -41,4 +39,4 @@ export default class DataObjectRenderer extends BaseRenderer {
4139
}
4240
}
4341

44-
DataObjectRenderer.$inject = [ 'eventBus', 'bpmnRenderer' ];
42+
DataObjectRenderer.$inject = ['eventBus', 'bpmnRenderer'];

app/spiffworkflow/DataObject/DataObjectRules.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export default function DataObjectRules(eventBus) {
1818
inherits(DataObjectRules, RuleProvider);
1919
const HIGH_PRIORITY = 1500;
2020

21-
DataObjectRules.prototype.init = function() {
22-
this.addRule('elements.move', HIGH_PRIORITY,function(context) {
21+
DataObjectRules.prototype.init = function () {
22+
this.addRule('elements.move', HIGH_PRIORITY, function (context) {
2323
let elements = context.shapes;
2424
let target = context.target;
2525
return canDrop(elements, target);
@@ -36,4 +36,4 @@ function canDrop(elements, target) {
3636
}
3737

3838
DataObjectRules.prototype.canDrop = canDrop;
39-
DataObjectRules.$inject = [ 'eventBus' ];
39+
DataObjectRules.$inject = ['eventBus'];

app/spiffworkflow/DataObject/index.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ import DataObjectPropertiesProvider from './propertiesPanel/DataObjectProperties
66
import DataObjectLabelEditingProvider from './DataObjectLabelEditingProvider';
77

88
export default {
9-
__depends__: [
10-
RulesModule
9+
__depends__: [RulesModule],
10+
__init__: [
11+
'dataInterceptor',
12+
'dataObjectRules',
13+
'dataObjectRenderer',
14+
'dataObjectPropertiesProvider',
15+
'dataObjectLabelEditingProvider',
1116
],
12-
__init__: [ 'dataInterceptor', 'dataObjectRules', 'dataObjectRenderer', 'dataObjectPropertiesProvider', 'dataObjectLabelEditingProvider' ],
13-
dataInterceptor: [ 'type', DataObjectInterceptor ],
14-
dataObjectRules: [ 'type', DataObjectRules ],
15-
dataObjectRenderer: [ 'type', DataObjectRenderer ],
16-
dataObjectPropertiesProvider: [ 'type', DataObjectPropertiesProvider ],
17-
dataObjectLabelEditingProvider: [ 'type', DataObjectLabelEditingProvider ]
17+
dataInterceptor: ['type', DataObjectInterceptor],
18+
dataObjectRules: ['type', DataObjectRules],
19+
dataObjectRenderer: ['type', DataObjectRenderer],
20+
dataObjectPropertiesProvider: ['type', DataObjectPropertiesProvider],
21+
dataObjectLabelEditingProvider: ['type', DataObjectLabelEditingProvider],
1822
};
19-
20-
21-

0 commit comments

Comments
 (0)