__Describe the Enhancement__
When applying an task-specific element template to a task of a specific type (e.g., ServiceTask) and then changing the type of the respective task (e.g., to UserTask), the element template is still present. This is IMO an inconsistent state, since the element template configuration would not allow that template to be applied to a task other than ServiceTask.
__Steps to Reproduce__
{
"name": "Mail Task",
"id": "com.camunda.example.MailTask",
"appliesTo": [
"bpmn:ServiceTask"
],
"properties": [
{
"label": "Implementation Type",
"type": "String",
"value": "com.mycompany.MailTaskImpl",
"editable": false,
"binding": {
"type": "property",
"name": "camunda:class"
}
},
{
"label": "Sender",
"type": "String",
"binding": {
"type": "camunda:inputParameter",
"name": "sender"
},
"constraints": {
"notEmpty": true,
"pattern": {
"value": "^[A-z0-9._%+-]+@[A-z0-9.-]+\\.[A-z]{2,}$",
"message": "Must be a valid email."
}
}
},
{
"label": "Receivers",
"type": "String",
"binding": {
"type": "camunda:inputParameter",
"name": "receivers"
},
"constraints": {
"notEmpty": true
}
},
{
"label": "Template",
"description": "By the way, you can use <a href=\"https://freemarker.apache.org/\">freemarker templates</a> here",
"value": "Hello ${firstName}!",
"type": "Text",
"binding": {
"type": "camunda:inputParameter",
"name": "messageBody",
"scriptFormat": "freemarker"
},
"constraints": {
"notEmpty": true
}
},
{
"label": "Result Status",
"description": "The process variable to which to assign the send result to",
"type": "String",
"value": "mailSendResult",
"binding": {
"type": "camunda:outputParameter",
"source": "${ resultStatus }"
}
},
{
"label": "Send Async?",
"type": "Boolean",
"value": true,
"binding": {
"type": "property",
"name": "camunda:asyncBefore"
}
}
]
}
serviceTaskuserTask__Expected Behavior__
The element template shall be unlinked, if not supporting the respective new task type.
__Why__
If we don't have this, the user would get to an inconsistent state of the diagram (according to the element template configuration)
__Environment__
Maybe we could listen for shape.replace and check whether the template is still applicable. I think we already do similar for other events in some command handler for the element templates.
and check whether the template is still applicable.
I think we cannot check this in all cases since the template might be not available (e.g., file deleted).
Therefore we could:
A) only check this, if the template is still present
B) simply always unlink once you use the wrench
I would opt for B.
B) simply always unlink once you use the wrench
Sounds OK to me. 馃憤
The solution I've discussed with @azeghers is:
CodeSandbox example: https://codesandbox.io/s/restricting-camundamodelertemplate-nyrtp?file=/src/index.js
Most helpful comment
The solution I've discussed with @azeghers is:
CodeSandbox example: https://codesandbox.io/s/restricting-camundamodelertemplate-nyrtp?file=/src/index.js