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:



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

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 = params[:extra] unless params[:extra].blank?

  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:



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

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



68
69
70
# File 'lib/wice/wice_grid_serialized_queries_controller.rb', line 68

def extra
  params[:extra]
end