Skip to content
New issue

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

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

Already on GitHub? # to your account

Vertically Auto-Place Elements In Collapsed Subprocesses #2205

Merged
merged 1 commit into from
Aug 19, 2024

Conversation

sombrek
Copy link
Contributor

@sombrek sombrek commented Jul 20, 2024

Proposed Changes

Closes #2127

This already worked for expanded sub processes.

Visual demo

visual-demo

@barmac
Copy link
Member

barmac commented Jul 30, 2024

Thanks for the PR. I will look into this later this week.

@barmac barmac self-assigned this Jul 30, 2024
@barmac barmac force-pushed the auto-place-in-vertical-sub-process branch from d3685d8 to 3b15986 Compare August 2, 2024 12:08
Comment on lines 56 to 59
parent = getParent(element, 'bpmn:Participant');
if (parent) {
return isHorizontal(parent);
} else if (isAny(element, types)) {
} else if (is(element, 'bpmn:Participant')) {
Copy link
Member

Choose a reason for hiding this comment

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

Does it mean we don't care about vertical/horizontal Lane anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. We still care.

Comment on lines 63 to 82
var process;
for (process = getBusinessObject(element); process; process = process.$parent) {
if (is(process, 'bpmn:Process')) {
break;
}
}

// The direction may be specified in another diagram. We ignore that there
// could be multiple diagrams with contradicting properties based on the
// assumption that such BPMN files are unusual.
var pool = elementRegistry.find(function(shape) {
var businessObject = getBusinessObject(shape);
return businessObject && businessObject.get('processRef') === process;
});
Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately, for some elements on a collaboration diagram process ends up being undefined, and this leads to unexpected outcomes.

Screen.Recording.2024-08-02.at.14.27.40.mov

*
* @return {boolean} false for vertical pools, lanes and their children. true otherwise
*/
export function isDirectionHorizontal(element) {
export function isDirectionHorizontal(element, elementRegistry) {
Copy link
Member

Choose a reason for hiding this comment

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

Since we are requiring an additional argument now to handle the additional use case, this could mean we are introducing a potentially breaking change of the util. I'd rather have an escape hatch to return the default value (true) in case elementRegistry is not passed except for the cases that we can solve with the old code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've made the argument optional.

@barmac
Copy link
Member

barmac commented Aug 2, 2024

Thanks for another contribution of yours.
I've left a couple of comments, and there are blockers to resolve among them (function parameter, group on collaboration).

@sombrek
Copy link
Contributor Author

sombrek commented Aug 2, 2024

@barmac Thanks for your review. I think I've adressed your comments as far as possible.

By the way, there seem to be building issues, but I don't think they're caused by the PR.
I'd also like to find out why those pesky merges started to appear.

@barmac barmac force-pushed the auto-place-in-vertical-sub-process branch from 2778216 to 215e0e7 Compare August 7, 2024 09:38
Copy link
Member

@barmac barmac left a comment

Choose a reason for hiding this comment

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

I left a couple of minor suggestions to merge.

@@ -37,19 +42,48 @@ export function getParent(element, anyType) {
* Determines if the local modeling direction is vertical or horizontal.
*
* @param {Element} element
* @param {ElementRegistry} elementRegistry
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @param {ElementRegistry} elementRegistry
* @param {ElementRegistry} [elementRegistry] - provide to support collapsed subprocess direction

*
* @return {boolean} false for vertical pools, lanes and their children. true otherwise
*/
export function isDirectionHorizontal(element) {
export function isDirectionHorizontal(element, elementRegistry = undefined) {
Copy link
Member

Choose a reason for hiding this comment

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

Optional argument defaults to undefined when not provided:

Suggested change
export function isDirectionHorizontal(element, elementRegistry = undefined) {
export function isDirectionHorizontal(element, elementRegistry) {

}
}

if (elementRegistry === undefined) {
Copy link
Member

Choose a reason for hiding this comment

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

Let's use idiomatic JS:

Suggested change
if (elementRegistry === undefined) {
if (!elementRegistry) {

@barmac
Copy link
Member

barmac commented Aug 12, 2024

CI failures seem to be caused by some GH Actions outage 🤷

@sombrek
Copy link
Contributor Author

sombrek commented Aug 14, 2024

I left a couple of minor suggestions to merge.

Thank you. I have adapted the changes. Also, the builds finally pass.

@barmac
Copy link
Member

barmac commented Aug 14, 2024

Can you please rebase this? There are some conflicts to resolve according to GH.

@sombrek sombrek force-pushed the auto-place-in-vertical-sub-process branch from 756f509 to 7b1b727 Compare August 15, 2024 05:50
@sombrek sombrek force-pushed the auto-place-in-vertical-sub-process branch from 7b1b727 to fa01871 Compare August 15, 2024 05:58
@sombrek
Copy link
Contributor Author

sombrek commented Aug 15, 2024

All should be clear now.

@barmac barmac merged commit 61f0d72 into bpmn-io:develop Aug 19, 2024
9 checks passed
@barmac
Copy link
Member

barmac commented Aug 19, 2024

Thanks!

@sombrek sombrek deleted the auto-place-in-vertical-sub-process branch January 17, 2025 12:28
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Elements Within Sub-Processes are Placed Horizontally
2 participants