Module: Wice

Defined in:
lib/wice_grid.rb,
lib/view_columns.rb,
lib/grid_renderer.rb,
lib/wice_grid_misc.rb,
lib/grid_output_buffer.rb,
lib/table_column_matrix.rb,
lib/wice_grid_controller.rb,
lib/wice_grid_spreadsheet.rb,
lib/helpers/js_calendar_helpers.rb,
lib/helpers/wice_grid_view_helpers.rb,
lib/helpers/wice_grid_misc_view_helpers.rb,
lib/wice_grid_serialized_queries_controller.rb,
lib/helpers/wice_grid_serialized_queries_view_helpers.rb

Defined Under Namespace

Modules: ConfigurationProvider, Controller, Defaults, ExceptionsMixin, GridTools, GridViewHelper, JsAdaptor, JsCalendarHelpers, SerializedQueriesControllerMixin, WiceGridExtentionToActiveRecordColumn, WiceGridNlMessageProvider Classes: ActionViewColumn, FilterConditionsGenerator, FilterConditionsGeneratorBoolean, FilterConditionsGeneratorCustomFilter, FilterConditionsGeneratorDate, FilterConditionsGeneratorInteger, FilterConditionsGeneratorString, GridOutputBuffer, GridRenderer, Spreadsheet, TableColumnMatrix, ViewColumn, ViewColumnBoolean, ViewColumnCustomDropdown, ViewColumnDate, ViewColumnDatetime, ViewColumnFloat, ViewColumnInteger, ViewColumnString, WiceGrid, WiceGridArgumentError, WiceGridException

Constant Summary collapse

@@model_validated =
false

Class Method Summary collapse

Class Method Details

.define_routes(map, controller) ⇒ Object

Used in routes.rb to define routes to the query processing controller. Parameters:

  • map - the mapper object used in routes.rb to defined routes (instance of ActionController::Routing::RouteSet::Mapper)

  • controller - name of the query processing controller, i.e. 'queries' if the controller is QueriesController .

Read section “Saving Queries How-To” in README for more details.


9
10
11
12
13
14
15
16
17
18
19
# File 'lib/wice_grid_serialized_queries_controller.rb', line 9

def define_routes(map, controller)
  controller = controller.to_s
  map.create_serialized_query '/wice_grid_serialized_queries/:grid_name',
    :controller => controller,
    :action => 'create',
    :conditions => {:method => :post}
  map.delete_serialized_query '/wice_grid_serialized_query/:grid_name/:id',
    :controller => controller,
    :action => 'delete',
    :conditions => {:method => :post}
end

.deprecated_call(old_name, new_name, opts) ⇒ Object

:nodoc:


39
40
41
42
43
44
45
# File 'lib/wice_grid_misc.rb', line 39

def deprecated_call(old_name, new_name, opts) #:nodoc:
  if opts[old_name] && ! opts[new_name]
    opts[new_name] = opts[old_name]
    opts.delete(old_name)
    STDERR.puts "WiceGrid: Parameter :#{old_name} is deprecated, use :#{new_name} instead!"
  end
end

.get_query_store_modelObject

Retrieves and constantizes (if needed ) the Query Store model


21
22
23
24
25
26
27
28
# File 'lib/wice_grid_misc.rb', line 21

def get_query_store_model #:nodoc:

  query_store_model = Wice::ConfigurationProvider.value_for(:QUERY_STORE_MODEL)
  query_store_model = query_store_model.constantize if query_store_model.is_a? String
  raise ::Wice::WiceGridArgumentError.new("Defaults::QUERY_STORE_MODEL must be an ActiveRecord class or a string which can be constantized to an ActiveRecord class") unless query_store_model.kind_of? Class
  validate_query_model(query_store_model) unless @@model_validated
  query_store_model
end

.get_string_matching_operators(model) ⇒ Object

:nodoc:


30
31
32
33
34
35
36
37
# File 'lib/wice_grid_misc.rb', line 30

def get_string_matching_operators(model)   #:nodoc:
  if defined?(Wice::Defaults::STRING_MATCHING_OPERATORS) && Wice::ConfigurationProvider.value_for(:STRING_MATCHING_OPERATORS).is_a?(Hash) &&
      str_matching_operator = Wice::ConfigurationProvider.value_for(:STRING_MATCHING_OPERATORS)[model.connection.class.to_s]
    str_matching_operator
  else
    Wice::ConfigurationProvider.value_for(:STRING_MATCHING_OPERATOR)
  end
end

.log(message) ⇒ Object

:nodoc:


47
48
49
# File 'lib/wice_grid_misc.rb', line 47

def log(message) #:nodoc:
  ActiveRecord::Base.logger.info('WiceGrid: ' + message)
end

.validate_query_model(query_store_model) ⇒ Object

checks whether the class is a valid storage for saved queries


9
10
11
12
13
14
15
16
17
18
# File 'lib/wice_grid_misc.rb', line 9

def validate_query_model(query_store_model)  #:nodoc:
  unless query_store_model.respond_to?(:list)
    raise ::Wice::WiceGridArgumentError.new("Model for saving queries #{query_store_model.class.name} is invalid - there is no class method #list defined")
  end
  arit = query_store_model.method(:list).arity
  unless arit == 2
    raise ::Wice::WiceGridArgumentError.new("Method list in the model for saving queries #{query_store_model.class.name} has wrong arity - it should be 2 instead of #{arit}")
  end
  @@model_validated = true
end