Module: Wice

Defined in:
lib/wice/columns.rb,
lib/wice_grid.rb,
lib/wice/grid_renderer.rb,
lib/wice/wice_grid_misc.rb,
lib/wice/grid_output_buffer.rb,
lib/wice/wice_grid_core_ext.rb,
lib/wice/columns/column_date.rb,
lib/wice/table_column_matrix.rb,
lib/wice/columns/column_float.rb,
lib/wice/columns/column_range.rb,
lib/wice/wice_grid_controller.rb,
lib/wice/columns/column_action.rb,
lib/wice/columns/column_string.rb,
lib/wice/wice_grid_spreadsheet.rb,
lib/wice/columns/column_boolean.rb,
lib/wice/columns/column_integer.rb,
lib/wice/columns/column_datetime.rb,
lib/wice/helpers/bs_calendar_helpers.rb,
lib/wice/helpers/js_calendar_helpers.rb,
lib/wice/active_record_column_wrapper.rb,
lib/wice/columns/column_custom_dropdown.rb,
lib/wice/columns/column_processor_index.rb,
lib/wice/helpers/wice_grid_view_helpers.rb,
lib/wice/helpers/wice_grid_misc_view_helpers.rb,
lib/wice/wice_grid_serialized_queries_controller.rb,
lib/wice/helpers/wice_grid_serialized_queries_view_helpers.rb

Overview

:nodoc:

Defined Under Namespace

Modules: BsCalendarHelpers, Columns, ConfigurationProvider, Controller, Defaults, ExceptionsMixin, GridTools, GridViewHelper, JsCalendarHelpers, MergeConditions, NlMessage, SerializedQueriesControllerMixin, WgArray, WgEnumerable, WgHash, WiceGridExtentionToActiveRecordColumn Classes: ActiveRecordColumnWrapper, GridOutputBuffer, GridRenderer, Spreadsheet, TableColumnMatrix, WiceGrid, WiceGridArgumentError, WiceGridEngine, WiceGridException, WiceGridMissingConfigurationConstantException

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 context of the routes execution (instance of ActionDispatch::Routing::Mapper). Normally use self for the first argument: Wice::define_routes(self, 'queries')

  • 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
20
# File 'lib/wice/wice_grid_serialized_queries_controller.rb', line 9

def define_routes(map, controller)
  controller = controller.to_s

  map.post '/wice_grid_serialized_queries/:grid_name',
    to: "#{controller}#create_saved_query",
    as: 'create_serialized_query'

  map.post '/wice_grid_serialized_queries/:grid_name/:id',
    to: "#{controller}#delete_saved_query",
    as: 'delete_serialized_query'

end

.deprecated_call(old_name, new_name, opts) ⇒ Object

:nodoc:



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

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



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

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:



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

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:



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

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



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

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