-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Added support to different diagrams per XML file #967
Conversation
Thanks for filing this pull request. Being able to specify which diagram you want to import would definitely be an improvement. We'll look into this. In the meantime, a few thoughts:
|
Let me know if something else is needed |
Thanks for your follow up @snakebyte85. Could you add some test cases that bring the code coverage to a decent amount? |
I added the needed test cases. I added two bpmns to be tested:
Sorry if I didn't that before but I am not practical of the used test enviroment and used patterns. Let me know if tests needed to be modified |
Thank you for your further commits. I left a few comments that will need to be resolved before we merge the PR. Can you please make sure your commits adhere to our contributing rules? Can we also have a test case for a situation when the selected diagram is not present? |
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.
Please read the comments in the code and in the issue for feedback.
393e763
to
2363327
Compare
All done Let me know for something else |
This introduces a new parameter to `Viewer#importXML` which enables to choose the diagram to display. ``` var viewer = new Viewer({ container: container }); viewer.importXML(xml, diagramId, done); ``` Closes bpmn-io#87
2363327
to
36a7713
Compare
b16ffb5
to
f99dcbc
Compare
This adds a method to switch displayed diagram without reimporting xml via ``` var viewer = new Viewer({ container: container }); viewer.importXML(xml, diagramId, done); var diagrams = viewer.getDefinitions().diagrams; viewer.open(diagrams[1], done); ```
f99dcbc
to
ed6fa0a
Compare
I slightly changed the API so that instead of @nikku Can you please have a look at this? |
@snakebyte85 Thanks again for your contribution. @barmac I discovered an issue with re-opens if elements are shown in multiple |
Current state is on https://github.com/bpmn-io/bpmn-js/tree/select-diagram I pushed a bugfix for BpmnTreeWalker when context wasn't passed. This revealed that the current implementation renders more elements than enough, as a result of this. There is also a problem of unnecessary warnings when an element is included in more than one DI. |
I rebased the branch on top of master. There are still two failing test cases.
Please feel free to update your branch with |
Merged via #983. Thanks for your contribution 🎉 |
Different diagrams (processes or collaborations) can be saved inside a single XML file, following BPMN 2.0 standard, but bpmn-js renders only the first diagram.
This commit allows a developer to select a specific diagram to be rendered, using the ID of the process or collaboration in this simply way:
bpmnViewer.importXML(bpmnXML, done, processId);
The first diagram (like before) will be rendered if processId is null
bpmn-js internally already supported the selection of a specific diagram to render, but the interfaces did not allow this
This is useful for #87