bpmn-io / bpmn-js-element-templates

The element template extension for bpmn-js
MIT License
5 stars 3 forks source link

Conditions that depend on boolean properties are not evaluated correctly when diagram is first loaded #94

Closed chillleader closed 6 months ago

chillleader commented 6 months ago

Describe the Bug

If a property condition references another property that happens to be a boolean, the condition is not evaluated correctly when the diagram is first loaded.

Steps to Reproduce

  1. Use the following element template
Element template ``` { "$schema": "https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json", "name": "New Connector Template", "id": "201a5308-1f7a-461b-8d1e-783d5c9c79bd", "version": 1715154218173, "appliesTo": [ "bpmn:Task" ], "properties": [ { "id": "myBooleanProp", "type": "Boolean", "label": "Checkbox", "value": false, "tooltip": "Hello world!
Link", "binding": { "type": "zeebe:property", "name": "myBooleanProp" } }, { "id": "inputForActiveCheckbox", "type": "String", "label": "Input that appears when checkbox is ACTIVE", "binding": { "type": "zeebe:property", "name": "inputActive" }, "condition": { "property": "myBooleanProp", "equals": true } }, { "id": "inputForInactiveCheckbox", "type": "String", "label": "Input that appears when checkbox is INACTIVE", "binding": { "type": "zeebe:property", "name": "inputInactive" }, "condition": { "property": "myBooleanProp", "equals": false } } ] } ```
Properties that have conditional dependencies on boolean properties should be rendered correctly immediately after the diagram is loaded. ### Environment Desktop Modeler 5.22.0, Web Modeler SaaS (DEV) as of 08.05.2024
chillleader commented 6 months ago

Hey @marstamm could you please check if this is related to another bug you recently fixed, or if it's a separate issue?

barmac commented 6 months ago

I can reproduce it on the nightly build as well.

barmac commented 6 months ago

The core reason for this is that a boolean zeebe:property#value is initially parsed as a string "true" which is not equal to the boolean true. Later, in the editing, the value is set to a boolean true which makes it pass the test. From the metamodel perspective, the fact that we set zeebe:property#value to a boolean is a hack as in the metamodel the property is defined as a string. As a quick solution, I will implement casting of the boolean properties. Alternatively, we could consider adjusting the metamodel to accommodate both string and boolean values, but that may break some templates which rely on string "true". Note that for XML it looks the same.