Skip to content

Commit

Permalink
WIP: reset dropdown value
Browse files Browse the repository at this point in the history
  • Loading branch information
smbea committed Oct 10, 2023
1 parent 37a924c commit e4e0ef5
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/cloud-element-templates/ElementTemplatesConditionChecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import { isObject } from 'min-dash';
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';

import { setPropertyValue, unsetProperty } from './util/propertyUtil';
import { getPropertyValue, setPropertyValue, unsetProperty } from './util/propertyUtil';
import { MESSAGE_BINDING_TYPES } from './util/bindingTypes';
import { removeMessage } from './util/rootElementUtil';

Expand Down Expand Up @@ -58,7 +58,9 @@ export default class ElementTemplatesConditionChecker extends CommandInterceptor
return;
}

const newTemplate = applyConditions(element, template);
const newTemplate = applyConditions(element, template, this._injector);

updateDropdownValues(newTemplate.properties, element, this._injector);

const propertiesToAdd = getMissingProperties(oldTemplate, newTemplate);
const propertiesToRemove = getPropertiesToRemove(newTemplate, oldTemplate);
Expand Down Expand Up @@ -147,3 +149,22 @@ function equals(a, b) {
function hasMessageProperties(template) {
return template.properties.some(p => MESSAGE_BINDING_TYPES.includes(p.binding.type));
}

function updateDropdownValues(properties, element, injector) {

const commandStack = injector.get('commandStack');
const bpmnFactory = injector.get('bpmnFactory');

properties.forEach(property => {

if (property.type !== 'Dropdown' || !property.condition) {
return;
}

const value = getPropertyValue(element, property);

if (value && !property.choices.find(choice => choice.value === value)) {
setPropertyValue(bpmnFactory, commandStack, element, property, '');
}
});
}

0 comments on commit e4e0ef5

Please sign in to comment.