G5/g5-content-management-system — pull request #478 by jcstringer (2014-10-03 23:55:54+00:00)
Title: Refactor drag and drop and moving to trash

https://www.pivotaltracker.com/story/show/79455898

This story was to fix a Firefox bug related to clicking the trash can icon. Under the covers the whole app was going into meltdown any time you drag a page into the trash or reorder page once you get more than a handful of pages due to the update_navigation_settings callback on the WebTemplate model which is a heinous beast. Paired with @variousred and refactored that beast into a Resque job, then also modified the ember and ruby code to only invoke that callback on the last call to the API if it's a batch.

I don't love the coupling between Ember and Rails here but this was the best we could cook up for now. We tried to leave the original behavior intact to be safe, but added a new param called should_update_navigation_settings from ember that can control whether or not the callback gets called, which was ultimately how we told the batch updates to only do the callback on the last call to the API. If the update doesn't come from the ember app, that attr on the model will be nil and the previous behavior should get invoked.