chore(bpmn-replace): reorganize toggling collapsed state
This commit is contained in:
parent
973ac6e35a
commit
e1efb556f2
|
@ -45,8 +45,10 @@ var CUSTOM_PROPERTIES = [
|
|||
'isInterrupting'
|
||||
];
|
||||
|
||||
|
||||
function toggeling(element, target) {
|
||||
/**
|
||||
* Check if element should be collapsed or expanded.
|
||||
*/
|
||||
function shouldToggleCollapsed(element, targetElement) {
|
||||
|
||||
var oldCollapsed = (
|
||||
element && has(element, 'collapsed') ? element.collapsed : !isExpanded(element)
|
||||
|
@ -54,11 +56,11 @@ function toggeling(element, target) {
|
|||
|
||||
var targetCollapsed;
|
||||
|
||||
if (target && (has(target, 'collapsed') || has(target, 'isExpanded'))) {
|
||||
if (targetElement && (has(targetElement, 'collapsed') || has(targetElement, 'isExpanded'))) {
|
||||
|
||||
// property is explicitly set so use it
|
||||
targetCollapsed = (
|
||||
has(target, 'collapsed') ? target.collapsed : !target.isExpanded
|
||||
has(targetElement, 'collapsed') ? targetElement.collapsed : !targetElement.isExpanded
|
||||
);
|
||||
} else {
|
||||
|
||||
|
@ -67,7 +69,6 @@ function toggeling(element, target) {
|
|||
}
|
||||
|
||||
if (oldCollapsed !== targetCollapsed) {
|
||||
element.collapsed = oldCollapsed;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -75,7 +76,6 @@ function toggeling(element, target) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This module takes care of replacing BPMN elements
|
||||
*/
|
||||
|
@ -106,15 +106,13 @@ export default function BpmnReplace(
|
|||
var type = target.type,
|
||||
oldBusinessObject = element.businessObject;
|
||||
|
||||
if (isSubProcess(oldBusinessObject)) {
|
||||
if (type === 'bpmn:SubProcess') {
|
||||
if (toggeling(element, target)) {
|
||||
if (isSubProcess(oldBusinessObject) && type === 'bpmn:SubProcess') {
|
||||
if (shouldToggleCollapsed(element, target)) {
|
||||
|
||||
// expanding or collapsing process
|
||||
modeling.toggleCollapse(element);
|
||||
// expanding or collapsing process
|
||||
modeling.toggleCollapse(element);
|
||||
|
||||
return element;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue