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

Add save callback and buttons to NAD viewer #121

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

massimo-ferraro
Copy link
Contributor

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem?
no

What kind of change does this PR introduce?
feature

What is the current behavior?
In network area diagram viewer it is not possible to save updated SVG or metadata.
By default the mouse is used for moving nodes. For selecting nodes the SHIFT key must be used.

What is the new behavior (if this is a feature change)?
A callback for saving SVG and metadata has been added.
Three buttons can be added to the viewer, two buttons for changing between moving nodes and selecting nodes, and one button for calling the save callback

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

If yes, please check if the following requirements are fulfilled

  • The Breaking Change or Deprecated label has been added
  • The migration steps are described in the following section

What changes might users need to make in their application due to this PR? (migration steps)
the constructor of the NetworkAreaDiagramViewer has 3 additional parameters:

  • the save callback
  • the flag for enabling the visualization of the buttons
  • the default action for the mouse: moving vs. selection

Examples are provided in the demo/src/diagram-viewers/add-diagrams.js file

Comment on lines 529 to 530
button.style.height = '20px';
button.style.width = '20px';
Copy link
Contributor

Choose a reason for hiding this comment

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

25px would be better, and keeping 15px for the corresponding SVGs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

buttonsDiv.appendChild(saveSvgButton);
saveSvgButton.addEventListener('click', () => {
if (this.onSaveCallback != null) {
this.onSaveCallback(this.getSvg(), this.getMetadata());
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that, in a second version, we should differentiate the buttons which remain selected and the one which are clicked once only.

Signed-off-by: massimo.ferraro <[email protected]>
Signed-off-by: massimo.ferraro <[email protected]>
Signed-off-by: massimo.ferraro <[email protected]>
Signed-off-by: massimo.ferraro <[email protected]>
Copy link

sonarcloud bot commented Nov 18, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
20.2% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants