AgileVentures / osra

Sponsor orphans in Syria & ensure basic life & education requirements for Syrian children
MIT License
20 stars 39 forks source link

Osra418 sort by table header for orphans #381

Closed robbiejackson closed 9 years ago

robbiejackson commented 9 years ago

This functionality for sorting by headers follows the design proposed in http://railscasts.com/episodes/228-sortable-table-columns and the first part of http://railscasts.com/episodes/240-search-sort-paginate-with-ajax. There will be commonality between this sorting for Orphans and sorting other tables, so please comment particularly on these aspects so that we can agree on their design. They are:

  1. The use of the helper function sortable_column
  2. The use of the private methods #sort_column and #sort_direction in the controllers (to prevent SQL injection attacks)
  3. The CSS class we use to indicate the current sorting column and direction (asc/desc) (eg we might instead want to have 2 classes one for the column and one for the direction, as shown in the railscast). (I've just created temporarily a little CSS in /assets/stylesheets/hq.scss to make the background of the column header green if it's an ascending sort, pink if descending).
robbiejackson commented 9 years ago

Column sort functionality moved from hq orphan controller into Orphan model - for comparison with similar functionality in the Sponsor area.