Module: Wice::SerializedQueriesControllerMixin

Defined in:
lib/wice/wice_grid_serialized_queries_controller.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#create_saved_queryObject

:nodoc:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/wice/wice_grid_serialized_queries_controller.rb', line 39

def create_saved_query  #:nodoc:
  init
  query_params = if params[@grid_name]
    params[@grid_name]
  else
    {}
  end
  query_params.delete(:page)

  @saved_query = @query_store_model.new

  @saved_query.grid_name = @grid_name
  @saved_query.name      = params[:query_name]
  @saved_query.query     = query_params

  @saved_query.attributes = extra unless extra.nil?

  if @saved_query.save
    @grid_title_id = "#{@grid_name}_title"
    @notification_messages = NlMessage['query_saved_message']
  else
    @error_messages = @saved_query.errors.map { |_, msg| msg }.join(' ')
  end

  render_asyns_result
end

#delete_saved_queryObject

:nodoc:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/wice/wice_grid_serialized_queries_controller.rb', line 23

def delete_saved_query  #:nodoc:
  init
  if sq = @query_store_model.find_by_id_and_grid_name(params[:id], @grid_name)
    if sq.destroy
      if params[:current]
        @current = @query_store_model.find_by_id_and_grid_name(params[:current], @grid_name)
      end
      @notification_messages = NlMessage['query_deleted_message']
    else
      @error_messages = sq.errors.full_raw_messages.join(' ')
    end
  end

  render_asyns_result
end

#extraObject

:nodoc:



66
67
68
# File 'lib/wice/wice_grid_serialized_queries_controller.rb', line 66

def extra #:nodoc:
  params[:extra].permit! unless params[:extra].nil?
end