wice_grid_ms 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.inch.yml +3 -0
- data/.rspec +3 -0
- data/.rubocop.yml +181 -0
- data/.travis.yml +22 -0
- data/CHANGELOG.md +714 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +20 -0
- data/README.md +1518 -0
- data/Rakefile +59 -0
- data/SAVED_QUERIES_HOWTO.md +113 -0
- data/TODO.md +16 -0
- data/app/views/kaminari/wice_grid/_gap.html.erb +1 -0
- data/app/views/kaminari/wice_grid/_next_page.html.erb +1 -0
- data/app/views/kaminari/wice_grid/_page.html.erb +1 -0
- data/app/views/kaminari/wice_grid/_paginator.html.erb +19 -0
- data/app/views/kaminari/wice_grid/_prev_page.html.erb +1 -0
- data/config/locales/cz.yml +45 -0
- data/config/locales/de.yml +47 -0
- data/config/locales/en.yml +47 -0
- data/config/locales/es.yml +47 -0
- data/config/locales/fr.yml +45 -0
- data/config/locales/is.yml +46 -0
- data/config/locales/it.yml +38 -0
- data/config/locales/ja.yml +47 -0
- data/config/locales/nl.yml +45 -0
- data/config/locales/pt-BR.yml +36 -0
- data/config/locales/pt.yml +45 -0
- data/config/locales/ru.yml +45 -0
- data/config/locales/sk.yml +45 -0
- data/config/locales/uk.yml +45 -0
- data/config/locales/zh.yml +45 -0
- data/lib/generators/wice_grid/add_migration_for_serialized_queries_generator.rb +20 -0
- data/lib/generators/wice_grid/install_generator.rb +14 -0
- data/lib/generators/wice_grid/templates/create_wice_grid_serialized_queries.rb +14 -0
- data/lib/generators/wice_grid/templates/wice_grid_config.rb +192 -0
- data/lib/wice/active_record_column_wrapper.rb +123 -0
- data/lib/wice/columns.rb +276 -0
- data/lib/wice/columns/column_action.rb +52 -0
- data/lib/wice/columns/column_boolean.rb +40 -0
- data/lib/wice/columns/column_bootstrap_datepicker.rb +48 -0
- data/lib/wice/columns/column_custom_dropdown.rb +115 -0
- data/lib/wice/columns/column_float.rb +9 -0
- data/lib/wice/columns/column_html5_datepicker.rb +31 -0
- data/lib/wice/columns/column_integer.rb +78 -0
- data/lib/wice/columns/column_jquery_datepicker.rb +49 -0
- data/lib/wice/columns/column_processor_index.rb +23 -0
- data/lib/wice/columns/column_rails_date_helper.rb +41 -0
- data/lib/wice/columns/column_rails_datetime_helper.rb +40 -0
- data/lib/wice/columns/column_range.rb +72 -0
- data/lib/wice/columns/column_string.rb +92 -0
- data/lib/wice/columns/common_date_datetime_mixin.rb +20 -0
- data/lib/wice/columns/common_js_date_datetime_conditions_generator_mixin.rb +42 -0
- data/lib/wice/columns/common_js_date_datetime_mixin.rb +15 -0
- data/lib/wice/columns/common_rails_date_datetime_conditions_generator_mixin.rb +26 -0
- data/lib/wice/columns/common_standard_helper_date_datetime_mixin.rb +22 -0
- data/lib/wice/grid_output_buffer.rb +49 -0
- data/lib/wice/grid_renderer.rb +609 -0
- data/lib/wice/helpers/bs_calendar_helpers.rb +66 -0
- data/lib/wice/helpers/js_calendar_helpers.rb +83 -0
- data/lib/wice/helpers/wice_grid_misc_view_helpers.rb +75 -0
- data/lib/wice/helpers/wice_grid_serialized_queries_view_helpers.rb +95 -0
- data/lib/wice/helpers/wice_grid_view_helpers.rb +718 -0
- data/lib/wice/kaminari_monkey_patching.rb +14 -0
- data/lib/wice/table_column_matrix.rb +65 -0
- data/lib/wice/wice_grid_controller.rb +223 -0
- data/lib/wice/wice_grid_core_ext.rb +142 -0
- data/lib/wice/wice_grid_misc.rb +209 -0
- data/lib/wice/wice_grid_serialized_queries_controller.rb +87 -0
- data/lib/wice/wice_grid_serialized_query.rb +14 -0
- data/lib/wice/wice_grid_spreadsheet.rb +20 -0
- data/lib/wice_grid.rb +676 -0
- data/release_notes/RELEASE_NOTES_3.2.pre1.rdoc +81 -0
- data/release_notes/RELEASE_NOTES_3.2.pre2.rdoc +6 -0
- data/release_notes/RELEASE_NOTES_3.3.0.rdoc +21 -0
- data/spec/schema.rb +9 -0
- data/spec/spec_helper.rb +75 -0
- data/spec/support/active_record.rb +11 -0
- data/spec/support/wice_grid_test_config.rb +175 -0
- data/spec/wice/grid_output_buffer_spec.rb +41 -0
- data/spec/wice/table_column_matrix_spec.rb +38 -0
- data/spec/wice/wice_grid_misc_spec.rb +159 -0
- data/spec/wice/wice_grid_spreadsheet_spec.rb +14 -0
- data/test/readme.txt +1 -0
- data/vendor/assets/javascripts/wice_grid.js +3 -0
- data/vendor/assets/javascripts/wice_grid_init.js.coffee +339 -0
- data/vendor/assets/javascripts/wice_grid_processor.js.coffee +133 -0
- data/vendor/assets/javascripts/wice_grid_saved_queries_init.js.coffee +103 -0
- data/vendor/assets/stylesheets/wice_grid.scss +81 -0
- data/wice_grid.gemspec +36 -0
- metadata +335 -0
@@ -0,0 +1,81 @@
|
|
1
|
+
1. Support for Prototype has been dropped. No hard feelings, Prototype, no matter what
|
2
|
+
others say, I liked you :)
|
3
|
+
|
4
|
+
2. All assets are in the asset pipeline. All javascript is now coffeescript. No more Rails
|
5
|
+
2 legacy in the form of obtrusive javascript in the HTML page. The styles file is copied
|
6
|
+
to the application asset directory by a generate task so that is it easy to modify it to
|
7
|
+
the application needs. The javascript and images are loaded from the plugin. Read the
|
8
|
+
Installation section in README for details. Thanks to the asset pipeline taking care of
|
9
|
+
loading assets for us, methods +include_wice_grid_assets+, +names_of_wice_grid_stylesheets+,
|
10
|
+
and +names_of_wice_grid_javascripts+ have been removed
|
11
|
+
|
12
|
+
3. ERB mode has been removed. It had never been used by anyone and is bad style anyway. In
|
13
|
+
case you have no idea what it was, here's what it was:
|
14
|
+
|
15
|
+
<% grid(@countries_grid, :erb_mode => true) do |g| %>
|
16
|
+
<% g.column :column_name => 'Name', :attribute_name => 'name' do |country| %>
|
17
|
+
<b>Name: <%= link_to(country.name, country_path(country)) %></b>
|
18
|
+
<% end %>
|
19
|
+
<% end -%>
|
20
|
+
|
21
|
+
4. WiceGrid is compatible with Twitter Bootstrap out of the box.
|
22
|
+
|
23
|
+
5. Paths to various images used by WiceGrid have been removed from the configuration file
|
24
|
+
and are now defined only in the css file. Developers are encouraged to modify
|
25
|
+
<tt>wice_grid.scss</tt> to use other images and to change the styles in general.
|
26
|
+
|
27
|
+
6. The markup and css classes that WiceGrid generates have changed, and CSS for older versions
|
28
|
+
of WiceGrid might not work. Inspect the source code.
|
29
|
+
|
30
|
+
7. Parameter names in the grid helper have been renamed:
|
31
|
+
* <tt>:table_html_attrs</tt> becomes <tt>:html</tt>
|
32
|
+
* <tt>:header_tr_html_attrs</tt> becomes <tt>:header_tr_html</tt>
|
33
|
+
|
34
|
+
8. Parameter names in column definitions have been renamed:
|
35
|
+
* <tt>:column_name</tt> becomes <tt>:name</tt>
|
36
|
+
* <tt>:attribute_name</tt> becomes <tt>:attribute</tt>
|
37
|
+
* <tt>:model_class</tt> becomes <tt>:model</tt>
|
38
|
+
* <tt>:allow_ordering</tt> becomes <tt>:ordering</tt>
|
39
|
+
* <tt>:td_html_attrs</tt> becomes <tt>:html</tt>
|
40
|
+
* Negation in the parameter name does not contribute to the simplicity of an API, so
|
41
|
+
<tt>:no_filter</tt> in becomes <tt>:filter</tt>. Consequently, <tt>:no_filter => true</tt>
|
42
|
+
becomes <tt>:filter => false</tt>
|
43
|
+
* <tt>:negation_in_filter</tt> becomes <tt>:negation</tt>
|
44
|
+
|
45
|
+
|
46
|
+
9. New configuration parameter <tt>DEFAULT_TABLE_CLASSES</tt> contains CSS classes added to
|
47
|
+
all WiceGrid tables by default.
|
48
|
+
|
49
|
+
10. In previous versions of WiceGrid in the jQuery mode DateTime filters used to automatically
|
50
|
+
fall back on Rails DateTime helpers due to absence of time controls in jQuery DatePicker.
|
51
|
+
In version 3.2 this behavior has been changed to always use jQuery DatePicker, even with
|
52
|
+
DateTime filters. Of course it is possible to force Rails DateTime with
|
53
|
+
<tt>:helper_style => :standard</tt> in the column definition.
|
54
|
+
|
55
|
+
11. The second variable injected into to <tt>before_row</tt> and <tt>after_row</tt> block,
|
56
|
+
and the first parameter injected into the <tt>last_row</tt> is the number of columns in
|
57
|
+
the current grid.
|
58
|
+
|
59
|
+
12. <tt>:csv_field_separator</tt> is a new parameter for +initialize_grid+ defining the field
|
60
|
+
separator in CSV files. The default separator is defined by +CSV_FIELD_SEPARATOR+ in the
|
61
|
+
config file.
|
62
|
+
|
63
|
+
13. New parameter +:confirm+ for +saved_queries_panel+ which turns on or off the JS confirm
|
64
|
+
dialogs when deleting saved queries.
|
65
|
+
|
66
|
+
14. Instead of the old rake task creating a table for serialized queries a generator has been
|
67
|
+
added which adds a migration file to +db/migrations+.
|
68
|
+
|
69
|
+
15. Instead of using helpers +submit_grid_javascript+ and +reset_grid_javascript+ to create
|
70
|
+
external Submit and Reset buttons all you have to do is add a button or any other
|
71
|
+
clickable HTML element with class +wg-external-submit-button+ or +wg-external-reset-button+,
|
72
|
+
and attribute +data-grid-name+ whose value is the name of the grid:
|
73
|
+
|
74
|
+
<button class="wg-external-submit-button" data-grid-name="grid">Submit</button>
|
75
|
+
<button class="wg-external-reset-button" data-grid-name="grid">Reset</button>
|
76
|
+
|
77
|
+
|
78
|
+
The same goes for the external CSV export button, only the CSS class is
|
79
|
+
+wg-external-csv-export-button+:
|
80
|
+
|
81
|
+
<button class="wg-external-csv-export-button" data-grid-name="grid">Export To CSV</button>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
1. +will_paginate+ is replaced by +kaminari+.
|
2
|
+
2. The detached filter API has changed. No more magical invocation of the +grid+ helper two times.
|
3
|
+
First, +define_grid+ is used in the same way as +grid+, then +grid_filter+,
|
4
|
+
and then <tt>render_grid(@grid)</tt> to actually output the grid table .
|
5
|
+
3. No more polluting core Ruby classes like Hash and Array with methods. All such methods
|
6
|
+
are now private to the plugin.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
the with_paginated_resultset callback receives an ActiveRelation object, not a lambda
|
2
|
+
|
3
|
+
Wice::Defaults::DATEPICKER_YEAR_RANGE added to the config to define the default year range in Datepicker (https://github.com/leikind/wice_grid/issues/61)
|
4
|
+
|
5
|
+
improvement of the javascript calendar control: if the FROM field is set to a value after TO, TO is set to the value of FROM. Vice versa: if the TO field is set to a value before FROM, FROM is set to the value of TO
|
6
|
+
|
7
|
+
New view helpers filter_and_order_state_as_hash(grid) and filter_state_as_hash(grid)
|
8
|
+
|
9
|
+
<caption> supported
|
10
|
+
|
11
|
+
support for Ruby 2.0
|
12
|
+
|
13
|
+
2 errors fixed in the Saved Queries UI ( https://github.com/leikind/wice_grid/issues/89 )
|
14
|
+
|
15
|
+
bug fixed: extra_request_parameters not propagating to the pagination panel
|
16
|
+
|
17
|
+
README: made it clear that Datepicker has to be installed separately
|
18
|
+
|
19
|
+
README: made it clear that css is basis and that Twitter Bootstrap is supported
|
20
|
+
|
21
|
+
|
data/spec/schema.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
3
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
4
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
5
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
6
|
+
# files.
|
7
|
+
#
|
8
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
9
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
10
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
11
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
12
|
+
# a separate helper file that requires the additional dependencies and performs
|
13
|
+
# the additional setup, and require it from the spec files that actually need
|
14
|
+
# it.
|
15
|
+
#
|
16
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
17
|
+
# users commonly want.
|
18
|
+
#
|
19
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
20
|
+
|
21
|
+
require 'rspec'
|
22
|
+
require 'coveralls'
|
23
|
+
require 'codeclimate-test-reporter'
|
24
|
+
require 'simplecov'
|
25
|
+
|
26
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
27
|
+
Coveralls::SimpleCov::Formatter,
|
28
|
+
SimpleCov::Formatter::HTMLFormatter,
|
29
|
+
CodeClimate::TestReporter::Formatter
|
30
|
+
]
|
31
|
+
SimpleCov.start
|
32
|
+
|
33
|
+
begin
|
34
|
+
require 'support/active_record'
|
35
|
+
require 'action_controller'
|
36
|
+
require 'action_view'
|
37
|
+
require 'csv'
|
38
|
+
|
39
|
+
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
40
|
+
rescue LoadError
|
41
|
+
puts 'LoadError'
|
42
|
+
end
|
43
|
+
|
44
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
|
45
|
+
require 'wice_grid'
|
46
|
+
require 'support/wice_grid_test_config'
|
47
|
+
|
48
|
+
ActiveRecord::ConnectionAdapters::Column.send(:include, ::Wice::WiceGridExtentionToActiveRecordColumn)
|
49
|
+
|
50
|
+
::Wice.on_action_view_load
|
51
|
+
|
52
|
+
RSpec.configure do |config|
|
53
|
+
# rspec-expectations config goes here. You can use an alternate
|
54
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
55
|
+
# assertions if you prefer.
|
56
|
+
config.expect_with :rspec do |expectations|
|
57
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
58
|
+
# and `failure_message` of custom matchers include text for helper methods
|
59
|
+
# defined using `chain`, e.g.:
|
60
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
61
|
+
# # => "be bigger than 2 and smaller than 4"
|
62
|
+
# ...rather than:
|
63
|
+
# # => "be bigger than 2"
|
64
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
65
|
+
end
|
66
|
+
|
67
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
68
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
69
|
+
config.mock_with :rspec do |mocks|
|
70
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
71
|
+
# a real object. This is generally recommended, and will default to
|
72
|
+
# `true` in RSpec 4.
|
73
|
+
mocks.verify_partial_doubles = true
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Default number of rows to show per page.
|
4
|
+
Wice::Defaults::PER_PAGE = 20
|
5
|
+
|
6
|
+
# Default order direction
|
7
|
+
Wice::Defaults::ORDER_DIRECTION = 'asc'
|
8
|
+
|
9
|
+
# Default name for a grid. A grid name is the basis for a lot of
|
10
|
+
# names including parameter names, DOM IDs, etc
|
11
|
+
# The shorter the name is the shorter the request URI will be.
|
12
|
+
Wice::Defaults::GRID_NAME = 'grid'
|
13
|
+
|
14
|
+
# 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
|
15
|
+
# for filter related icons (filter icon, reset icon, show/hide icon), otherwise an additional table column is added.
|
16
|
+
Wice::Defaults::REUSE_LAST_COLUMN_FOR_FILTER_ICONS = true
|
17
|
+
|
18
|
+
# The label of the first option of a custom dropdown list meaning 'All items'
|
19
|
+
Wice::Defaults::CUSTOM_FILTER_ALL_LABEL = '--'
|
20
|
+
|
21
|
+
# A list of classes for the table tag of the grid
|
22
|
+
Wice::Defaults::DEFAULT_TABLE_CLASSES = ['table', 'table-bordered', 'table-striped']
|
23
|
+
|
24
|
+
# Allow switching between a single and multiple selection modes in custom filters (dropdown boxes)
|
25
|
+
Wice::Defaults::ALLOW_MULTIPLE_SELECTION = true
|
26
|
+
|
27
|
+
# Show the upper pagination panel by default or not
|
28
|
+
Wice::Defaults::SHOW_UPPER_PAGINATION_PANEL = false
|
29
|
+
|
30
|
+
# Disabling CSV export by default
|
31
|
+
Wice::Defaults::ENABLE_EXPORT_TO_CSV = false
|
32
|
+
|
33
|
+
# Default CSV field separator
|
34
|
+
Wice::Defaults::CSV_FIELD_SEPARATOR = ','
|
35
|
+
|
36
|
+
# Default CSV encoding
|
37
|
+
Wice::Defaults::CSV_ENCODING = nil
|
38
|
+
|
39
|
+
# The strategy when to show the filter.
|
40
|
+
# * <tt>:when_filtered</tt> - when the table is the result of filtering
|
41
|
+
# * <tt>:always</tt> - show the filter always
|
42
|
+
# * <tt>:no</tt> - never show the filter
|
43
|
+
Wice::Defaults::SHOW_FILTER = :always
|
44
|
+
|
45
|
+
# A boolean value specifying if a change in a filter triggers reloading of the grid.
|
46
|
+
Wice::Defaults::AUTO_RELOAD = false
|
47
|
+
|
48
|
+
# SQL operator used for matching strings in string filters.
|
49
|
+
Wice::Defaults::STRING_MATCHING_OPERATOR = 'LIKE'
|
50
|
+
# STRING_MATCHING_OPERATOR = 'ILIKE' # Use this for Postgresql case-insensitive matching.
|
51
|
+
|
52
|
+
# Defining one string matching operator globally for the whole application turns is not enough
|
53
|
+
# when you connect to two databases one of which is MySQL and the other is Postgresql.
|
54
|
+
# If the key for an adapter is missing it will fall back to Wice::Defaults::STRING_MATCHING_OPERATOR
|
55
|
+
Wice::Defaults::STRING_MATCHING_OPERATORS = {
|
56
|
+
'ActiveRecord::ConnectionAdapters::MysqlAdapter' => 'LIKE',
|
57
|
+
'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter' => 'ILIKE'
|
58
|
+
}
|
59
|
+
|
60
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
61
|
+
# Advanced Filters #
|
62
|
+
|
63
|
+
# Switch of the negation checkbox in all text filters
|
64
|
+
Wice::Defaults::NEGATION_IN_STRING_FILTERS = false
|
65
|
+
|
66
|
+
# Each WiceGrid filter column is defined in two classes, one used for rendering the filter, the other
|
67
|
+
# for generating query conditions. All these columns are in lib/wice/columns/*.rb .
|
68
|
+
# File lib/wice/columns/column_processor_index.rb lists all predefined processors.
|
69
|
+
# In most cases a processor is chosen automatically based on the DB column type,
|
70
|
+
# for example, integer columns
|
71
|
+
# can have two of processors, the default one with one input field, and a processor called "range",
|
72
|
+
# with 2 input fields. In this case it is possible to specify a processor in the column definition:
|
73
|
+
#
|
74
|
+
# g.column filter_type: :range
|
75
|
+
#
|
76
|
+
# It is also possible to define you own processors:
|
77
|
+
#
|
78
|
+
# Wice::Defaults::ADDITIONAL_COLUMN_PROCESSORS = {
|
79
|
+
# some_key_identifying_new_column_type: ['AViewColumnProcessorClass', 'ConditionsGeneratorClass'],
|
80
|
+
# another_key_identifying_new_column_type: ['AnotherViewColumnProcessorClass', 'AnotherConditionsGeneratorClass']
|
81
|
+
# }
|
82
|
+
#
|
83
|
+
# Column processor keys/names should not coincide with the existing keys/names (see lib/wice/columns/column_processor_index.rb)
|
84
|
+
# the value is a 2-element array with 2 strings, the first should be a name of view processor class inherited from
|
85
|
+
# Wice::Columns::ViewColumn, the second should be a name of conditions generator class inherited from
|
86
|
+
# Wice::Columns::ConditionsGeneratorColumn .
|
87
|
+
|
88
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
89
|
+
# Showing All Records #
|
90
|
+
|
91
|
+
# Enable or disable showing all records (non-paginated table)
|
92
|
+
Wice::Defaults::ALLOW_SHOWING_ALL_RECORDS = true
|
93
|
+
|
94
|
+
# If number of all queries is more than this value, the user will be given a warning message
|
95
|
+
Wice::Defaults::START_SHOWING_WARNING_FROM = 100
|
96
|
+
|
97
|
+
# Hide the "show all" link if the number of all records is more than...
|
98
|
+
# Force-resets back to pagination starting from this value.
|
99
|
+
# Set to nil to always show it
|
100
|
+
Wice::Defaults::SHOW_ALL_ALLOWED_UP_TO = nil
|
101
|
+
|
102
|
+
#
|
103
|
+
# set to nil to skip the check
|
104
|
+
Wice::Defaults::SWITCH_BACK_TO_PAGINATION_FROM = nil
|
105
|
+
|
106
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
107
|
+
# Saving Queries #
|
108
|
+
|
109
|
+
# ActiveRecord model to store queries. Read the documentation for details
|
110
|
+
# QUERY_STORE_MODEL = 'WiceGridSerializedQuery'
|
111
|
+
Wice::Defaults::QUERY_STORE_MODEL = 'WiceGridSerializedQuery'
|
112
|
+
|
113
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
114
|
+
# Here go settings related to the calendar helpers #
|
115
|
+
|
116
|
+
# The default style of the date and datetime helper
|
117
|
+
# * <tt>:calendar</tt> - JS calendar
|
118
|
+
# * <tt>:html5</tt> - HTML5 date input field
|
119
|
+
# * <tt>:standard</tt> - standard Rails date and datetime helpers
|
120
|
+
# * <tt>:bootstrap</tt> - Bootstrap datepicker helper
|
121
|
+
Wice::Defaults::HELPER_STYLE = :calendar
|
122
|
+
|
123
|
+
# Format of the datetime displayed.
|
124
|
+
# If you change the format, make sure to check if +DATETIME_PARSER+ can still parse this string.
|
125
|
+
Wice::Defaults::DATETIME_FORMAT = '%Y-%m-%d %H:%M'
|
126
|
+
|
127
|
+
# Format of the date displayed.
|
128
|
+
# If you change the format, make sure to check if +DATE_PARSER+ can still parse this string.
|
129
|
+
Wice::Defaults::DATE_FORMAT = '%Y-%m-%d'
|
130
|
+
|
131
|
+
# Format of the date displayed in jQuery's Datepicker
|
132
|
+
# If you change the format, make sure to check if +DATE_PARSER+ can still parse this string.
|
133
|
+
Wice::Defaults::DATE_FORMAT_JQUERY = 'yy-mm-dd'
|
134
|
+
|
135
|
+
# Format of the date displayed in Bootstrap's Datepicker
|
136
|
+
# If you change the format, make sure to check if +DATE_PARSER+ can still parse this string.
|
137
|
+
Wice::Defaults::DATE_FORMAT_BOOTSTRAP = 'yyyy-mm-dd'
|
138
|
+
|
139
|
+
# With Calendar helpers enabled the parameter sent is the string displayed. This lambda will be given a date string in the
|
140
|
+
# format defined by +DATETIME_FORMAT+ and must generate a DateTime object.
|
141
|
+
# In many cases <tt>Time.zone.parse</tt> is enough, for instance, <tt>%Y-%m-%d</tt>. If you change the format, make sure to check this code
|
142
|
+
# and modify it if needed.
|
143
|
+
Wice::Defaults::DATETIME_PARSER = lambda do |datetime_string|
|
144
|
+
if datetime_string.blank?
|
145
|
+
nil
|
146
|
+
elsif Time.zone
|
147
|
+
Time.zone.parse(datetime_string)
|
148
|
+
else
|
149
|
+
Time.parse(datetime_string)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
# The range of years to display in jQuery Datepicker.
|
154
|
+
# It can always be changed dynamically with the following javascript:
|
155
|
+
# $( ".hasDatepicker" ).datepicker( "option", "yearRange", "2000:2042" );
|
156
|
+
Wice::Defaults::DATEPICKER_YEAR_RANGE = (from = Date.current.year - 10).to_s + ':' + (from + 15).to_s
|
157
|
+
|
158
|
+
# With Calendar helpers enabled the parameter sent is the string displayed. This lambda will be given a date string in the
|
159
|
+
# format defined by +DATETIME+ and must generate a Date object.
|
160
|
+
# In many cases <tt>Date.parse</tt> is enough, for instance, <tt>%Y-%m-%d</tt>. If you change the format, make sure to check this code
|
161
|
+
# and modify it if needed.
|
162
|
+
Wice::Defaults::DATE_PARSER = lambda do |date_string|
|
163
|
+
if date_string.blank?
|
164
|
+
nil
|
165
|
+
else
|
166
|
+
begin
|
167
|
+
Date.parse(date_string)
|
168
|
+
rescue ArgumentError
|
169
|
+
nil
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
# The name of the page method (should correspond to Kaminari.config.page_method_name)
|
175
|
+
Wice::Defaults::PAGE_METHOD_NAME = :page
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
describe Wice::GridOutputBuffer do
|
4
|
+
FILTER_COMMON_CODE = 'here filter code'
|
5
|
+
|
6
|
+
|
7
|
+
let(:buffer){Wice::GridOutputBuffer.new}
|
8
|
+
|
9
|
+
it 'should to_s' do
|
10
|
+
expect(buffer.to_s.class).to eq(ActiveSupport::SafeBuffer)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should add_filter' do
|
14
|
+
|
15
|
+
expect(buffer.add_filter('key', FILTER_COMMON_CODE)).to eq(FILTER_COMMON_CODE)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should filter_for' do
|
19
|
+
|
20
|
+
buffer.add_filter('key', FILTER_COMMON_CODE)
|
21
|
+
expect(buffer.filter_for('key')).to eq(FILTER_COMMON_CODE)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should filter_for 2 times' do
|
25
|
+
buffer.add_filter('key', FILTER_COMMON_CODE)
|
26
|
+
|
27
|
+
expect(buffer.filter_for('key')).to eq(FILTER_COMMON_CODE)
|
28
|
+
expect { buffer.filter_for('key') }.to raise_error
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should filter_for without filters' do
|
32
|
+
|
33
|
+
expect { buffer.filter_for('key') }.to raise_error
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should filter_for return empty string' do
|
37
|
+
buffer.return_empty_strings_for_nonexistent_filters = true
|
38
|
+
|
39
|
+
expect(buffer.filter_for('key')).to eq('')
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
describe Wice::TableColumnMatrix do
|
4
|
+
let(:general_conditions){ 'conditions' }
|
5
|
+
|
6
|
+
let(:table){ Wice::TableColumnMatrix.new }
|
7
|
+
|
8
|
+
it 'should new' do
|
9
|
+
expect(table.class).to eq(Wice::TableColumnMatrix)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should add_condition' do
|
13
|
+
|
14
|
+
table.add_condition('key', general_conditions)
|
15
|
+
|
16
|
+
expect(table.conditions).to include(general_conditions)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should set default_model_class' do
|
20
|
+
|
21
|
+
table.default_model_class = Dummy
|
22
|
+
|
23
|
+
expect(table.class).to eq(Wice::TableColumnMatrix)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should get column' do
|
27
|
+
|
28
|
+
table.default_model_class = Dummy
|
29
|
+
|
30
|
+
expect(Dummy.columns).to include(table.get_column_by_model_class_and_column_name(Dummy, :name))
|
31
|
+
expect(Dummy.columns).to include(table.get_column_in_default_model_class_by_column_name(:name))
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should get column not initialized' do
|
35
|
+
|
36
|
+
expect { table.get_column_in_default_model_class_by_column_name(:name) }.to raise_error
|
37
|
+
end
|
38
|
+
end
|