bpmn-js-spiffworkflow/app/spiffworkflow/loops/propertiesPanel/LoopProperty.js

31 lines
1.0 KiB
JavaScript
Raw Normal View History

2023-04-06 14:44:06 +00:00
export function getLoopProperty(element, propertyName) {
const loopCharacteristics = element.businessObject.loopCharacteristics;
const prop = loopCharacteristics.get(propertyName);
let value = '';
if (typeof(prop) !== 'object') {
value = prop;
} else if (typeof(prop) !== 'undefined') {
if (prop.$type === 'bpmn:FormalExpression')
value = prop.get('body');
else
value = prop.get('id');
}
return value;
}
export function setLoopProperty(element, propertyName, value, commandStack) {
const loopCharacteristics = element.businessObject.loopCharacteristics;
if (typeof(value) === 'object')
value.$parent = loopCharacteristics;
2023-07-12 16:25:57 +00:00
let properties = { [propertyName]: value };
if (propertyName === 'loopCardinality') properties['loopDataInputRef'] = undefined;
if (propertyName === 'loopDataInputRef') properties['loopCardinality'] = undefined;
2023-04-06 14:44:06 +00:00
commandStack.execute('element.updateModdleProperties', {
element,
moddleElement: loopCharacteristics,
2023-07-12 16:25:57 +00:00
properties: properties,
2023-04-06 14:44:06 +00:00
});
}