wice_grid 3.2.0 → 3.2.1.pre1

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.
Files changed (35) hide show
  1. data/CHANGELOG +9 -6
  2. data/README.rdoc +29 -0
  3. data/VERSION +1 -1
  4. data/lib/active_record_column_wrapper.rb +105 -0
  5. data/lib/columns/column_action.rb +50 -0
  6. data/lib/columns/column_boolean.rb +43 -0
  7. data/lib/columns/column_custom_dropdown.rb +119 -0
  8. data/lib/columns/column_date.rb +23 -0
  9. data/lib/columns/column_datetime.rb +113 -0
  10. data/lib/columns/column_float.rb +14 -0
  11. data/lib/columns/column_integer.rb +63 -0
  12. data/lib/columns/column_processor_index.rb +19 -0
  13. data/lib/columns/column_range.rb +74 -0
  14. data/lib/columns/column_string.rb +89 -0
  15. data/lib/columns.rb +223 -0
  16. data/lib/generators/wice_grid/add_migration_for_serialized_queries_generator.rb +1 -1
  17. data/lib/generators/wice_grid/templates/create_wice_grid_serialized_queries.rb +2 -2
  18. data/lib/grid_renderer.rb +19 -9
  19. data/lib/helpers/wice_grid_view_helpers.rb +6 -10
  20. data/lib/kaminari_monkey_patching.rb +4 -4
  21. data/lib/wice_grid.rb +15 -245
  22. data/lib/wice_grid_controller.rb +4 -4
  23. data/lib/wice_grid_core_ext.rb +3 -3
  24. data/wice_grid.gemspec +15 -13
  25. metadata +17 -15
  26. data/lib/view_columns/action_view_column.rb +0 -45
  27. data/lib/view_columns/column_processor_index.rb +0 -16
  28. data/lib/view_columns/view_column_boolean.rb +0 -23
  29. data/lib/view_columns/view_column_custom_dropdown.rb +0 -80
  30. data/lib/view_columns/view_column_date.rb +0 -17
  31. data/lib/view_columns/view_column_datetime.rb +0 -85
  32. data/lib/view_columns/view_column_float.rb +0 -7
  33. data/lib/view_columns/view_column_integer.rb +0 -38
  34. data/lib/view_columns/view_column_string.rb +0 -63
  35. data/lib/view_columns.rb +0 -177
data/lib/wice_grid.rb CHANGED
@@ -4,6 +4,7 @@ require 'wice_grid_misc.rb'
4
4
  require 'wice_grid_core_ext.rb'
5
5
  require 'grid_renderer.rb'
6
6
  require 'table_column_matrix.rb'
7
+ require 'active_record_column_wrapper.rb'
7
8
  require 'helpers/wice_grid_view_helpers.rb'
8
9
  require 'helpers/wice_grid_misc_view_helpers.rb'
9
10
  require 'helpers/wice_grid_serialized_queries_view_helpers.rb'
@@ -13,8 +14,8 @@ require 'grid_output_buffer.rb'
13
14
  require 'wice_grid_controller.rb'
14
15
  require 'wice_grid_spreadsheet.rb'
15
16
  require 'wice_grid_serialized_queries_controller.rb'
16
- require 'view_columns/column_processor_index.rb'
17
- require 'view_columns.rb'
17
+ require 'columns/column_processor_index.rb'
18
+ require 'columns.rb'
18
19
  require 'kaminari.rb'
19
20
 
20
21
 
@@ -22,7 +23,7 @@ ActionController::Base.send(:helper_method, :wice_grid_custom_filter_params)
22
23
 
23
24
  module Wice
24
25
 
25
- class WiceGridEngine < ::Rails::Engine
26
+ class WiceGridEngine < ::Rails::Engine #:nodoc:
26
27
 
27
28
  initializer "wice_grid_railtie.configure_rails_initialization" do |app|
28
29
 
@@ -44,7 +45,7 @@ module Wice
44
45
  JsCalendarHelpers.send(:include, m)
45
46
  end
46
47
 
47
- ViewColumn.load_column_processors
48
+ Columns.load_column_processors
48
49
  require 'wice_grid_serialized_query.rb'
49
50
 
50
51
  # It is here only until this pull request is pulled: https://github.com/amatsuda/kaminari/pull/267
@@ -55,10 +56,10 @@ module Wice
55
56
 
56
57
  class WiceGrid
57
58
 
58
- attr_reader :klass, :name, :resultset, :custom_order, :query_store_model
59
- attr_reader :ar_options, :status, :export_to_csv_enabled, :csv_file_name, :csv_field_separator, :saved_query
60
- attr_writer :renderer
61
- attr_accessor :output_buffer, :view_helper_finished, :csv_tempfile
59
+ attr_reader :klass, :name, :resultset, :custom_order, :query_store_model #:nodoc:
60
+ attr_reader :ar_options, :status, :export_to_csv_enabled, :csv_file_name, :csv_field_separator, :saved_query #:nodoc:
61
+ attr_writer :renderer #:nodoc:
62
+ attr_accessor :output_buffer, :view_helper_finished, :csv_tempfile #:nodoc:
62
63
 
63
64
  # core workflow methods START
64
65
 
@@ -203,7 +204,7 @@ module Wice
203
204
  end
204
205
  end
205
206
 
206
- def declare_column(column_name, model, custom_filter_active, table_alias) #:nodoc:
207
+ def declare_column(column_name, model, custom_filter_active, table_alias, filter_type) #:nodoc:
207
208
  if model # this is an included table
208
209
  column = @table_column_matrix.get_column_by_model_class_and_column_name(model, column_name)
209
210
  raise WiceGridArgumentError.new("Column '#{column_name}' is not found in table '#{model.table_name}'!") if column.nil?
@@ -221,7 +222,9 @@ module Wice
221
222
  end
222
223
 
223
224
  if column
224
- conditions, current_parameter_name = column.wg_initialize_request_parameters(@status[:f], main_table, table_alias, custom_filter_active)
225
+ conditions_generator = ActiveRecordColumnWrapper.new(column, @status[:f], main_table, table_alias, custom_filter_active, filter_type)
226
+ conditions, current_parameter_name = conditions_generator.wg_initialize_request_parameters
227
+
225
228
  if @status[:f] && conditions.blank?
226
229
  @status[:f].delete(current_parameter_name)
227
230
  end
@@ -447,11 +450,6 @@ module Wice
447
450
  end
448
451
 
449
452
 
450
- def selected_records #:nodoc:
451
- STDERR.puts "WiceGrid: Parameter :#{selected_records} is deprecated, use :#{all_pages_records} or :#{current_page_records} instead!"
452
- all_pages_records
453
- end
454
-
455
453
  # Returns the list of objects browsable through all pages with the current filters.
456
454
  # Should only be called after the +grid+ helper.
457
455
  def all_pages_records
@@ -556,7 +554,7 @@ module Wice
556
554
  def resultset_without_paging_with_user_filters #:nodoc:
557
555
  form_ar_options
558
556
  @klass.unscoped do
559
- @relation.find(:all, :joins => @ar_options[:joins],
557
+ @relation.find(:all, :joins => @ar_options[:joins],
560
558
  :include => @ar_options[:include],
561
559
  :group => @ar_options[:group],
562
560
  :conditions => @ar_options[:conditions],
@@ -575,7 +573,7 @@ module Wice
575
573
 
576
574
  end
577
575
 
578
- # routines called from WiceGridExtentionToActiveRecordColumn (ActiveRecord::ConnectionAdapters::Column) or FilterConditionsGenerator classes
576
+ # routines called from WiceGridExtentionToActiveRecordColumn (ActiveRecord::ConnectionAdapters::Column) or ConditionsGeneratorColumn classes
579
577
  module GridTools #:nodoc:
580
578
  class << self
581
579
  def special_value(str) #:nodoc:
@@ -607,234 +605,6 @@ module Wice
607
605
  end
608
606
  end
609
607
 
610
- # to be mixed in into ActiveRecord::ConnectionAdapters::Column
611
- module WiceGridExtentionToActiveRecordColumn #:nodoc:
612
-
613
- attr_accessor :model
614
-
615
- def alias_or_table_name(table_alias)
616
- table_alias || self.model.table_name
617
- end
618
-
619
- def wg_initialize_request_parameters(all_filter_params, main_table, table_alias, custom_filter_active) #:nodoc:
620
- @request_params = nil
621
- return if all_filter_params.nil?
622
-
623
- # if the parameter does not specify the table name we only allow columns in the default table to use these parameters
624
- if main_table && @request_params = all_filter_params[self.name]
625
- current_parameter_name = self.name
626
- elsif @request_params = all_filter_params[alias_or_table_name(table_alias) + '.' + self.name]
627
- current_parameter_name = alias_or_table_name(table_alias) + '.' + self.name
628
- end
629
-
630
- # Preprocess incoming parameters for datetime, if what's coming in is
631
- # a datetime (with custom_filter it can be anything else, and not
632
- # the datetime hash {:fr => ..., :to => ...})
633
- if @request_params
634
- if (self.type == :datetime || self.type == :timestamp) && @request_params.is_a?(Hash)
635
- [:fr, :to].each do |sym|
636
- if @request_params[sym]
637
- if @request_params[sym].is_a?(String)
638
- @request_params[sym] = Wice::ConfigurationProvider.value_for(:DATETIME_PARSER).call(@request_params[sym])
639
- elsif @request_params[sym].is_a?(Hash)
640
- @request_params[sym] = Wice::GridTools.params_2_datetime(@request_params[sym])
641
- end
642
- end
643
- end
644
-
645
- end
646
-
647
- # Preprocess incoming parameters for date, if what's coming in is
648
- # a date (with custom_filter it can be anything else, and not
649
- # the date hash {:fr => ..., :to => ...})
650
- if self.type == :date && @request_params.is_a?(Hash)
651
- [:fr, :to].each do |sym|
652
- if @request_params[sym]
653
- if @request_params[sym].is_a?(String)
654
- @request_params[sym] = Wice::ConfigurationProvider.value_for(:DATE_PARSER).call(@request_params[sym])
655
- elsif @request_params[sym].is_a?(Hash)
656
- @request_params[sym] = ::Wice::GridTools.params_2_date(@request_params[sym])
657
- end
658
- end
659
- end
660
- end
661
- end
662
-
663
- return wg_generate_conditions(table_alias, custom_filter_active), current_parameter_name
664
- end
665
-
666
- def wg_generate_conditions(table_alias, custom_filter_active) #:nodoc:
667
- return nil if @request_params.nil?
668
-
669
- if custom_filter_active
670
- return ::Wice::FilterConditionsGeneratorCustomFilter.new(self).generate_conditions(table_alias, @request_params)
671
- end
672
608
 
673
- column_type = self.type.to_s
674
-
675
- processor_class = ::Wice::FilterConditionsGenerator.handled_type[column_type]
676
-
677
- if processor_class
678
- return processor_class.new(self).generate_conditions(table_alias, @request_params)
679
- else
680
- Wice.log("No processor for database type #{column_type}!!!")
681
- nil
682
- end
683
- end
684
-
685
- end
686
-
687
- class FilterConditionsGenerator #:nodoc:
688
-
689
- cattr_accessor :handled_type
690
- @@handled_type = HashWithIndifferentAccess.new
691
-
692
- def initialize(column) #:nodoc:
693
- @column = column
694
- end
695
- end
696
-
697
- class FilterConditionsGeneratorCustomFilter < FilterConditionsGenerator #:nodoc:
698
-
699
- def generate_conditions(table_alias, opts) #:nodoc:
700
- if opts.empty? || (opts.is_a?(Array) && opts.size == 1 && opts[0].blank?)
701
- return false
702
- end
703
- opts = (opts.kind_of?(Array) && opts.size == 1) ? opts[0] : opts
704
-
705
- if opts.kind_of?(Array)
706
- opts_with_special_values, normal_opts = opts.partition{|v| ::Wice::GridTools.special_value(v)}
707
-
708
- conditions_ar = if normal_opts.size > 0
709
- [" #{@column.alias_or_table_name(table_alias)}.#{@column.name} IN ( " + (['?'] * normal_opts.size).join(', ') + ' )'] + normal_opts
710
- else
711
- []
712
- end
713
-
714
- if opts_with_special_values.size > 0
715
- special_conditions = opts_with_special_values.collect{|v| " #{@column.alias_or_table_name(table_alias)}.#{@column.name} is " + v}.join(' or ')
716
- if conditions_ar.size > 0
717
- conditions_ar[0] = " (#{conditions_ar[0]} or #{special_conditions} ) "
718
- else
719
- conditions_ar = " ( #{special_conditions} ) "
720
- end
721
- end
722
- conditions_ar
723
- else
724
- if ::Wice::GridTools.special_value(opts)
725
- " #{@column.alias_or_table_name(table_alias)}.#{@column.name} is " + opts
726
- else
727
- [" #{@column.alias_or_table_name(table_alias)}.#{@column.name} = ?", opts]
728
- end
729
- end
730
- end
731
-
732
- end
733
-
734
- class FilterConditionsGeneratorBoolean < FilterConditionsGenerator #:nodoc:
735
- @@handled_type[:boolean] = self
736
-
737
- def generate_conditions(table_alias, opts) #:nodoc:
738
- unless (opts.kind_of?(Array) && opts.size == 1)
739
- Wice.log "invalid parameters for the grid boolean filter - must be an one item array: #{opts.inspect}"
740
- return false
741
- end
742
- opts = opts[0]
743
- if opts == 'f'
744
- [" (#{@column.alias_or_table_name(table_alias)}.#{@column.name} = ? or #{@column.alias_or_table_name(table_alias)}.#{@column.name} is null) ", false]
745
- elsif opts == 't'
746
- [" #{@column.alias_or_table_name(table_alias)}.#{@column.name} = ?", true]
747
- else
748
- nil
749
- end
750
- end
751
- end
752
-
753
- class FilterConditionsGeneratorString < FilterConditionsGenerator #:nodoc:
754
- @@handled_type[:string] = self
755
- @@handled_type[:text] = self
756
-
757
- def generate_conditions(table_alias, opts) #:nodoc:
758
- if opts.kind_of? String
759
- string_fragment = opts
760
- negation = ''
761
- elsif (opts.kind_of? Hash) && opts.has_key?(:v)
762
- string_fragment = opts[:v]
763
- negation = opts[:n] == '1' ? 'NOT' : ''
764
- else
765
- Wice.log "invalid parameters for the grid string filter - must be a string: #{opts.inspect} or a Hash with keys :v and :n"
766
- return false
767
- end
768
- if string_fragment.empty?
769
- return false
770
- end
771
- [" #{negation} #{@column.alias_or_table_name(table_alias)}.#{@column.name} #{::Wice.get_string_matching_operators(@column.model)} ?",
772
- '%' + string_fragment + '%']
773
- end
774
-
775
- end
776
-
777
- class FilterConditionsGeneratorInteger < FilterConditionsGenerator #:nodoc:
778
- @@handled_type[:integer] = self
779
- @@handled_type[:float] = self
780
- @@handled_type[:decimal] = self
781
-
782
- def generate_conditions(table_alias, opts) #:nodoc:
783
- unless opts.kind_of? Hash
784
- Wice.log "invalid parameters for the grid integer filter - must be a hash"
785
- return false
786
- end
787
- conditions = [[]]
788
- if opts[:fr]
789
- if opts[:fr] =~ /\d/
790
- conditions[0] << " #{@column.alias_or_table_name(table_alias)}.#{@column.name} >= ? "
791
- conditions << opts[:fr]
792
- else
793
- opts.delete(:fr)
794
- end
795
- end
796
-
797
- if opts[:to]
798
- if opts[:to] =~ /\d/
799
- conditions[0] << " #{@column.alias_or_table_name(table_alias)}.#{@column.name} <= ? "
800
- conditions << opts[:to]
801
- else
802
- opts.delete(:to)
803
- end
804
- end
805
-
806
- if conditions.size == 1
807
- return false
808
- end
809
-
810
- conditions[0] = conditions[0].join(' and ')
811
-
812
- return conditions
813
- end
814
- end
815
-
816
- class FilterConditionsGeneratorDate < FilterConditionsGenerator #:nodoc:
817
- @@handled_type[:date] = self
818
- @@handled_type[:datetime] = self
819
- @@handled_type[:timestamp] = self
820
-
821
- def generate_conditions(table_alias, opts) #:nodoc:
822
- conditions = [[]]
823
- if opts[:fr]
824
- conditions[0] << " #{@column.alias_or_table_name(table_alias)}.#{@column.name} >= ? "
825
- conditions << opts[:fr]
826
- end
827
-
828
- if opts[:to]
829
- conditions[0] << " #{@column.alias_or_table_name(table_alias)}.#{@column.name} <= ? "
830
- conditions << opts[:to]
831
- end
832
-
833
- return false if conditions.size == 1
834
-
835
- conditions[0] = conditions[0].join(' and ')
836
- return conditions
837
- end
838
- end
839
609
 
840
610
  end
@@ -17,7 +17,7 @@ module Wice
17
17
 
18
18
  protected
19
19
 
20
- attr_accessor :wice_grid_instances
20
+ attr_accessor :wice_grid_instances #:nodoc:
21
21
 
22
22
  # Creates a grid object to be used in the view. This is the <i>main</i> model, and the underlying table is the default table -
23
23
  # if in other parameters a column name is mentioned without the name of the table, this table is implied.
@@ -163,7 +163,7 @@ module Wice
163
163
  private
164
164
 
165
165
 
166
- def send_file_rails2(path, options = {}) #:doc:
166
+ def send_file_rails2(path, options = {}) #:nodoc:
167
167
  raise "Cannot read file #{path}" unless File.file?(path) and File.readable?(path)
168
168
 
169
169
  options[:length] ||= File.size(path)
@@ -177,7 +177,7 @@ module Wice
177
177
  end
178
178
 
179
179
 
180
- DEFAULT_SEND_FILE_OPTIONS_RAILS2 = {
180
+ DEFAULT_SEND_FILE_OPTIONS_RAILS2 = { #:nodoc:
181
181
  :type => 'application/octet-stream'.freeze,
182
182
  :disposition => 'attachment'.freeze,
183
183
  :stream => true,
@@ -185,7 +185,7 @@ module Wice
185
185
  :x_sendfile => false
186
186
  }.freeze
187
187
 
188
- def send_file_headers_rails2!(options) #:doc:
188
+ def send_file_headers_rails2!(options) #:nodoc:
189
189
 
190
190
  options.update(DEFAULT_SEND_FILE_OPTIONS_RAILS2.merge(options))
191
191
  [:length, :type, :disposition].each do |arg|
@@ -1,8 +1,8 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module Wice
4
- module WgHash
5
- class << self
4
+ module WgHash #:nodoc:
5
+ class << self #:nodoc:
6
6
 
7
7
  # if there's a hash of hashes, the original structure and the
8
8
  # returned structure should not contain any shared deep hashes
@@ -105,7 +105,7 @@ module Wice
105
105
 
106
106
  end
107
107
 
108
- module WgArray
108
+ module WgArray #:nodoc:
109
109
  # Only used by Hash#parameter_names_and_values
110
110
  # Transforms ['foo', 'bar', 'baz'] to 'foo[bar][baz]'
111
111
  def self.to_parameter_name(array) #:nodoc:
data/wice_grid.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "wice_grid"
8
- s.version = "3.2.0"
8
+ s.version = "3.2.1.pre1"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Yuri Leikind"]
12
- s.date = "2012-09-30"
12
+ s.date = "2012-12-14"
13
13
  s.description = "A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters "
14
14
  s.email = "yuri.leikind@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -29,6 +29,18 @@ Gem::Specification.new do |s|
29
29
  "app/views/kaminari/wice_grid/_page.html.erb",
30
30
  "app/views/kaminari/wice_grid/_paginator.html.erb",
31
31
  "app/views/kaminari/wice_grid/_prev_page.html.erb",
32
+ "lib/active_record_column_wrapper.rb",
33
+ "lib/columns.rb",
34
+ "lib/columns/column_action.rb",
35
+ "lib/columns/column_boolean.rb",
36
+ "lib/columns/column_custom_dropdown.rb",
37
+ "lib/columns/column_date.rb",
38
+ "lib/columns/column_datetime.rb",
39
+ "lib/columns/column_float.rb",
40
+ "lib/columns/column_integer.rb",
41
+ "lib/columns/column_processor_index.rb",
42
+ "lib/columns/column_range.rb",
43
+ "lib/columns/column_string.rb",
32
44
  "lib/generators/wice_grid/add_migration_for_serialized_queries_generator.rb",
33
45
  "lib/generators/wice_grid/install_generator.rb",
34
46
  "lib/generators/wice_grid/templates/create_wice_grid_serialized_queries.rb",
@@ -43,16 +55,6 @@ Gem::Specification.new do |s|
43
55
  "lib/helpers/wice_grid_view_helpers.rb",
44
56
  "lib/kaminari_monkey_patching.rb",
45
57
  "lib/table_column_matrix.rb",
46
- "lib/view_columns.rb",
47
- "lib/view_columns/action_view_column.rb",
48
- "lib/view_columns/column_processor_index.rb",
49
- "lib/view_columns/view_column_boolean.rb",
50
- "lib/view_columns/view_column_custom_dropdown.rb",
51
- "lib/view_columns/view_column_date.rb",
52
- "lib/view_columns/view_column_datetime.rb",
53
- "lib/view_columns/view_column_float.rb",
54
- "lib/view_columns/view_column_integer.rb",
55
- "lib/view_columns/view_column_string.rb",
56
58
  "lib/wice_grid.rb",
57
59
  "lib/wice_grid_controller.rb",
58
60
  "lib/wice_grid_core_ext.rb",
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wice_grid
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
5
- prerelease:
4
+ version: 3.2.1.pre1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Yuri Leikind
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-30 00:00:00.000000000 Z
12
+ date: 2012-12-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: kaminari
@@ -48,6 +48,18 @@ files:
48
48
  - app/views/kaminari/wice_grid/_page.html.erb
49
49
  - app/views/kaminari/wice_grid/_paginator.html.erb
50
50
  - app/views/kaminari/wice_grid/_prev_page.html.erb
51
+ - lib/active_record_column_wrapper.rb
52
+ - lib/columns.rb
53
+ - lib/columns/column_action.rb
54
+ - lib/columns/column_boolean.rb
55
+ - lib/columns/column_custom_dropdown.rb
56
+ - lib/columns/column_date.rb
57
+ - lib/columns/column_datetime.rb
58
+ - lib/columns/column_float.rb
59
+ - lib/columns/column_integer.rb
60
+ - lib/columns/column_processor_index.rb
61
+ - lib/columns/column_range.rb
62
+ - lib/columns/column_string.rb
51
63
  - lib/generators/wice_grid/add_migration_for_serialized_queries_generator.rb
52
64
  - lib/generators/wice_grid/install_generator.rb
53
65
  - lib/generators/wice_grid/templates/create_wice_grid_serialized_queries.rb
@@ -62,16 +74,6 @@ files:
62
74
  - lib/helpers/wice_grid_view_helpers.rb
63
75
  - lib/kaminari_monkey_patching.rb
64
76
  - lib/table_column_matrix.rb
65
- - lib/view_columns.rb
66
- - lib/view_columns/action_view_column.rb
67
- - lib/view_columns/column_processor_index.rb
68
- - lib/view_columns/view_column_boolean.rb
69
- - lib/view_columns/view_column_custom_dropdown.rb
70
- - lib/view_columns/view_column_date.rb
71
- - lib/view_columns/view_column_datetime.rb
72
- - lib/view_columns/view_column_float.rb
73
- - lib/view_columns/view_column_integer.rb
74
- - lib/view_columns/view_column_string.rb
75
77
  - lib/wice_grid.rb
76
78
  - lib/wice_grid_controller.rb
77
79
  - lib/wice_grid_core_ext.rb
@@ -112,9 +114,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
114
  required_rubygems_version: !ruby/object:Gem::Requirement
113
115
  none: false
114
116
  requirements:
115
- - - ! '>='
117
+ - - ! '>'
116
118
  - !ruby/object:Gem::Version
117
- version: '0'
119
+ version: 1.3.1
118
120
  requirements: []
119
121
  rubyforge_project:
120
122
  rubygems_version: 1.8.23
@@ -1,45 +0,0 @@
1
- # encoding: UTF-8
2
- module Wice
3
-
4
- class ActionViewColumn < ViewColumn #:nodoc:
5
- def initialize(grid_obj, html, param_name, select_all_buttons, object_property, view) #:nodoc:
6
- @view = view
7
- @select_all_buttons = select_all_buttons
8
- self.grid = grid_obj
9
- self.html = html
10
- Wice::WgHash.add_or_append_class_value!(self.html, 'sel')
11
- grid_name = self.grid.name
12
- @param_name = param_name
13
- @cell_rendering_block = lambda do |object, params|
14
- selected = if params[grid_name] && params[grid_name][param_name] &&
15
- params[grid_name][param_name].index(object.send(object_property).to_s)
16
- true
17
- else
18
- false
19
- end
20
- check_box_tag("#{grid_name}[#{param_name}][]", object.send(object_property), selected, :id => nil)
21
- end
22
- end
23
-
24
- def in_html #:nodoc:
25
- true
26
- end
27
-
28
- def capable_of_hosting_filter_related_icons? #:nodoc:
29
- false
30
- end
31
-
32
- def name #:nodoc:
33
- return '' unless @select_all_buttons
34
-
35
- content_tag(:div, '',
36
- :class => 'clickable select-all',
37
- :title => NlMessage['select_all']) + ' ' +
38
- content_tag(:div, '',
39
- :class => 'clickable deselect-all',
40
- :title => NlMessage['deselect_all'])
41
-
42
- end
43
-
44
- end
45
- end
@@ -1,16 +0,0 @@
1
- # encoding: UTF-8
2
- module Wice
3
- COLUMN_PROCESSOR_INDEX = ActiveSupport::OrderedHash[
4
- :action , 'action_view_column', # Special processor for action column, columns with checkboxes
5
- :text , 'view_column_string',
6
- :string , 'view_column_string',
7
- :timestamp, 'view_column_datetime',
8
- :datetime , 'view_column_datetime',
9
- :date , 'view_column_date',
10
- :integer , 'view_column_integer',
11
- :float , 'view_column_float',
12
- :decimal , 'view_column_float',
13
- :custom , 'view_column_custom_dropdown', # Special processor for custom filter columns
14
- :boolean , 'view_column_boolean'
15
- ]
16
- end
@@ -1,23 +0,0 @@
1
- # encoding: UTF-8
2
- module Wice
3
-
4
-
5
- class ViewColumnBoolean < ViewColumnCustomDropdown #:nodoc:
6
- include ActionView::Helpers::FormOptionsHelper
7
-
8
- attr_accessor :boolean_filter_true_label, :boolean_filter_false_label
9
-
10
- def render_filter_internal(params) #:nodoc:
11
- @custom_filter = {
12
- @filter_all_label => nil,
13
- @boolean_filter_true_label => 't',
14
- @boolean_filter_false_label => 'f'
15
- }
16
-
17
- @turn_off_select_toggling = true
18
- super(params)
19
- end
20
- end
21
-
22
-
23
- end
@@ -1,80 +0,0 @@
1
- # encoding: UTF-8
2
- module Wice
3
-
4
-
5
- class ViewColumnCustomDropdown < ViewColumn #:nodoc:
6
- include ActionView::Helpers::FormOptionsHelper
7
-
8
- attr_accessor :filter_all_label
9
- attr_accessor :custom_filter
10
-
11
- def render_filter_internal(params) #:nodoc:
12
- @query, @query_without_equals_sign, @parameter_name, @dom_id = form_parameter_name_id_and_query('')
13
- @query_without_equals_sign += '%5B%5D='
14
-
15
- @custom_filter = @custom_filter.call if @custom_filter.kind_of? Proc
16
-
17
- if @custom_filter.kind_of? Array
18
-
19
- @custom_filter = [[@filter_all_label, nil]] + @custom_filter.map{|label, value|
20
- [label.to_s, value.to_s]
21
- }
22
-
23
- end
24
-
25
- select_options = {:name => @parameter_name + '[]', :id => @dom_id, :class => 'custom-dropdown'}
26
-
27
- if @turn_off_select_toggling
28
- select_toggle = ''
29
- else
30
- if self.allow_multiple_selection
31
- select_options[:multiple] = params.is_a?(Array) && params.size > 1
32
-
33
- expand_icon_style, collapse_icon_style = nil, 'display: none'
34
- expand_icon_style, collapse_icon_style = collapse_icon_style, expand_icon_style if select_options[:multiple]
35
-
36
- select_toggle = content_tag(:span, '',
37
- :title => NlMessage['expand'],
38
- :class => 'expand-multi-select-icon clickable',
39
- :style => expand_icon_style
40
- ) +
41
- content_tag(:span, '',
42
- :title => NlMessage['collapse'],
43
- :class => 'collapse-multi-select-icon clickable',
44
- :style => collapse_icon_style
45
- )
46
- else
47
- select_options[:multiple] = false
48
- select_toggle = ''
49
- end
50
- end
51
-
52
- if auto_reload
53
- select_options[:class] += ' auto-reload'
54
- end
55
-
56
- params_for_select = (params.is_a?(Hash) && params.empty?) ? [nil] : params
57
-
58
- '<div class="custom-dropdown-container">'.html_safe +
59
- content_tag(:select,
60
- options_for_select(@custom_filter, params_for_select),
61
- select_options) + select_toggle.html_safe + '</div>'.html_safe
62
- end
63
-
64
-
65
- def yield_declaration_of_column_filter #:nodoc:
66
- {
67
- :templates => [@query_without_equals_sign],
68
- :ids => [@dom_id]
69
- }
70
- end
71
-
72
-
73
- def has_auto_reloading_select? #:nodoc:
74
- auto_reload
75
- end
76
- end
77
-
78
-
79
-
80
- end