unepwcmc/SAPI — pull request #98 by agnessa (2013-10-23 16:23:09+00:00)
Title: Fixes issues with resetting sandbox when using validation error links

This fix replaces the existing mechanism of filtering by errors, which was causing the problem. Essentially, that mechanism was in place before we had filters. The validation error links were not real filters, but rather each error had an array of matching row ids, and the table content was replaced with whatever rows were returned from the backend. This obviously clashed with the filters, because the state of the filters defines the active selection of rows at all times. In this case, even though visually the content of the table would be set according to row ids, in fact the controller would assume that all rows are selected (because filters were cleared). Editing operations would then trigger resetting of the sandbox content (and result in invalid edits, e.g. 2 rows edited instead of 1), such as:
-> clicking the delete checkbox
-> clicking to edit a particular field and entering e.g. a character
This would typically happen only straight after refresh, so the sequence to reproduce is:
1. refresh
2. follow a validation error link
3. perform one of the above operations

This PR changes the way errors are returned to the frontend. Each validation error has now an "error_selector" attached; that selector will behave differently for different types of validations, but it needs to be always contructed in a way to allow the frontend to select the matching rows using the existing filters.

For now I have not removed the old way of doing things - it is still available under "old buggy link"; I left it in because I was concerned that there may be cases where the two links would return different subsets of rows, so having it in would make it easier to verify.