lshift/diffa — pull request #143 by aprescott (2012-05-03 15:05:28+00:00)
Title: Rework inventory upload form to allow pair-based selection

*(Note: this can't yet be merged because of a conflict between data.js and settings.js. Further details are below.)*

The inventory upload has been reworked to provide pair-based selection of two endpoints in addition to choosing from a list of endpoints, as before. [Select2](http://ivaynberg.github.com/select2/) is used to allow easy filtering and clearing.

![New inventory upload form](http://i.imgur.com/Eb9bc.png)

The inventory upload view defined in data.js has been changed from handling a collection of endpoints to just a single endpoint. Two ``s are then used to add either 1 or 2 inventory upload forms, depending on whether a pair has been selected or just a single endpoint. If there are 2 inventory upload forms displayed, they're both independent in the sense that submitting one form does not submit the other.

Status messages (error & success) need a bit more attention to make sure they don't break the layout when there are two forms being displayed.

### Broken settings page

[The call to `loadAll` in data.js](https://github.com/aprescott/diffa/blob/3e405434fd0d500a36970ffbd9479cddab613ef4/agent/src/main/webapp/js/data.js#L383) seems to cause a conflict with a call to `loadAll` in settings.js, possibly due to the asynchronous behaviour of Backbone's fetch. When the data.js `loadAll` call isn't commented out, the "Add New" links on the left-hand side of the settings page is broken, as are the links to edit an existing endpoint/pair: the form to edit the settings does not load, no error is shown in the JavaScript console, and nothing else is printed.

So in summary:

1. Visit the settings page.
2. Try to load the settings for either a new or an existing endpoint/pair and see it fails.
3. Comment out [the `loadAll` call](https://github.com/aprescott/diffa/blob/3e405434fd0d500a36970ffbd9479cddab613ef4/agent/src/main/webapp/js/data.js#L383) in data.js, thus breaking the inventory upload form.
4. Reload the settings page.
5. See that editing settings is working again.