SitePen/dgrid — pull request #808 by mercmobily (2014-01-07 00:36:55+00:00)
Title: Make sure that store.remove() is called only if store.put() worked when DnDing across containers; emit dgrid-error if errors

Hi,

I started using dgrid with my Json REST stores, and noticed a couple of problems.

1) No dgrid-error was emitted if there was an AJAX error. This meant that it was hard for my application to display an error in the error bar at the top if an error happened (I didn't really want to aspect() around the stores' methods etc.)

2) If the put() onto the destination store failed, but the remove() from the source store worked, you ended up *deleting* an item (!) rather than moving it (!!).

I fixed both of these in DnD.js. I would have created two different pull requests, but they would have conflicted with each other badly.

One note: as you can see, I actually emitted the dgrid-error event, rather than using _StoreMixin._trackError() (the note at the top of DnD.js mentioned "consider emitting store errors via OnDemandList._trackError". I tried using _trackError. However, I had some very strange UI behaviours (the avatar stayed on the screen weirdly, etc.). I *can* battle it even more and try to figure out the strange UI behaviours if using _trackError() is an absolute must. However, this patch works well as it is.

This pull request fixes #805 and #806