wice_grid 3.5.0 → 3.6.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.inch.yml +3 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +181 -0
  5. data/.travis.yml +22 -0
  6. data/{CHANGELOG → CHANGELOG.md} +95 -31
  7. data/Gemfile +4 -1
  8. data/README.md +1517 -0
  9. data/Rakefile +51 -7
  10. data/{SAVED_QUERIES_HOWTO.rdoc → SAVED_QUERIES_HOWTO.md} +34 -31
  11. data/TODO.md +16 -0
  12. data/lib/generators/wice_grid/add_migration_for_serialized_queries_generator.rb +4 -6
  13. data/lib/generators/wice_grid/install_generator.rb +2 -5
  14. data/lib/generators/wice_grid/templates/create_wice_grid_serialized_queries.rb +1 -0
  15. data/lib/generators/wice_grid/templates/wice_grid_config.rb +29 -34
  16. data/lib/wice/active_record_column_wrapper.rb +36 -17
  17. data/lib/wice/columns.rb +53 -52
  18. data/lib/wice/columns/column_action.rb +11 -13
  19. data/lib/wice/columns/column_boolean.rb +9 -11
  20. data/lib/wice/columns/column_bootstrap_datepicker.rb +48 -0
  21. data/lib/wice/columns/column_custom_dropdown.rb +22 -23
  22. data/lib/wice/columns/column_float.rb +2 -6
  23. data/lib/wice/columns/column_html5_datepicker.rb +31 -0
  24. data/lib/wice/columns/column_integer.rb +9 -13
  25. data/lib/wice/columns/column_jquery_datepicker.rb +49 -0
  26. data/lib/wice/columns/column_processor_index.rb +18 -13
  27. data/lib/wice/columns/column_rails_date_helper.rb +41 -0
  28. data/lib/wice/columns/column_rails_datetime_helper.rb +40 -0
  29. data/lib/wice/columns/column_range.rb +7 -11
  30. data/lib/wice/columns/column_string.rb +24 -20
  31. data/lib/wice/columns/common_date_datetime_mixin.rb +20 -0
  32. data/lib/wice/columns/common_js_date_datetime_conditions_generator_mixin.rb +39 -0
  33. data/lib/wice/columns/common_js_date_datetime_mixin.rb +15 -0
  34. data/lib/wice/columns/{column_date.rb → common_rails_date_datetime_conditions_generator_mixin.rb} +4 -22
  35. data/lib/wice/columns/common_standard_helper_date_datetime_mixin.rb +22 -0
  36. data/lib/wice/grid_output_buffer.rb +19 -10
  37. data/lib/wice/grid_renderer.rb +146 -85
  38. data/lib/wice/helpers/bs_calendar_helpers.rb +6 -7
  39. data/lib/wice/helpers/js_calendar_helpers.rb +19 -17
  40. data/lib/wice/helpers/wice_grid_misc_view_helpers.rb +18 -18
  41. data/lib/wice/helpers/wice_grid_serialized_queries_view_helpers.rb +44 -49
  42. data/lib/wice/helpers/wice_grid_view_helpers.rb +131 -134
  43. data/lib/wice/kaminari_monkey_patching.rb +3 -1
  44. data/lib/wice/table_column_matrix.rb +23 -8
  45. data/lib/wice/wice_grid_controller.rb +12 -16
  46. data/lib/wice/wice_grid_core_ext.rb +12 -20
  47. data/lib/wice/wice_grid_misc.rb +131 -53
  48. data/lib/wice/wice_grid_serialized_queries_controller.rb +10 -11
  49. data/lib/wice/wice_grid_serialized_query.rb +4 -3
  50. data/lib/wice/wice_grid_spreadsheet.rb +19 -18
  51. data/lib/wice_grid.rb +144 -135
  52. data/spec/schema.rb +9 -0
  53. data/spec/spec_helper.rb +75 -0
  54. data/spec/support/active_record.rb +11 -0
  55. data/spec/support/wice_grid_test_config.rb +172 -0
  56. data/spec/wice/grid_output_buffer_spec.rb +41 -0
  57. data/spec/wice/table_column_matrix_spec.rb +38 -0
  58. data/spec/wice/wice_grid_misc_spec.rb +159 -0
  59. data/spec/wice/wice_grid_spreadsheet_spec.rb +14 -0
  60. data/test/readme.txt +1 -1
  61. data/vendor/assets/javascripts/wice_grid_init.js.coffee +14 -8
  62. data/vendor/assets/stylesheets/wice_grid.scss +84 -0
  63. data/wice_grid.gemspec +32 -16
  64. metadata +217 -25
  65. data/README.rdoc +0 -1325
  66. data/lib/generators/wice_grid/templates/wice_grid.scss +0 -140
  67. data/lib/wice/columns/column_datetime.rb +0 -171
  68. data/vendor/assets/images/icons/grid/arrow_down.gif +0 -0
  69. data/vendor/assets/images/icons/grid/arrow_up.gif +0 -0
  70. data/vendor/assets/images/icons/grid/calendar_view_month.png +0 -0
  71. data/vendor/assets/images/icons/grid/collapse.gif +0 -0
  72. data/vendor/assets/images/icons/grid/delete.png +0 -0
  73. data/vendor/assets/images/icons/grid/expand.gif +0 -0
  74. data/vendor/assets/images/icons/grid/page_white_excel.png +0 -0
  75. data/vendor/assets/images/icons/grid/page_white_find.png +0 -0
  76. data/vendor/assets/images/icons/grid/table.png +0 -0
  77. data/vendor/assets/images/icons/grid/table_refresh.png +0 -0
  78. data/vendor/assets/images/icons/grid/tick_all.png +0 -0
  79. data/vendor/assets/images/icons/grid/untick_all.png +0 -0
@@ -1,7 +1,11 @@
1
+ # encoding: utf-8
1
2
  module Wice #:nodoc:
2
3
  module BsCalendarHelpers #:nodoc:
3
4
 
4
- class CalendarData
5
+ # A struct containing all data for rendering a calendar
6
+ class CalendarData #:nodoc:
7
+
8
+ # :nodoc:
5
9
  attr_accessor :name,
6
10
  :date_string,
7
11
  :dom_id,
@@ -14,16 +18,14 @@ module Wice #:nodoc:
14
18
  end
15
19
 
16
20
  def date_calendar_bs(calendar_data) #:nodoc:
17
-
18
21
  text_field_tag_options = {
19
22
  :id => calendar_data.dom_id,
20
23
  'data-provide' => 'datepicker',
21
24
  'data-date-language' => I18n.locale,
22
25
  'data-date-autoclose' => true,
23
- 'data-date-format' => Wice::ConfigurationProvider.value_for(:DATE_FORMAT_BOOTSTRAP),
26
+ 'data-date-format' => Wice::ConfigurationProvider.value_for(:DATE_FORMAT_BOOTSTRAP)
24
27
  }
25
28
 
26
-
27
29
  text_field_tag_options['class'] = 'form-control input-sm'
28
30
 
29
31
  if Rails.env.development?
@@ -48,11 +50,9 @@ module Wice #:nodoc:
48
50
  end
49
51
 
50
52
  def prepare_data_for_bscalendar(options) #:nodoc:
51
-
52
53
  date_format = Wice::ConfigurationProvider.value_for(:DATE_FORMAT)
53
54
 
54
55
  CalendarData.new.tap do |calendar_data|
55
-
56
56
  calendar_data.name = options[:name]
57
57
  calendar_data.date_string = options[:initial_date].nil? ? '' : options[:initial_date].strftime(date_format)
58
58
  calendar_data.dom_id = options[:name].gsub(/([\[\(])|(\]\[)/, '_').gsub(/[\]\)]/, '').gsub(/\./, '_').gsub(/_+/, '_')
@@ -62,6 +62,5 @@ module Wice #:nodoc:
62
62
  calendar_data.fire_event = options[:fire_event]
63
63
  end
64
64
  end
65
-
66
65
  end
67
66
  end
@@ -1,7 +1,11 @@
1
+ # encoding: utf-8
1
2
  module Wice #:nodoc:
2
3
  module JsCalendarHelpers #:nodoc:
3
4
 
5
+ # A struct containing all data for rendering a calendar
4
6
  class CalendarData
7
+
8
+ # :nodoc:
5
9
  attr_accessor :name,
6
10
  :date_string,
7
11
  :dom_id,
@@ -15,12 +19,10 @@ module Wice #:nodoc:
15
19
  end
16
20
 
17
21
  def date_calendar_jquery(calendar_data) #:nodoc:
18
-
19
22
  hidden_field_tag_options = {
20
23
  :id => calendar_data.dom_id,
21
24
  'data-locale' => I18n.locale,
22
25
  'data-date-format' => Wice::ConfigurationProvider.value_for(:DATE_FORMAT_JQUERY),
23
- 'data-button-image' => Wice::ConfigurationProvider.value_for(:CALENDAR_ICON),
24
26
  'data-button-text' => calendar_data.title
25
27
  }
26
28
 
@@ -40,31 +42,33 @@ module Wice #:nodoc:
40
42
  hidden_field_tag_options['data-the-other-datepicker-id-from'] = calendar_data.the_other_datepicker_id_from
41
43
  end
42
44
 
43
-
44
45
  if year_range = ConfigurationProvider.value_for(:DATEPICKER_YEAR_RANGE)
45
46
  hidden_field_tag_options['data-date-year-range'] = year_range
46
47
  end
47
48
 
48
-
49
49
  date_picker = hidden_field_tag(calendar_data.name, calendar_data.date_string, hidden_field_tag_options) + ' ' +
50
50
 
51
- link_to(calendar_data.date_string,
52
- '#',
53
- :id => calendar_data.date_span_id,
54
- :class => 'date-label',
55
- :title => ::Wice::NlMessage['date_string_tooltip'],
56
- 'data-dom-id' => calendar_data.dom_id
57
- )
58
-
59
- "<span id=\"#{calendar_data.datepicker_placeholder_id}\">#{date_picker}</span>"
51
+ link_to(
52
+ calendar_data.date_string,
53
+ '#',
54
+ :id => calendar_data.date_span_id,
55
+ :class => 'date-label',
56
+ :title => ::Wice::NlMessage['date_string_tooltip'],
57
+ 'data-dom-id' => calendar_data.dom_id
58
+ )
59
+
60
+ content_tag(
61
+ :span,
62
+ date_picker,
63
+ id: calendar_data.datepicker_placeholder_id,
64
+ class: 'jq-datepicker-container'
65
+ )
60
66
  end
61
67
 
62
68
  def prepare_data_for_calendar(options) #:nodoc:
63
-
64
69
  date_format = Wice::ConfigurationProvider.value_for(:DATE_FORMAT)
65
70
 
66
71
  CalendarData.new.tap do |calendar_data|
67
-
68
72
  calendar_data.name = options[:name]
69
73
  calendar_data.date_string = options[:initial_date].nil? ? '' : options[:initial_date].strftime(date_format)
70
74
  calendar_data.dom_id = options[:name].gsub(/([\[\(])|(\]\[)/, '_').gsub(/[\]\)]/, '').gsub(/\./, '_').gsub(/_+/, '_')
@@ -73,9 +77,7 @@ module Wice #:nodoc:
73
77
  calendar_data.close_calendar_event_name = "wg:calendarChanged_#{options[:grid_name]}"
74
78
  calendar_data.title = options[:title]
75
79
  calendar_data.fire_event = options[:fire_event]
76
-
77
80
  end
78
81
  end
79
-
80
82
  end
81
83
  end
@@ -1,19 +1,20 @@
1
+ # encoding: utf-8
1
2
  module Wice
2
- module GridViewHelper
3
-
4
3
 
4
+ # Various grid related helpers
5
+ module GridViewHelper
5
6
  # This method dumps all HTTP parameters related to filtering and ordering of a certain grid as hidden form fields.
6
7
  # This might be required if you want to keep the state of a grid while reloading the page using other forms.
7
8
  #
8
9
  # The only parameter is a grid object returned by +initialize_grid+ in the controller.
9
10
  def dump_filter_parameters_as_hidden_fields(grid)
10
- unless grid.kind_of? WiceGrid
11
- raise WiceGridArgumentError.new("dump_filter_parameters_as_hidden_fields: the parameter must be a WiceGrid instance.")
11
+ unless grid.is_a? WiceGrid
12
+ fail WiceGridArgumentError.new('dump_filter_parameters_as_hidden_fields: the parameter must be a WiceGrid instance.')
12
13
  end
13
14
 
14
- grid.get_state_as_parameter_value_pairs(true).collect{|param_name, value|
15
- hidden_field_tag(param_name, value, :id => "hidden-#{param_name.gsub(/[\[\]]/, '-')}")
16
- }.join("\n").html_safe
15
+ grid.get_state_as_parameter_value_pairs(true).collect do|param_name, value|
16
+ hidden_field_tag(param_name, value, id: "hidden-#{param_name.gsub(/[\[\]]/, '-')}")
17
+ end.join("\n").html_safe
17
18
  end
18
19
 
19
20
  # This method dumps all HTTP parameters related to filtering of a certain grid in the form of a hash.
@@ -23,7 +24,7 @@ module Wice
23
24
  #
24
25
  # The only parameter is a grid object returned by +initialize_grid+ in the controller.
25
26
  def filter_state_as_hash(grid)
26
- {grid.name => {'f' => grid.status[:f]}}
27
+ { grid.name => { 'f' => grid.status[:f] } }
27
28
  end
28
29
 
29
30
  # This method dumps all HTTP parameters related to filtering and ordering of a certain grid in the form of a hash.
@@ -40,36 +41,35 @@ module Wice
40
41
  }
41
42
  end
42
43
 
44
+ # display the state of the grid
43
45
  def dump_state(grid) #:nodoc:
44
- debug(grid.get_state_as_parameter_value_pairs())
46
+ debug(grid.get_state_as_parameter_value_pairs)
45
47
  end
46
48
 
47
-
48
49
  # secret but stupid weapon - takes an ActiveRecord and using reflection tries to build all the column clauses by itself.
49
50
  # WiceGrid is not a scaffolding solution, I hate scaffolding and how certain idiots associate scaffolding with Rails,
50
51
  # so I do not document this method to avoid contributing to this misunderstanding.
51
52
  def scaffolded_grid(grid_obj, opts = {}) #:nodoc:
52
- unless grid_obj.kind_of? WiceGrid
53
- raise WiceGridArgumentError.new("scaffolded_grid: the parameter must be a WiceGrid instance.")
53
+ unless grid_obj.is_a? WiceGrid
54
+ fail WiceGridArgumentError.new('scaffolded_grid: the parameter must be a WiceGrid instance.')
54
55
  end
55
56
 
56
57
  # debug grid.klass.column_names
57
58
  columns = grid_obj.klass.column_names
58
59
  if opts[:reject_attributes].is_a? Proc
59
- columns = columns.reject{|c| opts[:reject_attributes].call(c)}
60
+ columns = columns.reject { |c| opts[:reject_attributes].call(c) }
60
61
  opts.delete(:reject_attributes)
61
- elsif
62
- columns = columns.reject{|c| c =~ opts[:reject_attributes]}
62
+ else
63
+ columns = columns.reject { |c| c =~ opts[:reject_attributes] }
63
64
  opts.delete(:reject_attributes)
64
65
  end
65
66
  grid(grid_obj, opts) do |g|
66
67
  columns.each do |column_name|
67
- g.column :name => column_name.humanize, :attribute => column_name do |ar|
68
+ g.column name: column_name.humanize, attribute: column_name do |ar|
68
69
  ar.send(column_name)
69
70
  end
70
71
  end
71
72
  end
72
73
  end
73
-
74
74
  end
75
- end
75
+ end
@@ -1,17 +1,17 @@
1
+ # encoding: utf-8
1
2
  module Wice
2
3
  module GridViewHelper
3
-
4
4
  # View helper to render the list of saved queries and the form to create a new query.
5
5
  # Parameters:
6
6
  # * <tt>:extra_parameters</tt> - a hash of additional parameters to use when creating a new query object.
7
7
  # * <tt>:confirm</tt> - A boolean value which turns on or off the JS confirm dialogs when deleting saved queries.
8
8
  # Read section "Adding Application Specific Logic to Saving/Restoring Queries" in README for more details.
9
9
  def saved_queries_panel(grid, opts = {})
10
- unless grid.kind_of? WiceGrid
11
- raise WiceGridArgumentError.new("saved_queries_panel: the parameter must be a WiceGrid instance.")
10
+ unless grid.is_a? WiceGrid
11
+ fail WiceGridArgumentError.new('saved_queries_panel: the parameter must be a WiceGrid instance.')
12
12
  end
13
13
 
14
- options = {extra_parameters: {}, confirm: 1}
14
+ options = { extra_parameters: {}, confirm: 1 }
15
15
  opts.assert_valid_keys(options.keys)
16
16
  options.merge!(opts)
17
17
 
@@ -22,13 +22,13 @@ module Wice
22
22
  parameters = grid.get_state_as_parameter_value_pairs
23
23
 
24
24
  options[:extra_parameters].each do |k, v|
25
- parameters << [ CGI.unescape({extra: {k => ''}}.to_query.sub(/=$/,'')) , v.to_s ]
25
+ parameters << [CGI.unescape({ extra: { k => '' } }.to_query.sub(/=$/, '')), v.to_s]
26
26
  end
27
- parameters << ['authenticity_token', form_authenticity_token]
27
+ parameters << ['authenticity_token', form_authenticity_token]
28
28
  notification_messages_id = "#{grid_name}_notification_messages"
29
- (%! <div class="wice-grid-query-panel well"><h3>#{NlMessage['saved_query_panel_title']}</h3>! +
29
+ (%( <div class="wice-grid-query-panel well"><h3>#{NlMessage['saved_query_panel_title']}</h3>) +
30
30
  saved_queries_list(grid_name, grid.saved_query, options[:extra_parameters], options[:confirm]) +
31
- %!<div id="#{notification_messages_id}" ></div>! +
31
+ %(<div id="#{notification_messages_id}" ></div>) +
32
32
  if block_given?
33
33
  view, ids = yield
34
34
  view
@@ -36,9 +36,7 @@ module Wice
36
36
  ''
37
37
  end +
38
38
 
39
- '<div class="form-horizontal"><div class="wg-saved-query-input-controls input-append">'+
40
-
41
- text_field_tag(input_field_name, '', onkeydown: '', class: 'wice-grid-save-query-field form-control ') +
39
+ '<div class="form-horizontal"><div class="wg-saved-query-input-controls input-append">' + text_field_tag(input_field_name, '', onkeydown: '', class: 'wice-grid-save-query-field form-control ') +
42
40
  button_tag(
43
41
  NlMessage['save_query_button_label'],
44
42
  class: 'wice-grid-save-query-button btn btn-primary',
@@ -52,49 +50,46 @@ module Wice
52
50
  end
53
51
 
54
52
  def saved_queries_list(grid_name, saved_query = nil, extra_parameters = {}, confirm = 1) #:nodoc:
55
-
56
53
  link_title = NlMessage['saved_query_link_title']
57
54
  deletion_confirmation = confirm ? NlMessage['saved_query_deletion_confirmation'] : nil
58
55
  deletion_link_title = NlMessage['saved_query_deletion_link_title']
59
56
 
60
- query_store_model = ::Wice::get_query_store_model
57
+ query_store_model = ::Wice.get_query_store_model
61
58
  currently_loaded_query_id = saved_query ? saved_query.id : nil
62
- with = extra_parameters.nil? ? nil : "'" + {extra: extra_parameters}.to_query + "'"
59
+ # with = extra_parameters.nil? ? nil : "'" + {extra: extra_parameters}.to_query + "'"
63
60
 
64
- %!<ul id="#{grid_name}_query_list" class="query-list"> ! +
65
- query_store_model.list(grid_name, controller).collect do |sq|
66
- link_opts = {
67
- class: 'wice-grid-query-load-link',
68
- title: "#{link_title} #{sq.name}",
69
- 'data-query-id' => sq.id,
70
- 'data-grid-name' => grid_name
71
- }
72
- link_opts[:class] += ' current' if saved_query == sq
73
- "<li>"+
74
- link_to(
75
- content_tag(:div, '', :class => 'delete-icon'),
76
- delete_serialized_query_path(
77
- grid_name: grid_name,
78
- id: sq.id,
79
- current: currently_loaded_query_id,
80
- extra: extra_parameters,
81
- confirm: confirm
82
- ),
83
- class: 'wice-grid-delete-query',
84
- 'data-wg-confirm' => deletion_confirmation,
85
- 'data-grid-name' => grid_name,
86
- title: "#{deletion_link_title} #{sq.name}"
87
- ) + ' &nbsp; ' +
88
- link_to(h(sq.name), '#', link_opts) +
89
- if sq.respond_to? :description
90
- desc = sq.description
91
- desc.blank? ? '' : " <i>#{desc}</i>"
92
- else
93
- ''
94
- end +
95
- '</li>'
96
- end.join('') + '</ul>'
61
+ %(<ul id="#{grid_name}_query_list" class="query-list"> ) +
62
+ query_store_model.list(grid_name, controller).collect do |sq|
63
+ link_opts = {
64
+ class: 'wice-grid-query-load-link',
65
+ title: "#{link_title} #{sq.name}",
66
+ 'data-query-id' => sq.id,
67
+ 'data-grid-name' => grid_name
68
+ }
69
+ link_opts[:class] += ' current' if saved_query == sq
70
+ '<li>' + link_to(
71
+ content_tag(:i, '', class: 'fa fa-trash-o delete-icon'),
72
+ delete_serialized_query_path(
73
+ grid_name: grid_name,
74
+ id: sq.id,
75
+ current: currently_loaded_query_id,
76
+ extra: extra_parameters,
77
+ confirm: confirm
78
+ ),
79
+ class: 'wice-grid-delete-query',
80
+ 'data-wg-confirm' => deletion_confirmation,
81
+ 'data-grid-name' => grid_name,
82
+ title: "#{deletion_link_title} #{sq.name}"
83
+ ) + ' &nbsp; ' +
84
+ link_to(h(sq.name), '#', link_opts) +
85
+ if sq.respond_to? :description
86
+ desc = sq.description
87
+ desc.blank? ? '' : " <i>#{desc}</i>"
88
+ else
89
+ ''
90
+ end +
91
+ '</li>'
92
+ end.join('') + '</ul>'
97
93
  end
98
-
99
94
  end
100
- end
95
+ end
@@ -1,6 +1,6 @@
1
+ # encoding: utf-8
1
2
  module Wice
2
3
  module GridViewHelper
3
-
4
4
  # View helper for rendering the grid.
5
5
  #
6
6
  # The first parameter is a grid object returned by +initialize_grid+ in the controller.
@@ -69,9 +69,9 @@ module Wice
69
69
  # Pease read documentation about the +column+ method to achieve the enlightenment.
70
70
 
71
71
  def grid(grid, opts = {}, &block)
72
- raise WiceGridArgumentError.new('Missing block for the grid helper.' +
73
- ' For detached filters use first define_grid with the same API as grid, ' +
74
- 'then grid_filter to add filters, and then render_grid to actually show the grid' ) if block.nil?
72
+ fail WiceGridArgumentError.new('Missing block for the grid helper.' \
73
+ ' For detached filters use first define_grid with the same API as grid, ' \
74
+ 'then grid_filter to add filters, and then render_grid to actually show the grid') if block.nil?
75
75
  define_grid(grid, opts, &block)
76
76
  render_grid(grid)
77
77
  end
@@ -83,7 +83,7 @@ module Wice
83
83
  def define_grid(grid, opts = {}, &block)
84
84
  # strip the method from HTML stuff
85
85
  unless grid.class == WiceGrid
86
- raise WiceGridArgumentError.new("The first argument for the grid helper must be an instance of the WiceGrid class")
86
+ fail WiceGridArgumentError.new('The first argument for the grid helper must be an instance of the WiceGrid class')
87
87
  end
88
88
 
89
89
  options = {
@@ -107,7 +107,6 @@ module Wice
107
107
  options[:show_filters] = :no if options[:show_filters] == false
108
108
  options[:show_filters] = :always if options[:show_filters] == true
109
109
 
110
-
111
110
  rendering = GridRenderer.new(grid, self)
112
111
 
113
112
  block.call(rendering) # calling block containing column() calls
@@ -119,7 +118,7 @@ module Wice
119
118
  grid_csv(grid, rendering)
120
119
  else
121
120
  # If blank_slate is defined we don't show any grid at all
122
- if rendering.blank_slate_handler && grid.resultset.size == 0 && ! grid.filtering_on?
121
+ if rendering.blank_slate_handler && grid.resultset.size == 0 && !grid.filtering_on?
123
122
  generate_blank_slate(grid, rendering)
124
123
  else
125
124
  grid_html(grid, options, rendering, reuse_last_column_for_filter_buttons)
@@ -140,15 +139,14 @@ module Wice
140
139
  elsif grid.csv_tempfile
141
140
  grid.csv_tempfile.path
142
141
  else
143
- raise WiceGridException.new("Attempt to use 'render_grid' without 'define_grid' before.")
142
+ fail WiceGridException.new("Attempt to use 'render_grid' without 'define_grid' before.")
144
143
  end
145
144
  end
146
145
 
147
-
148
146
  def generate_blank_slate(grid, rendering) #:nodoc:
149
147
  grid.output_buffer = GridOutputBuffer.new
150
148
 
151
- grid.output_buffer << if rendering.blank_slate_handler.is_a?(Proc)
149
+ grid.output_buffer << if rendering.blank_slate_handler.is_a?(Proc)
152
150
  call_block(rendering.blank_slate_handler, nil)
153
151
  elsif rendering.blank_slate_handler.is_a?(Hash)
154
152
  render(rendering.blank_slate_handler)
@@ -156,7 +154,7 @@ module Wice
156
154
  rendering.blank_slate_handler
157
155
  end
158
156
 
159
- if rendering.find_one_for(:in_html){|column| column.detach_with_id}
157
+ if rendering.find_one_for(:in_html) { |column| column.detach_with_id }
160
158
  grid.output_buffer.return_empty_strings_for_nonexistent_filters = true
161
159
  end
162
160
  end
@@ -165,7 +163,7 @@ module Wice
165
163
  extra_argument ? block.call(ar, extra_argument) : block.call(ar)
166
164
  end
167
165
 
168
- def get_row_content(rendering, ar, sorting_dependant_row_cycling)
166
+ def get_row_content(rendering, ar, sorting_dependant_row_cycling) #:nodoc:
169
167
  cell_value_of_the_ordered_column = nil
170
168
  row_content = ''
171
169
  rendering.each_column(:in_html) do |column|
@@ -181,25 +179,25 @@ module Wice
181
179
  call_block(cell_block, ar)
182
180
  end
183
181
 
184
- if column_block_output.kind_of?(Array)
182
+ if column_block_output.is_a?(Array)
185
183
 
186
184
  unless column_block_output.size == 2
187
- raise WiceGridArgumentError.new('When WiceGrid column block returns an array it is expected to contain 2 elements only - '+
188
- 'the first is the contents of the table cell and the second is a hash containing HTML attributes for the <td> tag.')
185
+ fail WiceGridArgumentError.new('When WiceGrid column block returns an array it is expected to contain 2 elements only - ' \
186
+ 'the first is the contents of the table cell and the second is a hash containing HTML attributes for the <td> tag.')
189
187
  end
190
188
 
191
189
  column_block_output, additional_opts = column_block_output
192
190
 
193
191
  unless additional_opts.is_a?(Hash)
194
- raise WiceGridArgumentError.new('When WiceGrid column block returns an array its second element is expected to be a ' +
192
+ fail WiceGridArgumentError.new('When WiceGrid column block returns an array its second element is expected to be a ' \
195
193
  "hash containing HTML attributes for the <td> tag. The returned value is #{additional_opts.inspect}. Read documentation.")
196
194
  end
197
195
 
198
196
  additional_css_class = nil
199
- if additional_opts.has_key?(:class)
197
+ if additional_opts.key?(:class)
200
198
  additional_css_class = additional_opts[:class]
201
199
  additional_opts.delete(:class)
202
- elsif additional_opts.has_key?('class')
200
+ elsif additional_opts.key?('class')
203
201
  additional_css_class = additional_opts['class']
204
202
  additional_opts.delete('class')
205
203
  end
@@ -217,7 +215,6 @@ module Wice
217
215
 
218
216
  # the longest method? :(
219
217
  def grid_html(grid, options, rendering, reuse_last_column_for_filter_buttons) #:nodoc:
220
-
221
218
  table_html_attrs, header_tr_html = options[:html], options[:header_tr_html]
222
219
 
223
220
  Wice::WgHash.add_or_append_class_value!(table_html_attrs, 'wice-grid', true)
@@ -241,18 +238,18 @@ module Wice
241
238
  # Ruby 1.9.x
242
239
  grid.output_buffer.force_encoding('UTF-8') if grid.output_buffer.respond_to?(:force_encoding)
243
240
 
244
- grid.output_buffer << %!<div class="wice-grid-container table-responsive" data-grid-name="#{grid.name}" id="#{grid.name}"><div id="#{grid.name}_title">!
241
+ grid.output_buffer << %(<div class="wice-grid-container table-responsive" data-grid-name="#{grid.name}" id="#{grid.name}"><div id="#{grid.name}_title">)
245
242
  grid.output_buffer << content_tag(:h3, grid.saved_query.name) if grid.saved_query
246
- grid.output_buffer << "</div><table #{tag_options(table_html_attrs, true)}>"
243
+ grid.output_buffer << "</div><table #{public_tag_options(table_html_attrs, true)}>"
247
244
  grid.output_buffer << "<caption>#{rendering.kaption}</caption>" if rendering.kaption
248
- grid.output_buffer << "<thead>"
245
+ grid.output_buffer << '<thead>'
249
246
 
250
247
  no_filters_at_all = (options[:show_filters] == :no || rendering.no_filter_needed?)
251
248
 
252
249
  if no_filters_at_all
253
250
  no_rightmost_column = no_filter_row = no_filters_at_all
254
251
  else
255
- no_rightmost_column = no_filter_row = (options[:show_filters] == :no || rendering.no_filter_needed_in_main_table?) ? true: false
252
+ no_rightmost_column = no_filter_row = (options[:show_filters] == :no || rendering.no_filter_needed_in_main_table?) ? true : false
256
253
  end
257
254
 
258
255
  no_rightmost_column = true if reuse_last_column_for_filter_buttons
@@ -262,7 +259,7 @@ module Wice
262
259
 
263
260
  number_of_columns_for_extra_rows = number_of_columns + 1
264
261
 
265
- pagination_panel_content_html, pagination_panel_content_js = nil, nil
262
+ pagination_panel_content_html = nil
266
263
  if options[:upper_pagination_panel]
267
264
  grid.output_buffer << rendering.pagination_panel(number_of_columns, options[:hide_csv_button]) do
268
265
  pagination_panel_content_html =
@@ -274,7 +271,7 @@ module Wice
274
271
  title_row_attrs = header_tr_html.clone
275
272
  Wice::WgHash.add_or_append_class_value!(title_row_attrs, 'wice-grid-title-row', true)
276
273
 
277
- grid.output_buffer << %!<tr #{tag_options(title_row_attrs, true)}>!
274
+ grid.output_buffer << %(<tr #{public_tag_options(title_row_attrs, true)}>)
278
275
 
279
276
  filter_row_id = grid.name + '_filter_row'
280
277
 
@@ -287,7 +284,6 @@ module Wice
287
284
  end
288
285
 
289
286
  rendering.each_column_aware_of_one_last_one(:in_html) do |column, last|
290
-
291
287
  column_name = column.name
292
288
 
293
289
  opts = column.html
@@ -296,23 +292,43 @@ module Wice
296
292
 
297
293
  Wice::WgHash.add_or_append_class_value!(opts, column.css_class)
298
294
 
299
-
300
295
  if column.attribute && column.ordering
301
296
 
302
297
  column.add_css_class('active-filter') if grid.filtered_by?(column)
303
298
 
304
299
  direction = 'asc'
305
300
  link_style = nil
301
+ arrow_class = nil
302
+
306
303
  if grid.ordered_by?(column)
307
304
  column.add_css_class('sorted')
308
305
  Wice::WgHash.add_or_append_class_value!(opts, 'sorted')
309
306
  link_style = grid.order_direction
310
- direction = 'desc' if grid.order_direction == 'asc'
307
+
308
+ case grid.order_direction
309
+ when 'asc'
310
+ direction = 'desc'
311
+ arrow_class = 'down'
312
+ when 'desc'
313
+ direction = 'asc'
314
+ arrow_class = 'up'
315
+ end
311
316
  end
312
317
 
313
318
  col_link = link_to(
314
- column_name,
315
- rendering.column_link(column, direction, params, options[:extra_request_parameters]),
319
+ (column_name +
320
+ if arrow_class
321
+ ' ' + content_tag(:i, '', class: "fa fa-arrow-#{arrow_class}")
322
+ else
323
+ ''
324
+ end).html_safe,
325
+
326
+ rendering.column_link(
327
+ column,
328
+ direction,
329
+ params,
330
+ options[:extra_request_parameters]
331
+ ),
316
332
  class: link_style)
317
333
 
318
334
  grid.output_buffer << content_tag(:th, col_link, opts)
@@ -320,7 +336,7 @@ module Wice
320
336
  else
321
337
  if reuse_last_column_for_filter_buttons && last
322
338
  grid.output_buffer << content_tag(:th,
323
- hide_show_icon(filter_row_id, grid, filter_shown, no_filter_row, options[:show_filters], rendering), opts
339
+ hide_show_icon(filter_row_id, grid, filter_shown, no_filter_row, options[:show_filters], rendering), opts
324
340
  )
325
341
  else
326
342
  grid.output_buffer << content_tag(:th, column_name, opts)
@@ -329,13 +345,12 @@ module Wice
329
345
  end
330
346
 
331
347
  grid.output_buffer << content_tag(:th,
332
- hide_show_icon(filter_row_id, grid, filter_shown, no_filter_row, options[:show_filters], rendering)
348
+ hide_show_icon(filter_row_id, grid, filter_shown, no_filter_row, options[:show_filters], rendering)
333
349
  ) unless no_rightmost_column
334
350
 
335
351
  grid.output_buffer << '</tr>'
336
352
  # rendering first row end
337
353
 
338
-
339
354
  unless no_filters_at_all # there are filters, we don't know where, in the table or detached
340
355
  if no_filter_row # they are all detached
341
356
  rendering.each_column(:in_html) do |column|
@@ -351,12 +366,11 @@ module Wice
351
366
  Wice::WgHash.add_or_append_class_value!(filter_row_attrs, 'wg-filter-row', true)
352
367
  filter_row_attrs['id'] = filter_row_id
353
368
 
354
- grid.output_buffer << %!<tr #{tag_options(filter_row_attrs, true)} !
369
+ grid.output_buffer << %(<tr #{public_tag_options(filter_row_attrs, true)} )
355
370
  grid.output_buffer << 'style="display:none"' unless filter_shown
356
371
  grid.output_buffer << '>'
357
372
 
358
373
  rendering.each_column_aware_of_one_last_one(:in_html) do |column, last|
359
-
360
374
  opts = column.html ? column.html.clone : {}
361
375
  Wice::WgHash.add_or_append_class_value!(opts, column.css_class)
362
376
 
@@ -372,8 +386,8 @@ module Wice
372
386
  else
373
387
  if reuse_last_column_for_filter_buttons && last
374
388
  grid.output_buffer << content_tag(:th,
375
- reset_submit_buttons(options, grid, rendering),
376
- Wice::WgHash.add_or_append_class_value!(opts, 'filter_icons')
389
+ reset_submit_buttons(options, grid, rendering),
390
+ Wice::WgHash.add_or_append_class_value!(opts, 'filter_icons')
377
391
  )
378
392
  else
379
393
  grid.output_buffer << content_tag(:th, '', opts)
@@ -381,13 +395,12 @@ module Wice
381
395
  end
382
396
  end
383
397
  unless no_rightmost_column
384
- grid.output_buffer << content_tag(:th, reset_submit_buttons(options, grid, rendering), class: 'filter_icons' )
398
+ grid.output_buffer << content_tag(:th, reset_submit_buttons(options, grid, rendering), class: 'filter_icons')
385
399
  end
386
400
  grid.output_buffer << '</tr>'
387
401
  end
388
402
  end
389
403
 
390
-
391
404
  grid.output_buffer << '</thead><tfoot>'
392
405
  grid.output_buffer << rendering.pagination_panel(number_of_columns, options[:hide_csv_button]) do
393
406
  if pagination_panel_content_html
@@ -401,36 +414,28 @@ module Wice
401
414
 
402
415
  grid.output_buffer << '</tfoot><tbody>'
403
416
 
404
-
405
417
  # rendering rows
406
418
  cell_value_of_the_ordered_column = nil
407
419
  previous_cell_value_of_the_ordered_column = nil
408
420
 
409
421
  grid.each do |ar| # rows
410
-
411
422
  before_row_output = if rendering.before_row_handler
412
423
  call_block(rendering.before_row_handler, ar, number_of_columns_for_extra_rows)
413
- else
414
- nil
415
424
  end
416
425
 
417
426
  after_row_output = if rendering.after_row_handler
418
427
  call_block(rendering.after_row_handler, ar, number_of_columns_for_extra_rows)
419
- else
420
- nil
421
428
  end
422
429
 
423
430
  replace_row_output = if rendering.replace_row_handler
424
431
  call_block(rendering.replace_row_handler, ar, number_of_columns_for_extra_rows)
425
- else
426
- nil
427
432
  end
428
433
 
429
434
  row_content = if replace_row_output
430
435
  no_rightmost_column = true
431
436
  replace_row_output
432
437
  else
433
- row_content, tmp_cell_value_of_the_ordered_column = get_row_content(rendering,ar,sorting_dependant_row_cycling)
438
+ row_content, tmp_cell_value_of_the_ordered_column = get_row_content(rendering, ar, sorting_dependant_row_cycling)
434
439
  cell_value_of_the_ordered_column = tmp_cell_value_of_the_ordered_column if tmp_cell_value_of_the_ordered_column
435
440
  row_content
436
441
  end
@@ -447,7 +452,7 @@ module Wice
447
452
  Wice::WgHash.add_or_append_class_value!(row_attributes, cycle_class)
448
453
 
449
454
  grid.output_buffer << before_row_output if before_row_output
450
- grid.output_buffer << "<tr #{tag_options(row_attributes)}>#{row_content}"
455
+ grid.output_buffer << "<tr #{public_tag_options(row_attributes)}>#{row_content}"
451
456
  grid.output_buffer << content_tag(:td, '') unless no_rightmost_column
452
457
  grid.output_buffer << '</tr>'
453
458
  grid.output_buffer << after_row_output if after_row_output
@@ -455,8 +460,6 @@ module Wice
455
460
 
456
461
  last_row_output = if rendering.last_row_handler
457
462
  call_block(rendering.last_row_handler, number_of_columns_for_extra_rows)
458
- else
459
- nil
460
463
  end
461
464
 
462
465
  grid.output_buffer << last_row_output if last_row_output
@@ -467,18 +470,24 @@ module Wice
467
470
 
468
471
  link_for_export = rendering.link_for_export(controller, 'csv', options[:extra_request_parameters])
469
472
 
470
- parameter_name_for_query_loading = {grid.name => {q: ''}}.to_query
471
- parameter_name_for_focus = {grid.name => {foc: ''}}.to_query
473
+ parameter_name_for_query_loading = { grid.name => { q: '' } }.to_query
474
+ parameter_name_for_focus = { grid.name => { foc: '' } }.to_query
472
475
 
473
- processor_initializer_arguments = [base_link_for_filter, base_link_for_show_all_records,
474
- link_for_export, parameter_name_for_query_loading, parameter_name_for_focus, Rails.env]
476
+ processor_initializer_arguments = [
477
+ base_link_for_filter,
478
+ base_link_for_show_all_records,
479
+ link_for_export,
480
+ parameter_name_for_query_loading,
481
+ parameter_name_for_focus,
482
+ Rails.env
483
+ ]
475
484
 
476
485
  filter_declarations = if no_filters_at_all
477
486
  []
478
487
  else
479
488
  rendering.select_for(:in_html) do |vc|
480
489
  vc.attribute && vc.filter
481
- end.collect{|column| column.yield_declaration}
490
+ end.collect(&:yield_declaration)
482
491
  end
483
492
 
484
493
  wg_data = {
@@ -493,95 +502,92 @@ module Wice
493
502
 
494
503
  grid.output_buffer << '</div>'
495
504
 
496
-
497
-
498
505
  if Rails.env.development?
499
- grid.output_buffer << javascript_tag(%/ $(document).ready(function(){ \n/ +
506
+ grid.output_buffer << javascript_tag(%/ $(document).ready(function(){ \n/ +
500
507
  %$ if (typeof(WiceGridProcessor) == "undefined"){\n$ +
501
508
  %$ alert("wice_grid.js not loaded, WiceGrid cannot proceed!\\n" +\n$ +
502
- %$ "Make sure that you have loaded wice_grid.js.\\n" +\n$ +
503
- %$ "Add line\\n//= require wice_grid.js\\n" +\n$ +
509
+ %( "Make sure that you have loaded wice_grid.js.\n" +
510
+ ) +
511
+ %( "Add line\n//= require wice_grid.js\n" +
512
+ ) +
504
513
  %$ "to app/assets/javascripts/application.js")\n$ +
505
- %$ }\n$ +
514
+ %( }
515
+ ) +
506
516
  %$ }) $)
507
517
  end
508
518
 
509
519
  grid.output_buffer
510
520
  end
511
521
 
512
- def hide_show_icon(filter_row_id, grid, filter_shown, no_filter_row, show_filters, rendering) #:nodoc:
513
- grid_name = grid.name
522
+ def hide_show_icon(_filter_row_id, _grid, filter_shown, no_filter_row, show_filters, _rendering) #:nodoc:
514
523
  no_filter_opening_closing_icon = (show_filters == :always) || no_filter_row
515
524
 
516
- styles = ["display: block;", "display: none;"]
525
+ styles = ['display: block;', 'display: none;']
517
526
  styles.reverse! unless filter_shown
518
527
 
519
-
520
528
  if no_filter_opening_closing_icon
521
- hide_icon = show_icon = ''
529
+ ''
522
530
  else
523
531
 
524
- content_tag(:div, '',
525
- title: NlMessage['hide_filter_tooltip'],
526
- style: styles[0],
527
- class: 'clickable wg-hide-filter'
532
+ content_tag(:div, content_tag(:i, '', class: 'fa fa-eye-slash'),
533
+ title: NlMessage['hide_filter_tooltip'],
534
+ style: styles[0],
535
+ class: 'clickable wg-hide-filter'
528
536
  ) +
529
537
 
530
- content_tag(:div, '',
531
- title: NlMessage['show_filter_tooltip'],
532
- style: styles[1],
533
- class: 'clickable wg-show-filter'
534
- )
538
+ content_tag(:div, content_tag(:i, '', class: 'fa fa-eye'),
539
+ title: NlMessage['show_filter_tooltip'],
540
+ style: styles[1],
541
+ class: 'clickable wg-show-filter'
542
+ )
535
543
 
536
544
  end
537
545
  end
538
546
 
539
- def reset_submit_buttons(options, grid, rendering) #:nodoc:
547
+ def reset_submit_buttons(options, grid, _rendering) #:nodoc:
540
548
  if options[:hide_submit_button]
541
549
  ''
542
550
  else
543
- content_tag(:div, '',
544
- title: NlMessage['filter_tooltip'],
545
- id: grid.name + '_submit_grid_icon',
546
- class: 'submit clickable'
551
+ content_tag(:div, content_tag(:i, '', class: 'fa fa-filter'),
552
+ title: NlMessage['filter_tooltip'],
553
+ id: grid.name + '_submit_grid_icon',
554
+ class: 'submit clickable'
547
555
  )
548
556
  end.html_safe + ' ' +
549
- if options[:hide_reset_button]
550
- ''
551
- else
557
+ if options[:hide_reset_button]
558
+ ''
559
+ else
552
560
 
553
- content_tag(:div, '',
554
- title: NlMessage['reset_filter_tooltip'],
555
- id: grid.name + '_reset_grid_icon',
556
- class: 'reset clickable'
557
- )
558
- end.html_safe
561
+ content_tag(:div, content_tag(:i, '', class: 'fa fa-table'),
562
+ title: NlMessage['reset_filter_tooltip'],
563
+ id: grid.name + '_reset_grid_icon',
564
+ class: 'reset clickable'
565
+ )
566
+ end.html_safe
559
567
  end
560
568
 
561
569
  # Renders a detached filter. The parameters are:
562
570
  # * +grid+ the WiceGrid object
563
571
  # * +filter_key+ an identifier of the filter specified in the column declaration by parameter +:detach_with_id+
564
572
  def grid_filter(grid, filter_key)
565
- unless grid.kind_of? WiceGrid
566
- raise WiceGridArgumentError.new("grid_filter: the parameter must be a WiceGrid instance.")
573
+ unless grid.is_a? WiceGrid
574
+ fail WiceGridArgumentError.new('grid_filter: the parameter must be a WiceGrid instance.')
567
575
  end
568
576
  if grid.output_buffer.nil?
569
- raise WiceGridArgumentError.new("grid_filter: You have attempted to run 'grid_filter' before 'grid'. Read about detached filters in the documentation.")
577
+ fail WiceGridArgumentError.new("grid_filter: You have attempted to run 'grid_filter' before 'grid'. Read about detached filters in the documentation.")
570
578
  end
571
579
  if grid.output_buffer == true
572
- raise WiceGridArgumentError.new("grid_filter: You have defined no detached filters, or you try use detached filters with" +
573
- ":show_filters => :no (set :show_filters to :always in this case). Read about detached filters in the documentation.")
580
+ fail WiceGridArgumentError.new('grid_filter: You have defined no detached filters, or you try use detached filters with' \
581
+ ':show_filters => :no (set :show_filters to :always in this case). Read about detached filters in the documentation.')
574
582
  end
575
583
 
576
584
  content_tag :span,
577
- grid.output_buffer.filter_for(filter_key),
578
- class: "wg-detached-filter #{grid.name}_detached_filter",
579
- 'data-grid-name' => grid.name
585
+ grid.output_buffer.filter_for(filter_key),
586
+ class: "wg-detached-filter #{grid.name}_detached_filter",
587
+ 'data-grid-name' => grid.name
580
588
  end
581
589
 
582
-
583
590
  def grid_csv(grid, rendering) #:nodoc:
584
-
585
591
  spreadsheet = ::Wice::Spreadsheet.new(grid.name, grid.csv_field_separator)
586
592
 
587
593
  # columns
@@ -596,8 +602,8 @@ module Wice
596
602
 
597
603
  column_block_output = call_block(cell_block, ar)
598
604
 
599
- if column_block_output.kind_of?(Array)
600
- column_block_output, additional_opts = column_block_output
605
+ if column_block_output.is_a?(Array)
606
+ column_block_output, _additional_opts = column_block_output
601
607
  end
602
608
 
603
609
  row << column_block_output
@@ -616,27 +622,25 @@ module Wice
616
622
  html = pagination_info(grid, allow_showing_all_records)
617
623
 
618
624
  paginate(grid.resultset,
619
- theme: 'wice_grid',
620
- param_name: "#{grid.name}[page]",
621
- params: extra_request_parameters,
622
- inner_window: 4,
623
- outer_window: 2
625
+ theme: 'wice_grid',
626
+ param_name: "#{grid.name}[page]",
627
+ params: extra_request_parameters,
628
+ inner_window: 4,
629
+ outer_window: 2
624
630
  ) +
625
631
  (' <div class="pagination_status">' + html + '</div>').html_safe
626
632
  end
627
633
 
628
-
629
- def show_all_link(collection_total_entries, parameters, grid_name) #:nodoc:
630
-
634
+ def show_all_link(collection_total_entries, parameters, _grid_name) #:nodoc:
631
635
  message = NlMessage['all_queries_warning']
632
636
  confirmation = collection_total_entries > Defaults::START_SHOWING_WARNING_FROM ? message : nil
633
637
 
634
638
  html = content_tag(:a, NlMessage['show_all_records_label'],
635
- href: "#",
636
- title: NlMessage['show_all_records_tooltip'],
637
- class: 'wg-show-all-link',
638
- 'data-grid-state' => parameters.to_json,
639
- 'data-confim-message' => confirmation
639
+ href: '#',
640
+ title: NlMessage['show_all_records_tooltip'],
641
+ class: 'wg-show-all-link',
642
+ 'data-grid-state' => parameters.to_json,
643
+ 'data-confim-message' => confirmation
640
644
  )
641
645
 
642
646
  [html, '']
@@ -644,25 +648,22 @@ module Wice
644
648
 
645
649
  def back_to_pagination_link(parameters, grid_name) #:nodoc:
646
650
  pagination_override_parameter_name = "#{grid_name}[pp]"
647
- parameters = parameters.reject{|k, v| k == pagination_override_parameter_name}
651
+ parameters = parameters.reject { |k, _v| k == pagination_override_parameter_name }
648
652
 
649
653
  content_tag(:a, NlMessage['switch_back_to_paginated_mode_label'],
650
- href: "#",
651
- title: NlMessage['switch_back_to_paginated_mode_tooltip'],
652
- class: 'wg-back-to-pagination-link',
653
- 'data-grid-state' => parameters.to_json
654
+ href: '#',
655
+ title: NlMessage['switch_back_to_paginated_mode_tooltip'],
656
+ class: 'wg-back-to-pagination-link',
657
+ 'data-grid-state' => parameters.to_json
654
658
  )
655
659
  end
656
660
 
657
661
  def pagination_info(grid, allow_showing_all_records) #:nodoc:
658
-
659
662
  collection = grid.resultset
660
663
 
661
664
  if grid.all_record_mode?
662
665
 
663
666
  collection_total_entries = collection.length
664
- current_page = 1
665
- per_page = collection_total_entries
666
667
 
667
668
  first = 1
668
669
  last = collection.size
@@ -681,8 +682,6 @@ module Wice
681
682
 
682
683
  else
683
684
  collection_total_entries = collection.total_count
684
- current_page = grid.ar_options[:page].to_i
685
- per_page = grid.ar_options[:per_page].to_i
686
685
 
687
686
  first = collection.offset_value + 1
688
687
  last = collection.last_page? ? collection.total_count : collection.offset_value + collection.limit_value
@@ -692,8 +691,7 @@ module Wice
692
691
 
693
692
  parameters = grid.get_state_as_parameter_value_pairs
694
693
 
695
- js = ''
696
- html = if (num_pages < 2 && collection.length == 0)
694
+ if num_pages < 2 && collection.length == 0
697
695
  '0'
698
696
  else
699
697
  parameters << ["#{grid.name}[pp]", collection_total_entries]
@@ -706,18 +704,17 @@ module Wice
706
704
 
707
705
  "#{first}-#{last} / #{collection_total_entries} " +
708
706
  if show_all_records_link
709
- res, js = show_all_link(collection_total_entries, parameters, grid.name)
707
+ res, _js = show_all_link(collection_total_entries, parameters, grid.name)
710
708
  res
711
709
  else
712
710
  ''
713
711
  end
714
712
  end +
715
- if grid.all_record_mode?
716
- back_to_pagination_link(parameters, grid.name)
717
- else
718
- ''
719
- end
713
+ if grid.all_record_mode?
714
+ back_to_pagination_link(parameters, grid.name)
715
+ else
716
+ ''
717
+ end
720
718
  end
721
-
722
719
  end
723
720
  end