Skip to content

Commit

Permalink
fix: compensation activity paste now results simple activity
Browse files Browse the repository at this point in the history
Closes #2070
  • Loading branch information
abdul99ahad committed Aug 16, 2024
1 parent 8511c2a commit 2f2816a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/features/replace/BpmnReplace.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export default function BpmnReplace(
}

if (propertyName === 'isForCompensation') {
return !isEventSubProcess(newBusinessObject);
return false;
}

return true;
Expand Down
12 changes: 11 additions & 1 deletion lib/features/rules/BpmnRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import {
isInterrupting,
hasErrorEventDefinition,
hasEscalationEventDefinition,
hasCompensateEventDefinition
hasCompensateEventDefinition,
isCompensationActivityElement
} from '../../util/DiUtil';

import RuleProvider from 'diagram-js/lib/features/rules/RuleProvider';
Expand Down Expand Up @@ -888,6 +889,15 @@ function canReplace(elements, target, position) {
});
}
}

if (is(element,'bpmn:Task') && canDrop(element, target)) {
if (isCompensationActivityElement(element)) {
canExecute.replacements.push({
oldElementId: element.id,
newElementType: 'bpmn:Task'
});
}
}
}

if (!is(target, 'bpmn:Transaction')) {
Expand Down
9 changes: 9 additions & 0 deletions lib/util/DiUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,12 @@ export function hasEscalationEventDefinition(element) {
export function hasCompensateEventDefinition(element) {
return hasEventDefinition(element, 'bpmn:CompensateEventDefinition');
}

/**
* @param {Element} element
*
* @return {boolean}
*/
export function isCompensationActivityElement(element) {
return getBusinessObject(element).isForCompensation;
}
4 changes: 2 additions & 2 deletions test/spec/features/replace/BpmnReplaceSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,7 @@ describe('features/replace - bpmn replace', function() {
}));


it('should keep isForCompensation attr', inject(function(elementRegistry, bpmnReplace) {
it('should not keep isForCompensation attr', inject(function(elementRegistry, bpmnReplace) {

// given
var task = elementRegistry.get('Task_1');
Expand All @@ -1450,7 +1450,7 @@ describe('features/replace - bpmn replace', function() {
var newElement = bpmnReplace.replaceElement(task, newElementData);

// then
expect(newElement.businessObject.isForCompensation).to.be.true;
expect(newElement.businessObject.isForCompensation).to.be.false;
}));

});
Expand Down

0 comments on commit 2f2816a

Please sign in to comment.