-
Notifications
You must be signed in to change notification settings - Fork 33
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
Conversation
♻️ PR Preview 7814873 has been successfully destroyed since this PR has been closed. 🤖 By surge-preview |
♻️ PR Preview 7814873 has been successfully destroyed since this PR has been closed. 🤖 By surge-preview |
…mentation Don't check verticalAlign as we only need 3 positions. This reduces the method complexity.
in integration and e2e tests
Use a dedicated msg flow diagram Based on the existing one with complex path but without labels an with envelope icons.
Use array of ids and positions
Important note about overlays on message flowsThis 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. |
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: and positioned badly(starting point) while path attribute value is:
Further investigation must be done to find out what happens under the hood of mxgraph. |
const pts = state.absolutePoints; | ||
// 1st point for start position | ||
if (this.align == mxgraph.mxConstants.ALIGN_LEFT) { | ||
return pts[0]; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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[]] { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>>[ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Kudos, SonarCloud Quality Gate passed! |
Closes #1166
Closes #1168