-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support
zeebe:calledElement
templating
deps: update to @bpmn-io/element-templates-validator@1.7.0 Related to camunda/camunda-modeler#3006
- Loading branch information
Showing
23 changed files
with
1,007 additions
and
24 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor'; | ||
import { is } from 'bpmn-js/lib/util/ModelUtil'; | ||
|
||
import { findExtension } from './Helper'; | ||
|
||
/** | ||
* Enforces no variable propagation for templated call activities. | ||
*/ | ||
export class CalledElementBehavior extends CommandInterceptor { | ||
|
||
/** | ||
* @param {*} eventBus | ||
* @param {*} modeling | ||
* @param {import('./ElementTemplates').default} elementTemplates | ||
*/ | ||
constructor(eventBus, modeling, elementTemplates) { | ||
super(eventBus); | ||
|
||
this._modeling = modeling; | ||
this._elementTemplates = elementTemplates; | ||
|
||
this.postExecuted([ | ||
'element.updateProperties', 'element.updateModdleProperties' | ||
], this._ensureNoPropagation, true, this); | ||
} | ||
|
||
_ensureNoPropagation(context) { | ||
const { element } = context; | ||
|
||
if (!this._elementTemplates.get(element)) { | ||
return; | ||
} | ||
|
||
if (!is(element, 'bpmn:CallActivity')) { | ||
return; | ||
} | ||
|
||
const calledElement = findExtension(element, 'zeebe:CalledElement'); | ||
|
||
if (!calledElement) { | ||
return; | ||
} | ||
|
||
for (const property of [ | ||
'propagateAllChildVariables', | ||
'propagateAllParentVariables' | ||
]) { | ||
if (calledElement.get(property) !== false) { | ||
this._modeling.updateModdleProperties(element, calledElement, { | ||
[property]: false | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
|
||
CalledElementBehavior.$inject = [ | ||
'eventBus', | ||
'modeling', | ||
'elementTemplates' | ||
]; |
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
36 changes: 36 additions & 0 deletions
36
src/cloud-element-templates/create/CalledElementBindingProvider.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,36 @@ | ||
import { | ||
ensureExtension | ||
} from '../CreateHelper'; | ||
import { getDefaultValue } from '../Helper'; | ||
|
||
|
||
export class CalledElementBindingProvider { | ||
static create(element, options) { | ||
const { | ||
property, | ||
bpmnFactory | ||
} = options; | ||
|
||
const { | ||
binding | ||
} = property; | ||
|
||
const { | ||
property: propertyName | ||
} = binding; | ||
|
||
const value = getDefaultValue(property); | ||
|
||
const calledElement = ensureExtension(element, 'zeebe:CalledElement', bpmnFactory); | ||
|
||
// TODO(@barmac): remove if we decide to support propagation in templates | ||
ensureNoPropagation(calledElement); | ||
|
||
calledElement.set(propertyName, value); | ||
} | ||
} | ||
|
||
function ensureNoPropagation(calledElement) { | ||
calledElement.set('propagateAllChildVariables', false); | ||
calledElement.set('propagateAllParentVariables', false); | ||
} |
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
Oops, something went wrong.