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

Import images from JSON which lack coordinates into sidebar #1363

Open
jywarren opened this issue Feb 23, 2023 · 3 comments
Open

Import images from JSON which lack coordinates into sidebar #1363

jywarren opened this issue Feb 23, 2023 · 3 comments

Comments

@jywarren
Copy link
Member

Here, we skip over images which haven't been placed, when importing from a JSON file:

if (imageObj.nodes.length > 0) {
options = {
tooltipText: imageObj.tooltipText,
corners: imageObj.nodes,
};
placeImage(imageURL, options, false);
}

But, we could collect those images and add them to the sidebar, so people can continue to place them?

This isn't a priority or anything, just an idea!

@7malikk
Copy link
Collaborator

7malikk commented Feb 27, 2023

Hello, @jywarren I took a look into implementing this suggestion, and here's my result:

loadLegacyInSidebar

In the above GIF, I was able to load the two images that had no values in the nodes array

I extracted a part of the renderImages() making it reusable for both scenarios (i.e to display images from the regular IA URL and also from a legacy JSON file)

renderImages() now looks like this

renderImages = (args) => {
   args.forEach((file) => {
      renderAnImage(file, url)
   }
)}

where renderAnImage() handles the rendering of a single image on the sidebar

Observations

  • If you take a look at the pagination, it reads 0 of 0 - 0 which is its default value, this is because I did not tamper with the paginator class to create this, which leads to my next point
  • for a smoother/elegant display, considering a scenario where there are many images without node values, the paginator class would need to undergo a not-so-minimal refactor

What are your thoughts? @jywarren

@jywarren
Copy link
Member Author

jywarren commented Feb 27, 2023 via email

@7malikk
Copy link
Collaborator

7malikk commented Feb 27, 2023

Hi, this looks great, and I want to say I think due to the way mapknitter had worked, I don't think there will be too many images for each map, and we can leave pagination out for this use case. But thank you for carefully considering it!

Alright sounds great, will make a PR on it as soon as we finish up on the other one. Thanks!

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

No branches or pull requests

2 participants