Is there a way to prevent/cancel the shape.remove event (similarly to element.click) if a condition is fullfiled (the condition cannot be set previously with a rule)? I am trying to implement a collaborative way of editing bpmn diagrams and would like to create some sort of lock for activities, which are being edited by many users at the same time, so that one person couldn’t delete a script task for example if another user is working on it.
Thanks in advance!
If you have a working solution for the
element.click it should be doable to do the same for any other event. Did you try that out?
The solution I found for element.click is simply using the eventBus, setting the priority high and returning false, if needed. I tried the same for shape.remove and it did not work
This CodeSandbox might be a good starting point.
As far as I understood how the rules work, they are defined beforehand and added as the model instance is created. In my use case, an answer from the backend server should say if the selected task should be blocked from deletion or not- this answer may constantly change as other users are working on the process.
Next to the rules approach, there is also the way of using the CommandInterceptor.
For both approaches, why can’t you simply send a request to your Backend server to verify whether the shape should be blocked or not? The logic behind the rule will then be executed once you call
rules.allowed('elements.delete', ...). The behavior will be executed once a user is trying to delete a shape.
Thank you, I will try that!