Merge pull request #1359 from opf/fix/8002-angular-save-query-sortation

Hacky fix to get query sortation saving and loading in wp view.
pull/1338/merge
Till Breuer 11 years ago
commit 75c6c6b36d
  1. 7
      app/controllers/api/v3/queries_controller.rb

@ -117,6 +117,7 @@ module Api::V3
@query.is_public = false unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin?
view_context.add_filter_from_params if params[:fields] || params[:f]
@query.group_by ||= params[:group_by]
@query.sort_criteria = prepare_sort_criteria if params[:sort]
@query.project = nil if params[:query_is_for_all]
@query.display_sums ||= params[:display_sums].present?
@query.column_names = params[:c] if params[:c]
@ -125,6 +126,12 @@ module Api::V3
@query.is_public = params[:is_public] if params[:is_public]
end
def prepare_sort_criteria
# Note: There was a convention to have sortation strings in the form "type:desc,status:asc".
# For the sake of not breaking from convention we encoding/decoding the sortation.
params[:sort].split(',').collect{|p| [p.split(':')[0], p.split(':')[1] || 'asc']}
end
def visible_queries
unless @visible_queries
# User can see public queries and his own queries

Loading…
Cancel
Save