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

Replace jquery ui's sortable with Sortable.js #2523

Merged
merged 10 commits into from
Jan 24, 2018

Conversation

jhawthorn
Copy link
Contributor

@jhawthorn jhawthorn commented Jan 23, 2018

As per #2469, we are looking to remove jquery ui from the admin.

I initially tried to use html5sortable which is nice and very minimal (2KB min+gz). However, I was unable to get it to work satisfactorily on the taxon tree page. There were also minor issues sorting tables (it would get confused if the rows were dragged too far #right).

I ended up using Sortable.js, which is a little heavier (6KB min+gz), but we get a lot from that. Everything just worked without additional code from us (which even jquery ui sortable needed to fix some problems). Sortable's behaviour should also be more user friendly: it shown nice "ghost" placeholders to where the element is to be dropped, supports touch events, supports scrolling the page, and even animations (which I didn't enable, but worth trying in the future).


This PR starts with some housekeeping:

  • Moved table sorting out of backend/admin.js into it's own file, backend/components/sortable_table.js
  • Convert taxons.js.coffee, the "Display order" page, to plain JS (see Clarify that we prefer new files to be in JS, not coffee #2376 for justification)
  • Convert taxonomy.js.coffee, the "taxon tree" page, to plain JS

Before converting the three places jquery-ui/sortable was used:

  • Sortable tables in sortable_table.js
  • The "Display order" page, in taxons.js
  • The "taxon tree" page, in taxonomy.js

This is the last piece of the puzzle for #2469 "Replace jQuery UI".

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

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

Nice work. I really appreciate the usage of vanilla JavaScript instead of jQuery (a dependency we might of thinking removing as well somewhere in the future)

🚀

@jhawthorn jhawthorn force-pushed the admin_sortable_final branch 3 times, most recently from 61b8460 to f22c4f3 Compare January 24, 2018 00:09
@jhawthorn jhawthorn mentioned this pull request Jan 24, 2018
3 tasks
Copy link
Member

@gmacdougall gmacdougall left a comment

Choose a reason for hiding this comment

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

Thanks John

jhawthorn and others added 10 commits January 24, 2018 13:32
This feature doesn't work well. It requires using "Tab" to get focus
on an item in the list. After doing that it allows pressing up/down to
reorder the list.

This feature isn't discoverable to users, so I doubt it has ever been
used. It also doesn't exist in any of our other sortable tables in the
admin.

It could just as be implemented using Sortable.js, which we are moving
to from jquery-ui's sortable, but I would not rather not spend the time
reimplementing something that doesn't work well and isn't consistent
with the rest of the admin. If we want this we need to implement is
across all of our sortable lists.
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.

3 participants