chore(label-editing): use isAny helper
This commit is contained in:
parent
26f26945b6
commit
058cfbb579
|
@ -7,6 +7,7 @@ var UpdateLabelHandler = require('./cmd/UpdateLabelHandler');
|
|||
var LabelUtil = require('./LabelUtil');
|
||||
|
||||
var is = require('../../util/ModelUtil').is,
|
||||
isAny = require('../modeling/util/ModelingUtil').isAny,
|
||||
isExpanded = require('../../util/DiUtil').isExpanded;
|
||||
|
||||
var SMALL_FONT_SIZE = 11,
|
||||
|
@ -25,9 +26,7 @@ function LabelEditingProvider(eventBus, canvas, directEditing, commandStack, res
|
|||
|
||||
// listen to dblclick on non-root elements
|
||||
eventBus.on('element.dblclick', function(event) {
|
||||
directEditing.activate(event.element);
|
||||
|
||||
resizeHandles.removeResizers();
|
||||
activateDirectEdit(event.element, true);
|
||||
});
|
||||
|
||||
// complete on followup canvas operation
|
||||
|
@ -65,11 +64,18 @@ function LabelEditingProvider(eventBus, canvas, directEditing, commandStack, res
|
|||
return;
|
||||
}
|
||||
|
||||
if (is(element, 'bpmn:Task') || is(element, 'bpmn:TextAnnotation') ||
|
||||
(is(element, 'bpmn:SubProcess') && !isExpanded(element))) {
|
||||
activateDirectEdit(element);
|
||||
});
|
||||
|
||||
|
||||
function activateDirectEdit(element, force) {
|
||||
if (force ||
|
||||
isAny(element, [ 'bpmn:Task', 'bpmn:TextAnnotation' ]) ||
|
||||
isCollapsedSubProcess(element)) {
|
||||
|
||||
directEditing.activate(element);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -109,11 +115,8 @@ LabelEditingProvider.prototype.activate = function(element) {
|
|||
var options = {};
|
||||
|
||||
// tasks
|
||||
if (is(element, 'bpmn:Task') ||
|
||||
is(element, 'bpmn:Participant') ||
|
||||
is(element, 'bpmn:Lane') ||
|
||||
(is(element, 'bpmn:CallActivity') && !isExpanded(element)) ||
|
||||
(is(element, 'bpmn:SubProcess') && !isExpanded(element))) {
|
||||
if (isAny(element, [ 'bpmn:Task', 'bpmn:Participant', 'bpmn:Lane', 'bpmn:CallActivity' ]) ||
|
||||
isCollapsedSubProcess(element)) {
|
||||
assign(options, {
|
||||
centerVertically: true
|
||||
});
|
||||
|
@ -175,8 +178,7 @@ LabelEditingProvider.prototype.getEditingBBox = function(element) {
|
|||
var style = {};
|
||||
|
||||
// adjust for expanded pools AND lanes
|
||||
if ((is(element, 'bpmn:Participant') && isExpanded(element))
|
||||
|| is(element, 'bpmn:Lane')) {
|
||||
if (is(element, 'bpmn:Lane') || isExpandedPool(element)) {
|
||||
|
||||
assign(bounds, {
|
||||
width: bbox.height,
|
||||
|
@ -198,12 +200,10 @@ LabelEditingProvider.prototype.getEditingBBox = function(element) {
|
|||
|
||||
|
||||
// internal labels for tasks and collapsed call activities, sub processes and participants
|
||||
if (
|
||||
is(element, 'bpmn:Task') ||
|
||||
(is(element, 'bpmn:CallActivity') && !isExpanded(element)) ||
|
||||
(is(element, 'bpmn:SubProcess') && !isExpanded(element)) ||
|
||||
(is(element, 'bpmn:Participant') && !isExpanded(element))
|
||||
) {
|
||||
if (isAny(element, [ 'bpmn:Task', 'bpmn:CallActivity']) ||
|
||||
isCollapsedPool(element) ||
|
||||
isCollapsedSubProcess(element)) {
|
||||
|
||||
assign(bounds, {
|
||||
width: bbox.width,
|
||||
height: bbox.height
|
||||
|
@ -221,7 +221,7 @@ LabelEditingProvider.prototype.getEditingBBox = function(element) {
|
|||
|
||||
|
||||
// internal labels for expanded sub processes
|
||||
if (is(element, 'bpmn:SubProcess') && isExpanded(element)) {
|
||||
if (isExpandedSubProcess(element)) {
|
||||
assign(bounds, {
|
||||
width: bbox.width,
|
||||
x: bbox.x
|
||||
|
@ -298,3 +298,23 @@ LabelEditingProvider.prototype.update = function(element, newLabel, activeContex
|
|||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
////////// helpers ////////////////////////////////
|
||||
|
||||
function isCollapsedSubProcess(element) {
|
||||
return is(element, 'bpmn:SubProcess') && !isExpanded(element);
|
||||
}
|
||||
|
||||
function isExpandedSubProcess(element) {
|
||||
return is(element, 'bpmn:SubProcess') && isExpanded(element);
|
||||
}
|
||||
|
||||
function isCollapsedPool(element) {
|
||||
return is(element, 'bpmn:Participant') && !isExpanded(element);
|
||||
}
|
||||
|
||||
function isExpandedPool(element) {
|
||||
return is(element, 'bpmn:Participant') && isExpanded(element);
|
||||
}
|
Loading…
Reference in New Issue