Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(custom-elements): add custom connections
closes #12
- Loading branch information
1 parent
abae2a2
commit 9fc57b4
Showing
19 changed files
with
1,414 additions
and
476 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,109 @@ | ||
[ | ||
{ | ||
"type": "custom:triangle", | ||
"x": 300, | ||
"y": 300 | ||
}, | ||
{ | ||
"type": "custom:circle", | ||
"x": 500, | ||
"y": 400 | ||
} | ||
{ | ||
"type":"custom:circle", | ||
"id":"CustomCircle_1", | ||
"x":806, | ||
"y":210 | ||
}, | ||
{ | ||
"type":"custom:triangle", | ||
"id":"CustomTriangle_1", | ||
"x":300, | ||
"y":300 | ||
}, | ||
{ | ||
"type":"custom:connection", | ||
"id":"CustomConnection_2", | ||
"waypoints":[ | ||
{ | ||
"original":{ | ||
"x":320, | ||
"y":320 | ||
}, | ||
"x":330, | ||
"y":320 | ||
}, | ||
{ | ||
"x":469, | ||
"y":320 | ||
}, | ||
{ | ||
"x":469, | ||
"y":225 | ||
}, | ||
{ | ||
"original":{ | ||
"x":559, | ||
"y":200 | ||
}, | ||
"x":517, | ||
"y":212 | ||
} | ||
], | ||
"source":"CustomTriangle_1", | ||
"target":"Task_2" | ||
}, | ||
{ | ||
"type":"custom:connection", | ||
"id":"CustomConnection_1", | ||
"source":"CustomTriangle_1", | ||
"target":"Task_1", | ||
"waypoints":[ | ||
{ | ||
"original":{ | ||
"x":319, | ||
"y":302 | ||
}, | ||
"x":319, | ||
"y":302 | ||
}, | ||
{ | ||
"x":319, | ||
"y":200 | ||
}, | ||
{ | ||
"x":309, | ||
"y":200 | ||
}, | ||
{ | ||
"original":{ | ||
"x":309, | ||
"y":145 | ||
}, | ||
"x":309, | ||
"y":145 | ||
} | ||
] | ||
}, | ||
{ | ||
"type":"custom:connection", | ||
"waypoints":[ | ||
{ | ||
"original":{ | ||
"x":876, | ||
"y":280 | ||
}, | ||
"x":946, | ||
"y":280 | ||
}, | ||
{ | ||
"x":1028, | ||
"y":280 | ||
}, | ||
{ | ||
"x":1028, | ||
"y":111 | ||
}, | ||
{ | ||
"original":{ | ||
"x":876, | ||
"y":111 | ||
}, | ||
"x":917, | ||
"y":111 | ||
} | ||
], | ||
"source":"CustomCircle_1", | ||
"target":"Task_3" | ||
} | ||
] |
61 changes: 61 additions & 0 deletions
61
custom-elements/app/custom-modeler/custom/CustomContextPadProvider.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
'use strict'; | ||
|
||
var inherits = require('inherits'); | ||
|
||
var ContextPadProvider = require('bpmn-js/lib/features/context-pad/ContextPadProvider'); | ||
|
||
var isAny = require('bpmn-js/lib/features/modeling/util/ModelingUtil').isAny; | ||
|
||
var assign = require('lodash/object/assign'), | ||
bind = require('lodash/function/bind'); | ||
|
||
function CustomContextPadProvider(contextPad, modeling, elementFactory, connect, | ||
create, popupMenu, canvas, rules, translate) { | ||
|
||
ContextPadProvider.call(this, contextPad, modeling, elementFactory, connect, create, | ||
popupMenu, canvas, rules, translate); | ||
|
||
var cached = bind(this.getContextPadEntries, this); | ||
|
||
this.getContextPadEntries = function(element) { | ||
var actions = cached(element); | ||
|
||
var businessObject = element.businessObject; | ||
|
||
function startConnect(event, element, autoActivate) { | ||
connect.start(event, element, autoActivate); | ||
} | ||
|
||
if (isAny(businessObject, [ 'custom:triangle', 'custom:circle'])) { | ||
assign(actions, { | ||
'connect': { | ||
group: 'connect', | ||
className: 'bpmn-icon-connection-multi', | ||
title: translate('Connect using custom connection'), | ||
action: { | ||
click: startConnect, | ||
dragstart: startConnect | ||
} | ||
} | ||
}); | ||
} | ||
|
||
return actions; | ||
}; | ||
} | ||
|
||
inherits(CustomContextPadProvider, ContextPadProvider); | ||
|
||
CustomContextPadProvider.$inject = [ | ||
'contextPad', | ||
'modeling', | ||
'elementFactory', | ||
'connect', | ||
'create', | ||
'popupMenu', | ||
'canvas', | ||
'rules', | ||
'translate' | ||
]; | ||
|
||
module.exports = CustomContextPadProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.