Module: Wice::Defaults

Defined in:
lib/wice/wice_grid_misc.rb

Overview

:nodoc:

Constant Summary collapse

PER_PAGE =

Default number of rows to show per page.

20
ORDER_DIRECTION =

Default order direction

'asc'
GRID_NAME =

Default name for a grid. A grid name is the basis for a lot of names including parameter names, DOM IDs, etc The shorter the name is the shorter the request URI will be.

'grid'
REUSE_LAST_COLUMN_FOR_FILTER_ICONS =

If REUSE_LAST_COLUMN_FOR_FILTER_ICONS is true and the last column doesn’t have any filter and column name, it will be used for filter related icons (filter icon, reset icon, show/hide icon), otherwise an additional table column is added.

true
CUSTOM_FILTER_ALL_LABEL =

The label of the first option of a custom dropdown list meaning ‘All items’

'--'
DEFAULT_TABLE_CLASSES =

A list of classes for the table tag of the grid

['table', 'table-bordered', 'table-striped']
ALLOW_MULTIPLE_SELECTION =

Allow switching between a single and multiple selection modes in custom filters (dropdown boxes)

true
SHOW_UPPER_PAGINATION_PANEL =

Show the upper pagination panel by default or not

false
ENABLE_EXPORT_TO_CSV =

Disabling CSV export by default

false
CSV_FIELD_SEPARATOR =

Default CSV field separator

','
CSV_ENCODING =

Default CSV encoding (p.e. ‘CP1252:UTF-8’ to make Microsoft Excel(tm) happy)

nil
SHOW_FILTER =

The strategy when to show the filter.

  • :when_filtered - when the table is the result of filtering

  • :always - show the filter always

  • :no - never show the filter

:always
AUTO_RELOAD =

A boolean value specifying if a change in a filter triggers reloading of the grid.

false
STRING_MATCHING_OPERATOR =

SQL operator used for matching strings in string filters.

'LIKE'
STRING_MATCHING_OPERATORS =

Defining one string matching operator globally for the whole application turns is not enough when you connect to two databases one of which is MySQL and the other is Postgresql. If the key for an adapter is missing it will fall back to Wice::Defaults::STRING_MATCHING_OPERATOR.

‘CI_LIKE’ is a special value. Setting a value in STRING_MATCHING_OPERATORS to CI_LIKE will result in the following SQL:

UPPER(table.field) LIKE  UPPER(?)"
{
  'ActiveRecord::ConnectionAdapters::MysqlAdapter'      => 'LIKE',
  'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter' => 'ILIKE'
}
NEGATION_IN_STRING_FILTERS =

Switch of the negation checkbox in all text filters

false
ALLOW_SHOWING_ALL_RECORDS =

Enable or disable showing all records (non-paginated table)

true
START_SHOWING_WARNING_FROM =

If number of all queries is more than this value, the user will be given a warning message

100
SHOW_ALL_ALLOWED_UP_TO =

Hide the “show all” link if the number of all records is more than… Force-resets back to pagination starting from this value. Set to nil to always show it

nil
SWITCH_BACK_TO_PAGINATION_FROM =

set to nil to skip the check

nil
QUERY_STORE_MODEL =

ActiveRecord model to store queries. Read the documentation for details QUERY_STORE_MODEL = ‘WiceGridSerializedQuery’

'WiceGridSerializedQuery'
DEFAULT_FILTER_FOR_DATE =

Default column filters Possible values:

  • :jquery_datepicker - Jquery datepicker (works for datetime, too)

  • :bootstrap_datepicker - Bootstrap datepicker (works for datetime, too)

  • :rails_date_helper - standard Rails date helper

  • :rails_datetime_helper - standard Rails datetime helper

:jquery_datepicker
DEFAULT_FILTER_FOR_DATETIME =
:jquery_datepicker
DATETIME_FORMAT =

Format of the datetime displayed. If you change the format, make sure to check if DATETIME_PARSER can still parse this string.

'%Y-%m-%d %H:%M'
DATE_FORMAT =

Format of the date displayed. If you change the format, make sure to check if DATE_PARSER can still parse this string.

'%Y-%m-%d'
DATE_FORMAT_JQUERY =

Format of the date displayed in jQuery’s Datepicker If you change the format, make sure to check if DATE_PARSER can still parse this string.

'yy-mm-dd'
DATE_FORMAT_BOOTSTRAP =

Format of the date displayed in Bootstrap’s Datepicker If you change the format, make sure to check if DATE_PARSER can still parse this string.

'yyyy-mm-dd'
DATETIME_PARSER =

With Calendar helpers enabled the parameter sent is the string displayed. This lambda will be given a date string in the format defined by DATETIME_FORMAT and must generate a DateTime object. In many cases Time.zone.parse is enough, for instance, %Y-%m-%d. If you change the format, make sure to check this code and modify it if needed.

lambda do|datetime_string|
  if datetime_string.blank?
    nil
  elsif Time.zone
    Time.zone.parse(datetime_string)
  else
    Time.parse(datetime_string)
  end
end
DATEPICKER_YEAR_RANGE =

The range of years to display in jQuery Datepicker. It can always be changed dynamically with the following javascript:

$( ".hasDatepicker" ).datepicker( "option", "yearRange", "2000:2042" );
(from = Date.current.year - 10).to_s + ':' + (from + 15).to_s
DATE_PARSER =

With Calendar helpers enabled the parameter sent is the string displayed. This lambda will be given a date string in the format defined by DATETIME and must generate a Date object. In many cases Date.parse is enough, for instance, %Y-%m-%d. If you change the format, make sure to check this code and modify it if needed.

lambda do|date_string|
  if date_string.blank?
    nil
  else
    begin
      Date.parse(date_string)
    rescue ArgumentError
      nil
    end
  end
end
PAGE_METHOD_NAME =

The name of the page method (should correspond to Kaminari.config.page_method_name)

:page
PAGINATION_THEME =

The name of the theme to use for the pagination with Kaminari

:wice_grid
USE_DEFAULT_SCOPE =

By default ActiveRecord calls are always executed inside Model.unscoped{}. Setting USE_DEFAULT_SCOPE to true will use the default scope for all queries.

false