Skip to content

Commit 286568e

Browse files
authored
Add dropdowns for multi-instance input/output collections (#132) (#133)
1 parent c1cdabc commit 286568e

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

app/spiffworkflow/loops/propertiesPanel/InputCollectionEntry.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
import { useService } from "bpmn-js-properties-panel";
66
import { getLoopProperty, removeLoopProperty, setLoopProperty } from "../helpers";
7-
import { TextFieldEntry } from '@bpmn-io/properties-panel';
7+
import { SelectEntry } from '@bpmn-io/properties-panel';
8+
import { findDataObjects } from '../../DataObject/DataObjectHelpers';
89

910
export function InputCollection(props) {
1011
const { element } = props;
@@ -29,12 +30,32 @@ export function InputCollection(props) {
2930
setLoopProperty(element, 'loopDataInputRef', collection, commandStack);
3031
};
3132

32-
return TextFieldEntry({
33+
const getOptions = () => {
34+
const businessObject = element.businessObject;
35+
const parent = businessObject.$parent;
36+
const dataObjects = findDataObjects(parent);
37+
38+
const options = [
39+
{ label: '', value: '' } // Empty option to allow clearing
40+
];
41+
42+
dataObjects.forEach((dataObj) => {
43+
options.push({
44+
label: dataObj.name || dataObj.id,
45+
value: dataObj.id
46+
});
47+
});
48+
49+
return options;
50+
};
51+
52+
return SelectEntry({
3353
element,
3454
id: 'loopDataInputRef',
3555
label: translate('Input Collection'),
3656
getValue,
3757
setValue,
58+
getOptions,
3859
debounce,
3960
description: 'Create an instance for each item in this collection',
4061
});

app/spiffworkflow/loops/propertiesPanel/OutputCollectionEntry.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
import { useService } from "bpmn-js-properties-panel";
66
import { getLoopProperty, removeLoopProperty, setLoopProperty } from "../helpers";
7-
import { TextFieldEntry } from '@bpmn-io/properties-panel';
7+
import { SelectEntry } from '@bpmn-io/properties-panel';
8+
import { findDataObjects } from '../../DataObject/DataObjectHelpers';
89

910
export function OutputCollection(props) {
1011
const { element } = props;
@@ -29,12 +30,32 @@ export function OutputCollection(props) {
2930
setLoopProperty(element, 'loopDataOutputRef', collection, commandStack);
3031
};
3132

32-
return TextFieldEntry({
33+
const getOptions = () => {
34+
const businessObject = element.businessObject;
35+
const parent = businessObject.$parent;
36+
const dataObjects = findDataObjects(parent);
37+
38+
const options = [
39+
{ label: '', value: '' } // Empty option to allow clearing
40+
];
41+
42+
dataObjects.forEach((dataObj) => {
43+
options.push({
44+
label: dataObj.name || dataObj.id,
45+
value: dataObj.id
46+
});
47+
});
48+
49+
return options;
50+
};
51+
52+
return SelectEntry({
3353
element,
3454
id: 'loopDataOutputRef',
3555
label: translate('Output Collection'),
3656
getValue,
3757
setValue,
58+
getOptions,
3859
debounce,
3960
description: 'Create or update this collection with the instance results',
4061
});

0 commit comments

Comments
 (0)