Skip to content

Commit

Permalink
fix(FeelProperty): support non-string values
Browse files Browse the repository at this point in the history
closes #70
  • Loading branch information
marstamm committed Feb 29, 2024
1 parent 6d035c9 commit b443159
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { PropertyDescription } from '../../../../components/PropertyDescription'
import { PropertyTooltip } from '../../components/PropertyTooltip';
import { FeelEntryWithVariableContext, FeelEntry } from '../../../../entries/FeelEntryWithContext';
import { propertyGetter, propertySetter, propertyValidator, isExternalProperty } from './util';
import { useCallback } from '@bpmn-io/properties-panel/preact/hooks';

export function FeelProperty(props) {
const {
Expand All @@ -28,10 +29,21 @@ export function FeelProperty(props) {
? FeelEntryWithVariableContext
: FeelEntry;

const getValue = useCallback(() => {
const getter = propertyGetter(element, property);
const value = getter();

if (typeof value === 'undefined') {
return value;
}

return value.toString();
}, [ propertyGetter, element, property ]);

return TextFieldComponent({
debounce,
element,
getValue: propertyGetter(element, property),
getValue: getValue,
id,
label,
feel,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" id="Definitions_118jbsm" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.19.0">
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" id="Definitions_118jbsm" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.20.0">
<bpmn:process id="Process_1gpk8uz" isExecutable="true">
<bpmn:serviceTask id="disabled" name="feel disabled" zeebe:modelerTemplate="booleanField.feel.disabled" />
<bpmn:serviceTask id="required" name="feel required" zeebe:modelerTemplate="booleanField.feel.required" />
<bpmn:serviceTask id="optional" name="feel optional" zeebe:modelerTemplate="booleanField.feel.optional" />
<bpmn:serviceTask id="static" name="feel static" zeebe:modelerTemplate="booleanField.feel.static" />
<bpmn:serviceTask id="ServiceTask" name="ServiceTask" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1gpk8uz">
Expand All @@ -24,6 +25,10 @@
<dc:Bounds x="290" y="77" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0rfwxee_di" bpmnElement="ServiceTask">
<dc:Bounds x="160" y="290" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"label": "BooleanProperty",
"type": "Boolean",
"feel": "required",
"value": true,
"binding": {
"type": "zeebe:property",
"name": "BooleanProperty"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import TestContainer from 'mocha-test-container-support';

import {
bootstrapPropertiesPanel,
getBpmnJS
getBpmnJS,
inject
} from 'test/TestHelper';

import {
Expand Down Expand Up @@ -87,21 +88,37 @@ describe('provider/cloud-element-templates - BooleanProperty', function() {

describe('feel required', function() {

let entry, input;
it('should render as FEEL field', async function() {

beforeEach(async function() {
// given
await expectSelected('required');
entry = findEntry('custom-entry-booleanField.feel.required-0', container);
input = domQuery('.bio-properties-panel-feel-editor-container', entry);
});

it('should render as FEEL field', async function() {
const entry = findEntry('custom-entry-booleanField.feel.required-0', container);
const input = domQuery('.bio-properties-panel-feel-editor-container', entry);

// then
expect(input).to.exist;

});


it('should apply template', inject(async function(canvas, elementTemplates) {

// given
const element = await expectSelected('ServiceTask');
const template = templates.find(t => t.id === 'booleanField.feel.required');

// when
await act(() => {
elementTemplates.applyTemplate(element, template);
});

// then
const entry = findEntry('custom-entry-booleanField.feel.required-0', container);
const input = domQuery('[role="textbox"]', entry);

expect(input.textContent).to.eql('true');
}));

});


Expand Down

0 comments on commit b443159

Please sign in to comment.