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

Normalize keybindings #229

Merged
merged 28 commits into from
May 7, 2019
Merged

Conversation

sashadev-sky
Copy link
Member

@sashadev-sky sashadev-sky commented Apr 21, 2019

Fixes #226, #208, #219, #174, #211 (<=== Add issue number here)

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • PR is descriptively titled 📑 and links the original issue above 🔗
  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with grunt
  • code is in uniquely-named feature branch and has no merge conflicts 📁
  • screenshots/GIFs are attached 📎 in case of UI updation
  • @mention the original creator of the issue in a comment below for help or for a review

We're happy to help you get this ready -- don't be afraid to ask for help, and don't be discouraged if your tests fail at first!

If tests do fail, click on the red X to learn why by reading the logs.

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software

Thanks!

===================================

  1. RotateAndScaleHandles -> RotateScaleHandles

  2. Rotate -> RotateScale

  3. RotateStandalone -> Rotate

  4. ToggleRotateDistort -> ToggleRotateScale (still a little confusing but at least now consistent)

  5. _toggleIsolate keybinding temporarily (or maybe permanently) deleted

  6. _toggleScale and _toggleRotate temporarily uncommented until they have their own toolbar keys. (see pending below)

  7. hotkeys in multiple image select only toggle the state for one currently selected image (besides deselect all via escape / map click). This works through a _selected property that is assigned and managed in L.DistortableImage.Edit.js

  8. Ensures that hotkeys don't override "locked" mode unless you explicitly toggleLock.

  9. Fixes bug where the _removeOverlay hotkey triggers a confirm "you want to delete" multiple times (by the number of images you have) and then just deletes all of them at once.

  10. Allow images to be initialized as "selected" #174: show toolbar and markers initially on one of the images - there is now an optional selected: true option

  11. Incorporate newer key API method in place of the deprecated which method #211 Incorporate newer key API method in place of the deprecated which method

  12. adds testing for both single and multiple image selection / deselection (including testing for images that are locked)

  13. Added documentation in README for new selected option, plus improved documentation of all available options
    ===================================

PENDING:

  • Confirm with @rexagod about reverting his polyfill for now - pending confirmation

  • open a new PR to fix a deletion bug pointed out by @rexagod in Bug: Multiple image select with boxZoom #186. Point 9 here solved this bug for deletion using its keybinding but not for deletion using the toolbar action.

  • update keymapper to reflect updates made here

  • allow for rotateScale mode once @rexagod PR add default selector Add default selector #206 is merged

  • open new PR for @rexagod to add scale, rotate, toolbar icons then uncomment the keybindings for those? For now, the icon that is mean for rotating is RotateScale and therefore that keybinding is not uncommented. But it will be up to you which keybindings pair with which icons as long as they all have one.

    Let's just say as a rule, we don't expose or make available the separated Rotate and Scale tools at all, as they're only for (edited) Publish changes compatible with downstream React wrapper #105 usage, and we always assume the combined RotateAndScale tool.
    • But after further discussion decided to keep these tools, so the next step is just to add toolbar keys for them. For now I have uncommented their keybindings

@sashadev-sky
Copy link
Member Author

sashadev-sky commented Apr 21, 2019

@jywarren please review! I think this would be easier if you just pulled it and looked at it rather than uploading GIFs?

Before wrote:
I turned off all of the hotkeys for multiple image select except for deselect all on escape / map click
......

taking this back now:
instead hotkeys in multiple image select only toggle the state for one currently selected image now (besides deselect all via escape / map click). This works through a _selected property that is assigned and managed in L.DistortableImage.Edit.js

I think that if we want to introduce multiple image actions, we need to introduce breaking changes of requiring a feature group, and letting it manage all the toggle actions. Otherwise it gets more and more complicated to deal with event propagation and UI updates. This will reduce a lot of bugs we have in our code too, and we can stop developing for two completely separate cases (index.html vs select.html)

@rexagod what are your thoughts

@sashadev-sky
Copy link
Member Author

Also @jywarren what did you mean by issue #174? Just that the markers and toolbar will be on for one image initially? This was a really quick fix here, I just commented out the code that hides the toolbar / markers initially. Please let me know if this is what you were looking for! (Once again easier to test for yourself at this point I think)

@sashadev-sky
Copy link
Member Author

@jywarren - regarding #174 - is this what you would like: in single image and multiple image interface one image will always be displayed as selected right when the page loads (that is, handlers and toolbar). This is not counting locked images, whose handles are always immediately present
Screen Shot 2019-04-30 at 6 47 33 PM
Screen Shot 2019-04-30 at 6 47 17 PM

This will just be the default way it works. I think this is fine, rather than passing in option to make it do this. But really up to you

@jywarren
Copy link
Member

jywarren commented Apr 30, 2019 via email

@sashadev-sky
Copy link
Member Author

sashadev-sky commented Apr 30, 2019

I think not everyone will want this to be the case, so I had hoped for a constructor parameter like isSelected to set to true, but defaulting false. Could we do this? Thank you!

No problem! Lock will stay as is though. Is that fine? I think locked images should show they are locked at all times. I will update new UI once changes are made @jywarren

@jywarren
Copy link
Member

jywarren commented Apr 30, 2019 via email

@sashadev-sky
Copy link
Member Author

@jywarren not sure I am really understanding, but if the image is locked and you click 'embed code', it just unlocks it. So is it fine to continue with the same logic I have or is there something else I should change.

@jywarren
Copy link
Member

Sorry, i should've tried explaining more. Basically, when people make maps, sometimes they want to share them on a blog or on PL.org, not in an editable state, but just distorted and not interactive at all (besides being able to pan the overall map). So we have this "embed code" field here:

image

And that shows an iframe with this view, which as you can see is totally not editable: https://mapknitter.org/embed/cranston-test

For that use case, the images are "locked" essentially, but we don't show any UI on top of them at all, because they are essentially "part of the map". Make sense? Thanks!

@sashadev-sky
Copy link
Member Author

@jywarren Ok four scenarios for you to see here to decide if this is exactly what you are looking for, and then I will add doc. / testing:

index.html (single image interface)

  • scenario 1 image not initialized with selected: true passed

s1

  • scenario 2 image initialized with selected: true passed

s2

select.html (multiple image interface)

  • scenario 3 no images initialized with selected: true passed (note behavior of lock)

s3

  • scenario 4 one image initialized with selected: true passed

s4

  • scenario 5 two images initialized with selected: true passed - the same image as before and another one. Collection group ensures that even if you pass selected: true to multiple images, only the last one added to the group will actually be selected

s4

  • scenario 6 an image with mode: lock is passed selected: true:

s6

@sashadev-sky
Copy link
Member Author

Sorry, i should've tried explaining more. Basically, when people make maps, sometimes they want to share them on a blog or on PL.org, not in an editable state, but just distorted and not interactive at all (besides being able to pan the overall map). So we have this "embed code" field here:

image

And that shows an iframe with this view, which as you can see is totally not editable: https://mapknitter.org/embed/cranston-test

For that use case, the images are "locked" essentially, but we don't show any UI on top of them at all, because they are essentially "part of the map". Make sense? Thanks!

This has nothing to do with the initialization code here though, right? That logic is placed further down the line in mapknitter?

@jywarren
Copy link
Member

jywarren commented May 1, 2019 via email

@jywarren
Copy link
Member

jywarren commented May 7, 2019

This is great. Thanks for the detailed summary, and go ahead and merge!

Let's release a new version, and ensure it gets pulled into MapKnitter and appears on http://mapknitter-unstable.laboratoriopublico.org (from stable branch there!)

@jywarren
Copy link
Member

jywarren commented May 7, 2019

er, unstable branch!

@rexagod
Copy link
Member

rexagod commented May 7, 2019

@sashadev-sky, I'm okay with the polyfill removed as long as all the tests pass, also I'm looking to implement async functions in the future if any such issue arises. So yeah, this looks good to merge!

@sashadev-sky sashadev-sky merged commit c3eda90 into publiclab:main May 7, 2019
@sashadev-sky sashadev-sky mentioned this pull request May 8, 2019
5 tasks
@sashadev-sky
Copy link
Member Author

@jywarren sounds good I just made a PR to bump the version I will tag you there for review then draft new release

@sashadev-sky
Copy link
Member Author

@jywarren Ok I drafted a release let me know your thoughts on going forward with mentions in the releases! You can remove that part if you prefer not to start doing that.

Also, what is the easiest way to create a tarball?

@jywarren
Copy link
Member

jywarren commented May 8, 2019 via email

@sashadev-sky
Copy link
Member Author

@jywarren Oh I see the assets are there now! I didn't realize they were autogenerated, I refreshed the page after I posted the draft but I'm realizing now that they are probably then generated automatically when you hit publish

@sashadev-sky sashadev-sky deleted the keybindings-u branch June 19, 2019 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UI ambiguities around rotate and scale
3 participants