Module: Wice::SerializedQueriesControllerMixin

Defined in:
lib/wice_grid_serialized_queries_controller.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#createObject

:nodoc:



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

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

  @saved_query = @query_store_model.new(:grid_name => @grid_name, :name => params[:query_name], :query => query_params)

  @saved_query.attributes = params[:extra] unless params[:extra].blank?

  if @saved_query.save
    @grid_title_id = "#{@grid_name}_title"
    @notification_messages = WiceGridNlMessageProvider.get_message(:QUERY_SAVED_MESSAGE)
  else
    @error_messages = @saved_query.errors.map{ |_, msg| msg }.join(' ')
  end

  render :file => "#{RAILS_ROOT}/vendor/plugins/wice_grid/lib/views/create.rjs"
end

#deleteObject

:nodoc:



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

def delete  #: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 = WiceGridNlMessageProvider.get_message(:QUERY_DELETED_MESSAGE)
    else
      @error_messages = sq.errors.full_raw_messages.join(' ')
    end
  end
  render :file => "#{RAILS_ROOT}/vendor/plugins/wice_grid/lib/views/delete.rjs"
end

#extraObject



62
63
64
# File 'lib/wice_grid_serialized_queries_controller.rb', line 62

def extra
  params[:extra]
end