Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: display multi-instance configuration in properties panel #27

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ All notable changes to [bpmn-js-element-templates](https://github.com/bpmn-io/bp

___Note:__ Yet to be released changes appear here._

* `FIX`: display multi-instance configuration in properties panel

## 1.6.0

* `FEAT`: add `zeebe:subscription` in single command ([#21](https://github.com/bpmn-io/bpmn-js-element-templates/issues/21))
Expand Down
23 changes: 18 additions & 5 deletions src/cloud-element-templates/ElementTemplatesPropertiesProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import { getPropertyValue } from './util/propertyUtil';

const LOWER_PRIORITY = 300;

const ALWAYS_DISPLAYED_GROUPS = [
'general',
'multiInstance'
];


export default class ElementTemplatesPropertiesProvider {

Expand Down Expand Up @@ -48,7 +53,7 @@ export default class ElementTemplatesPropertiesProvider {
};

// (1) Add templates group
addGroupsAfter('documentation', groups, [ templatesGroup ]);
addGroupsAfter(ALWAYS_DISPLAYED_GROUPS, groups, [ templatesGroup ]);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a side effect, the template group is displayed above "Documentation". There were no tests about this, so I assumed the value was included by accident. Also, in the old properties panel "Catalog" was displayed above "Documentation".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation is gone as soon as one applies a template.


let elementTemplate = this._elementTemplates.get(element);

Expand Down Expand Up @@ -111,12 +116,20 @@ function overrideGenericEntries(oldEntries, newEntries) {

/**
*
* @param {string} id
* @param {string|string[]} idOrIds
* @param {Array<{ id: string }} groups
* @param {Array<{ id: string }>} groupsToAdd
*/
function addGroupsAfter(id, groups, groupsToAdd) {
const index = groups.findIndex(group => group.id === id);
function addGroupsAfter(idOrIds, groups, groupsToAdd) {
let ids = idOrIds;
if (!Array.isArray(idOrIds)) {
ids = [ idOrIds ];
}

// find index of last group with provided id
const index = groups.reduce((acc, group, index) => {
return ids.includes(group.id) ? index : acc;
}, -1);

if (index !== -1) {
groups.splice(index + 1, 0, ...groupsToAdd);
Expand All @@ -131,7 +144,7 @@ function filterWithEntriesVisible(template, groups) {
if (!template.entriesVisible) {
return groups.filter(group => {
return (
group.id === 'general' ||
ALWAYS_DISPLAYED_GROUPS.includes(group.id) ||
group.id.startsWith('ElementTemplates__')
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,30 @@ describe('provider/cloud-element-templates - ElementTemplates', function() {
}));

});


describe('multiinstance characteristics', function() {

it('should display multi-instance configuration', inject(
async function(elementRegistry, selection, modeling, bpmnFactory) {

// given
const element = elementRegistry.get('Task_1'),
loopCharacteristics = bpmnFactory.create('bpmn:MultiInstanceLoopCharacteristics');

// when
modeling.updateProperties(element, { loopCharacteristics });
await act(() => {
selection.select(element);
});

// then
const group = domQuery('[data-group-id="group-multiInstance"]', container);

expect(group).to.exist;
})
);
});
});


Expand Down