feat(modelling): unify drag/drop handling from palette/context-pad
Related to bpmn-io/diagram-js#60
This commit is contained in:
parent
1dd19fdb0d
commit
355059c30a
|
@ -47,29 +47,23 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|||
|
||||
var bpmnElement = element.businessObject;
|
||||
|
||||
function startConnect(event, element) {
|
||||
connect.start(event, element, null);
|
||||
}
|
||||
|
||||
function append(element, type) {
|
||||
var target = modeling.appendShape(element, { type: type });
|
||||
|
||||
selection.select(target);
|
||||
directEditing.activate(target);
|
||||
function startConnect(event, element, autoActivate) {
|
||||
connect.start(event, element, autoActivate);
|
||||
}
|
||||
|
||||
function appendAction(type, className) {
|
||||
|
||||
function appendListener(event, element) {
|
||||
var shape = elementFactory.createShape({ type: type });
|
||||
create.start(event, shape, element);
|
||||
}
|
||||
|
||||
return {
|
||||
group: 'model',
|
||||
className: className,
|
||||
action: {
|
||||
dragstart: function(event, element) {
|
||||
var shape = elementFactory.createShape({ type: type });
|
||||
create.start(event, shape, element);
|
||||
},
|
||||
click: function(event, element) {
|
||||
append(element, type);
|
||||
}
|
||||
dragstart: appendListener,
|
||||
click: appendListener
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -99,17 +93,21 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|||
});
|
||||
}
|
||||
|
||||
function removeElement(e) {
|
||||
if (element.waypoints) {
|
||||
modeling.removeConnection(element);
|
||||
} else {
|
||||
modeling.removeShape(element);
|
||||
}
|
||||
}
|
||||
|
||||
_.extend(actions, {
|
||||
'delete': {
|
||||
group: 'edit',
|
||||
className: 'icon-trash',
|
||||
action: function(e) {
|
||||
|
||||
if (element.waypoints) {
|
||||
modeling.removeConnection(element);
|
||||
} else {
|
||||
modeling.removeShape(element);
|
||||
}
|
||||
action: {
|
||||
click: removeElement,
|
||||
dragstart: removeElement
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -20,20 +20,24 @@ PaletteProvider.$inject = [ 'palette', 'create', 'elementFactory' ];
|
|||
PaletteProvider.prototype.getPaletteEntries = function(element) {
|
||||
|
||||
function createAction(type, group, className, title, options) {
|
||||
|
||||
function createListener(event) {
|
||||
var shape = elementFactory.createShape(_.extend({ type: type }, options));
|
||||
|
||||
if (options) {
|
||||
shape.businessObject.di.isExpanded = options.isExpanded;
|
||||
}
|
||||
|
||||
create.start(event, shape);
|
||||
}
|
||||
|
||||
return {
|
||||
group: group,
|
||||
className: className,
|
||||
title: title || 'Create ' + type,
|
||||
action: {
|
||||
dragstart: function(event) {
|
||||
var shape = elementFactory.createShape(_.extend({ type: type }, options));
|
||||
|
||||
if (options) {
|
||||
shape.businessObject.di.isExpanded = options.isExpanded;
|
||||
}
|
||||
|
||||
create.start(event, shape);
|
||||
}
|
||||
dragstart: createListener,
|
||||
click: createListener
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue