it’s not out-of-the-box possible to create a condition with expressions as it is a 8-8 relationship.
You could fix this by using an entity in between.
Page would look like this
the nested dataview shows a selected object when present. This is defined by a datasource microflow, which looks like this:
The onclick of the container will trigger this microflow, which creates or deletes the selected object.
When Selected object is not existing, it creates one and set the associations between Selected and Order and Contractor = Selected
When Selected object is existing, it deletes the selected object = not selected
At the end I refresh the order object to push this to the frontend.
Instead of conditional visibility to show different containers with different styling, I use dynamic classes to change the color of the container background:
$currentObject != empty