Skip to content

Commit c0e95c4

Browse files
philippfrommenikku
authored andcommitted
fix: do not unset form type when setting value to empty
Related to camunda/camunda-modeler#3963
1 parent 28a14c0 commit c0e95c4

File tree

4 files changed

+110
-6
lines changed

4 files changed

+110
-6
lines changed

src/provider/camunda-platform/properties/FormProps.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { isUndefined } from 'min-dash';
2+
13
import { getBusinessObject } from 'bpmn-js/lib/util/ModelUtil';
24

35
import { TextFieldEntry, isTextFieldEntryEdited, SelectEntry, isSelectEntryEdited } from '@bpmn-io/properties-panel';
@@ -77,7 +79,7 @@ function FormKey(props) {
7779

7880
const setValue = (value) => {
7981
modeling.updateProperties(element, {
80-
'camunda:formKey': value
82+
'camunda:formKey': isUndefined(value) ? '' : value
8183
});
8284
};
8385

@@ -106,7 +108,7 @@ function FormRef(props) {
106108

107109
const setValue = (value) => {
108110
modeling.updateProperties(element, {
109-
'camunda:formRef': value
111+
'camunda:formRef': isUndefined(value) ? '' : value
110112
});
111113
};
112114

src/provider/zeebe/properties/FormProps.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { without } from 'min-dash';
1+
import {
2+
isUndefined,
3+
without
4+
} from 'min-dash';
25

36
import {
47
getBusinessObject,
@@ -122,7 +125,7 @@ function FormConfiguration(props) {
122125
};
123126

124127
const setValue = (value) => {
125-
setUserTaskForm(injector, element, value);
128+
setUserTaskForm(injector, element, isUndefined(value) ? '' : value);
126129
};
127130

128131
return TextAreaEntry({
@@ -149,7 +152,7 @@ function FormId(props) {
149152
};
150153

151154
const setValue = (value) => {
152-
setFormId(injector, element, value);
155+
setFormId(injector, element, isUndefined(value) ? '' : value);
153156
};
154157

155158
return TextFieldEntry({
@@ -175,7 +178,7 @@ function CustomFormKey(props) {
175178
};
176179

177180
const setValue = (value) => {
178-
setCustomFormKey(injector, element, value);
181+
setCustomFormKey(injector, element, isUndefined(value) ? '' : value);
179182
};
180183

181184
return TextFieldEntry({

test/spec/provider/camunda-platform/FormProps.spec.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,27 @@ describe('provider/camunda-platform - FormProps', function() {
116116
}));
117117

118118

119+
it('should not delete if empty', inject(async function(elementRegistry, selection) {
120+
121+
// given
122+
const task = elementRegistry.get('UserTask_FormKey');
123+
124+
await act(() => {
125+
selection.select(task);
126+
});
127+
128+
// when
129+
const input = domQuery('input[name=formKey]', container);
130+
131+
changeInput(input, '');
132+
133+
// then
134+
expect(getBusinessObject(task).get('camunda:formKey')).to.equal('');
135+
136+
expect(input.value).to.equal('');
137+
}));
138+
139+
119140
it('should update on external change', inject(async function(commandStack, elementRegistry, selection) {
120141

121142
// given
@@ -203,6 +224,27 @@ describe('provider/camunda-platform - FormProps', function() {
203224
}));
204225

205226

227+
it('should not delete if empty', inject(async function(elementRegistry, selection) {
228+
229+
// given
230+
const task = elementRegistry.get('UserTask_FormRef');
231+
232+
await act(() => {
233+
selection.select(task);
234+
});
235+
236+
// when
237+
const input = domQuery('input[name=formRef]', container);
238+
239+
changeInput(input, '');
240+
241+
// then
242+
expect(getBusinessObject(task).get('camunda:formRef')).to.equal('');
243+
244+
expect(input.value).to.equal('');
245+
}));
246+
247+
206248
it('should update on external change', inject(async function(commandStack, elementRegistry, selection) {
207249

208250
// given

test/spec/provider/zeebe/Forms.spec.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,25 @@ describe('provider/zeebe - Forms', function() {
296296
}));
297297

298298

299+
it('should not delete if empty', inject(async function(elementRegistry, selection) {
300+
301+
// given
302+
const userTask = elementRegistry.get('CAMUNDA_FORM_EMBEDDED');
303+
304+
await act(() => {
305+
selection.select(userTask);
306+
});
307+
308+
const formConfigurationTextarea = getFormConfigurationTextarea(container);
309+
310+
// when
311+
changeInput(formConfigurationTextarea, '');
312+
313+
// then
314+
expectUserTaskForm(userTask, '');
315+
}));
316+
317+
299318
it('should update on external change', inject(async function(commandStack, elementRegistry, selection) {
300319

301320
// given
@@ -360,6 +379,25 @@ describe('provider/zeebe - Forms', function() {
360379
}));
361380

362381

382+
it('should not delete if empty', inject(async function(elementRegistry, selection) {
383+
384+
// given
385+
const userTask = elementRegistry.get('CAMUNDA_FORM_LINKED');
386+
387+
await act(() => {
388+
selection.select(userTask);
389+
});
390+
391+
const formIdInput = getFormIdInput(container);
392+
393+
// when
394+
changeInput(formIdInput, '');
395+
396+
// then
397+
expectFormId(userTask, '');
398+
}));
399+
400+
363401
it('should update on external change', inject(async function(commandStack, elementRegistry, selection) {
364402

365403
// given
@@ -424,6 +462,25 @@ describe('provider/zeebe - Forms', function() {
424462
}));
425463

426464

465+
it('should not delete if empty', inject(async function(elementRegistry, selection) {
466+
467+
// given
468+
const userTask = elementRegistry.get('CUSTOM_FORM');
469+
470+
await act(() => {
471+
selection.select(userTask);
472+
});
473+
474+
const customFormKeyInput = getCustomFormKeyInput(container);
475+
476+
// when
477+
changeInput(customFormKeyInput, '');
478+
479+
// then
480+
expectFormKey(userTask, '');
481+
}));
482+
483+
427484
it('should update on external change', inject(async function(commandStack, elementRegistry, selection) {
428485

429486
// given

0 commit comments

Comments
 (0)