Hi,
i am trying to implement a customized modeler according to our business needs. However i am stuck and would appreciate your help.
All our pools have to have the same width, because of a custom item at the top. The user can still change the width of an lane or pool, this also changes the size for every other lane/pool. This works just fine and i am not allowed to change this behaviour.
The problem is illustrated in the following pictures.
I am not allowed to decrease the size of the top shape. However if i resize the bottom one the rules for resizing lanes/pools dont get checked.
So far i tried something like this:
import CommandInterceptor from "diagram-js/lib/command/CommandInterceptor.js";
const HIGH_PRIORITY = 5000;
//Dont allow resize of pools if a shape is in the way of any pool
export default class RestrictPoolResize extends CommandInterceptor {
constructor(eventBus, modeling, elementRegistry, commandStack) {
super(eventBus);
this.canExecute("shape.resize", HIGH_PRIORITY, context => {
const element = context.shape;
let condition = true;
console.log(context);
if(!(element.type !== 'bpmn:Participant' || element.type !== 'bpmn:Lane')) return
//https://github.com/bpmn-io/bpmn-js/blob/b37dc237b33de20478992ce5114709e849aae2a1/lib/features/modeling/behavior/ResizeBehavior.js#L84
let allPools = elementRegistry.getAll().filter(element => element.type === 'bpmn:Participant');
allPools.forEach(element => {
if(!commandStack.shape.resize.canExecute(element)) condition = false;
});
return condition;
},
true
);
}
}
CommandInterceptor.$inject = ["eventBus", "modeling", "elementRegistry", "commandStack"];
I think i found your way of checking in the link (comment). Can i call this method for all pools prior to executing?
Is it in general possible to restrict behaviour with this approach? To my understanding rules dont work, because i would restrict the user from resizing at all.
Thanks in advance!