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

[FEAT] Add overlays on Edge #1207

Merged
merged 41 commits into from
Apr 1, 2021
Merged

[FEAT] Add overlays on Edge #1207

merged 41 commits into from
Apr 1, 2021

Conversation

aibcmars
Copy link
Contributor

@aibcmars aibcmars commented Mar 29, 2021

Closes #1166
Closes #1168

@aibcmars aibcmars added BPMN diagram usability Something about the way we can interact with BPMN diagrams mvp Formerly used for bpmn-visualization MVP issues/PRs labels Mar 29, 2021
@github-actions
Copy link

github-actions bot commented Mar 29, 2021

♻️ PR Preview 7814873 has been successfully destroyed since this PR has been closed.

🤖 By surge-preview

@github-actions
Copy link

github-actions bot commented Mar 29, 2021

♻️ PR Preview 7814873 has been successfully destroyed since this PR has been closed.

🤖 By surge-preview

@aibcmars aibcmars added the WIP 🚧 Pull request in progress and/or not ready for review. Used in addition to marking it as draft label Mar 29, 2021
aibcmars and others added 23 commits March 29, 2021 16:39
…mentation

Don't check verticalAlign as we only need 3 positions. This reduces the method
complexity.
Use a dedicated msg flow diagram
Based on the existing one with complex path but without labels an with envelope
icons.
@tbouffard
Copy link
Member

Important note about overlays on message flows

This may also apply to other Edges.

Some visualization test snapshots show overlays put on the middle of message flows rendered on the source (aka start point) of the message flows. The coordinates are correctly computed.
Depending on the zoom factor, the overlay is displayed at the right place or not.
This may be related to other issues we have with message flows, in particular, the Message/Sequence Flow start and end points are sometimes not at the right position. See #994

PR-1207_overlays_on_msg_flow_middle_depends_on_scaling

@aibcmars
Copy link
Contributor Author

in addition to what @tbouffard wrote above I found that:

The path itself is changed during the scaling action.

The overlay is well centered while the path attribute value is:
M 464.4 369.51 L 250.07 369.51

and positioned badly(starting point) while path attribute value is:
M 526.1 377 L 526.55 377 Q 527 377 525.58 377 L 387.75 377

Q part that appears in the path is to draw quadratic Bezier curve
(check more about Q here: https://css-tricks.com/svg-path-syntax-illustrated-guide)

Further investigation must be done to find out what happens under the hood of mxgraph.

@aibcmars aibcmars marked this pull request as ready for review March 31, 2021 14:35
@tbouffard tbouffard removed the WIP 🚧 Pull request in progress and/or not ready for review. Used in addition to marking it as draft label Mar 31, 2021
const pts = state.absolutePoints;
// 1st point for start position
if (this.align == mxgraph.mxConstants.ALIGN_LEFT) {
return pts[0];
Copy link
Member

Choose a reason for hiding this comment

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

I won't position the overlay on the first point of the edge, because it looks like the overlay is on the shape.
But rather 5% from the start, like I did in my POC: https://github.com/process-analytics/bpmn-visualization-js/pull/1118/files#diff-45741ef0472aa3227232cd7aa01f962ea65e42f186107a274fb2ad868a7d707dR58

Copy link
Member

Choose a reason for hiding this comment

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

Indeed, this will be better but this won't cover all use cases. Depending on the size of the text put in the overlay, the fixed size 5% may not be enough.
I suggest we think about it quietly (not in a rush right now) and provide a dedicated feature for this, and why not letting integration pass an offset values or a percentage

Copy link
Member

Choose a reason for hiding this comment

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

To do in #1169

}
// last point for end position
else {
return pts[pts.length - 1];
Copy link
Member

Choose a reason for hiding this comment

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

Same comment.

I won't position the overlay on the last point of the edge (and after the arrow), because it looks like the overlay is on the shape.
But rather 5% from the end (before the arrow), like I did in my POC.

const bpmnDiagramNameAssociations = 'overlays.edges.associations.complex.paths';
const bpmnDiagramNameMessageFlows = 'overlays.edges.message.flows.complex.paths';
const bpmnDiagramNameSequenceFlows = 'overlays.edges.sequence.flows.complex.paths';
function getEdgeKindAndIds(bpmnDiagramName: string): [string, string[]] {
Copy link
Member

Choose a reason for hiding this comment

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

I would rather have made a map with the different values ​​instead.

Copy link
Member

Choose a reason for hiding this comment

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

I am on it

}
return [edgeKind, ids];
}
describe.each([bpmnDiagramNameSequenceFlows, bpmnDiagramNameAssociations, bpmnDiagramNameMessageFlows])('diagram %s', (bpmnDiagramName: string) => {
Copy link
Member

Choose a reason for hiding this comment

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

Or directly give the diagram file + the edge kind + the edges id as an array of array. It's more readable to know what we test.

Copy link
Member

Choose a reason for hiding this comment

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

ok I will check this solution too.

Copy link
Member

Choose a reason for hiding this comment

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

I choose this solution, it is clearer. See 91d206b


export const overlayEdgePositionValues = <Array<OverlayEdgePosition>>['start', 'middle', 'end'];

export const overlayShapePositionValues = <Array<OverlayShapePosition>>[
Copy link
Member

Choose a reason for hiding this comment

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

I think to avoid to have this method, and to find all the value manually for the HTML page, it's better to have an enum like FitType.

Copy link
Member

Choose a reason for hiding this comment

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

This function is only used to avoid duplication in tests. Integration won't probably need to put an overlay on all positions for real use cases. So to me this is not an issue.
We already discussed about the drawbacks of using enums. I don't remember exactly why we decided to put a string type union here. For pros/cons, we can check https://2ality.com/2020/02/enum-alternatives-typescript.html#type-unions-vs.-enums
Anyway, if you think this change is valuable, we can think about it but not in this PR IMHO: it is already quite big and this change would break the API as well.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 1, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BPMN diagram usability Something about the way we can interact with BPMN diagrams mvp Formerly used for bpmn-visualization MVP issues/PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] Remove all overlays of a given BPMN element [FEAT] Add overlays on Edge
3 participants