wice_grid 3.4.10 → 3.4.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c917326faf115ba71d1c1e156815fa05cfc0ac71
4
- data.tar.gz: 7db7696c87a0a9d8171044b5145337da821141ae
3
+ metadata.gz: 19f365e429574298ed3b586c2517491ec3df7513
4
+ data.tar.gz: 9e662dc2095c9885feb230952f881f3705cc12ee
5
5
  SHA512:
6
- metadata.gz: ccab35cfcc8952ec2992fda26dc6ea8b332ec82476d81ea141e0625fe7351730c80833c494ac433c594b3e4a99d91b499d8fc52abb59f4143c1fbd7bdc611ad6
7
- data.tar.gz: ee71fd6c9196446d51e22ee25763d78df102e768f36363972d11504f0daecfe4b53e90f288b646bc368f4b1026b5f2ba926f4487ff83a3ae0d9b69751576aa45
6
+ metadata.gz: a47a53ef05c4a51972399a7f0d5adb74788a03637b2f334642d4e07fe5e8d418e665cb00b37e037d5e36d0548269ce8220f46f39e9cc9e779c7067a0958895d7
7
+ data.tar.gz: a9160aef46162410f9420264c2fc102eb92ea23fa2f054cb1b5e8a7dec2a077f865a5ef8a3ea6d71998cad63fb08f59f7aeb6a0d9abb8af48e1307b5c29d9d27
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = WiceGrid
2
2
 
3
- Version:: 3.4.10
3
+ Version:: 3.4.11
4
4
  Author:: Yuri Leikind
5
5
  Sources:: https://github.com/leikind/wice_grid/
6
6
  Examples online:: http://wicegrid.herokuapp.com
@@ -677,27 +677,36 @@ with value <tt>:range</tt>:
677
677
  end
678
678
 
679
679
 
680
- === Javascript Calendar for Date and DateTime Filters.
680
+ === Date and DateTime Filters
681
681
 
682
- WiceGrid uses jQuery datepicker[http://jqueryui.com/demos/datepicker/] for Date and DateTime filters by default.
683
- Because this is part of the standard jQuery codebase, it is not bundled together with the plugin,
684
- and it is the responsibility of the programmer to include all necessary assets including
685
- localization files if the application is multilingual.
686
-
687
-
688
- jQuery datepicker does not have any time related controls, and when dealing with DateTime filters, the time value is ignored.
689
-
690
- Another option is standard Rails helpers. It's possible to change between the two styles of Date/DateTime
691
- filters in <tt>config/initializers/wice_grid_config.rb</tt> using constant HELPER_STYLE, or set it on per-column basis:
682
+ WiceGrid provides three ways of selecting dates and times. The default style is
683
+ set in <tt>config/initializers/wice_grid_config.rb</tt> using the HELPER_STYLE
684
+ constant. The available options are <tt>:calendar</tt> (jQueryUI datepicker),
685
+ <tt>:html5</tt> and <tt>:standard</tt>. The style can also be individually
686
+ configured via the <tt>helper_style</tt> option on a Date/DateTime filter
687
+ column configuration:
692
688
 
693
689
  g.column name: 'Due Date', attribute: 'due_date', helper_style: :calendar do |task|
694
690
  task.due_date.to_s(:short) if task.due_date
695
691
  end
696
692
 
693
+ g.column name: 'Created', attribute: 'created_at', helper_style: :html5 do |task|
694
+ task.created_at.to_s(:short)
695
+ end
696
+
697
697
  g.column name: 'Updated', attribute: 'updated_at', helper_style: :standard do |task|
698
698
  task.created_at.to_s(:short)
699
699
  end
700
700
 
701
+ ==== jQueryUI DatePicker
702
+
703
+ By default WiceGrid uses jQueryUI datepicker[http://jqueryui.com/demos/datepicker/] for Date and DateTime filters.
704
+ Because this is part of the standard jQueryUI codebase, it is not bundled together with the plugin,
705
+ and it is the responsibility of the programmer to include all necessary assets including
706
+ localization files if the application is multilingual.
707
+
708
+ jQueryUI datepicker does not have any time related controls, and when dealing with DateTime filters, the time value is ignored.
709
+
701
710
  Constants +DATE_FORMAT+ and +DATETIME_FORMAT+ in the configuration file define the format of dates the user will see, as well as the
702
711
  format of the string sent in a HTTP parameter. If you change the formats, make sure that lamdbas defined
703
712
  in +DATETIME_PARSER+ and +DATE_PARSER+ return valid DateTime and Date objects.
@@ -712,7 +721,24 @@ you can always change this range dynamically with the following javascript:
712
721
 
713
722
  $( ".hasDatepicker" ).datepicker( "option", "yearRange", "2000:2042" );
714
723
 
724
+ ==== HTML5 input[type=date] DatePicker
725
+
726
+ In stead of the jQueryUI version of the datepicker some Browsers implement
727
+ their own datepicker which can be used as well without having to rely on
728
+ jQueryUI.
729
+
730
+ This helper_style actually also lets you use other javascript datepickers as
731
+ well. For example if you want to use the
732
+ bootstrap-datetimepicker[https://github.com/Eonasdan/bootstrap-datetimepicker]
733
+ with a timepicker, you would do this:
734
+
735
+ $('input[type=date]').attr("type","text").datetimepicker();
736
+
737
+ ==== Rails standard input fields
715
738
 
739
+ Another option is standard Rails helpers for date fields, these are separate
740
+ select fields for years, months and days (also for hour and minute if it is a
741
+ datetime field).
716
742
 
717
743
  == Detached Filters
718
744
 
@@ -112,6 +112,7 @@ if defined?(Wice::Defaults)
112
112
 
113
113
  # The default style of the date and datetime helper
114
114
  # * <tt>:calendar</tt> - JS calendar
115
+ # * <tt>:html5</tt> - HTML5 date input field
115
116
  # * <tt>:standard</tt> - standard Rails date and datetime helpers
116
117
  Wice::Defaults::HELPER_STYLE = :calendar
117
118
 
@@ -47,6 +47,16 @@ module Wice
47
47
  '</div>'
48
48
  end
49
49
 
50
+
51
+ def render_html5_filter_internal(params) #:nodoc:
52
+ css_class = 'form-control input-sm native-datepicker ' + (auto_reload ? 'auto-reload' : '')
53
+ date_format = Wice::ConfigurationProvider.value_for(:DATE_FORMAT)
54
+ '<div class="date-filter">' +
55
+ date_field_tag(@name1, params[:fr].try(:strftime, date_format), {class: css_class, id: @dom_id}) + '<br/>' +
56
+ date_field_tag(@name2, params[:to].try(:strftime, date_format), {class: css_class, id: @dom_id2}) +
57
+ '</div>'
58
+ end
59
+
50
60
  def render_calendar_filter_internal(params) #:nodoc:
51
61
 
52
62
  calendar_data_from = prepare_data_for_calendar(
@@ -80,7 +90,10 @@ module Wice
80
90
  if helper_style == :standard
81
91
  prepare_for_standard_filter
82
92
  render_standard_filter_internal(params)
83
- else
93
+ elsif helper_style == :html5
94
+ prepare_for_calendar_filter
95
+ render_html5_filter_internal(params)
96
+ else # :calendar
84
97
  prepare_for_calendar_filter
85
98
  render_calendar_filter_internal(params)
86
99
  end
data/lib/wice_grid.rb CHANGED
@@ -71,9 +71,9 @@ module Wice
71
71
  @controller = controller
72
72
 
73
73
  @relation = klass_or_relation
74
- @klass = klass_or_relation.is_a?(ActiveRecord::Relation) ?
75
- klass_or_relation.klass :
76
- klass_or_relation
74
+ @klass = @relation.kind_of?(Class) && @relation.ancestors.index(ActiveRecord::Base) ?
75
+ klass_or_relation :
76
+ klass_or_relation.klass
77
77
 
78
78
  unless @klass.kind_of?(Class) && @klass.ancestors.index(ActiveRecord::Base)
79
79
  raise WiceGridArgumentError.new("ActiveRecord model class (second argument) must be a Class derived from ActiveRecord::Base")
@@ -179,7 +179,7 @@ focusElementIfNeeded = (focusId) ->
179
179
 
180
180
  # autoreload for internal filters
181
181
  setupAutoreloadsForInternalFilters = (wiceGridContainer, gridProcessor) ->
182
- $('select.auto-reload', wiceGridContainer).change ->
182
+ $('select.auto-reload, input.native-datepicker.auto-reload', wiceGridContainer).change ->
183
183
  gridProcessor.process()
184
184
 
185
185
  $('input.auto-reload', wiceGridContainer).keyup (event)->
@@ -203,7 +203,7 @@ setupAutoreloadsForExternalFilters = ->
203
203
  $('.wg-detached-filter').each (index, detachedFilterContainer) ->
204
204
  gridProcessor = getGridProcessorForElement(detachedFilterContainer)
205
205
  if gridProcessor
206
- $('select.auto-reload', detachedFilterContainer).change ->
206
+ $('select.auto-reload, input.native-datepicker.auto-reload', detachedFilterContainer).change ->
207
207
  gridProcessor.process()
208
208
 
209
209
  $('input.auto-reload', detachedFilterContainer).keyup (event)->
data/wice_grid.gemspec CHANGED
@@ -1,8 +1,8 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'wice_grid'
3
- s.version = '3.4.10'
3
+ s.version = '3.4.11'
4
4
  s.homepage = 'https://github.com/leikind/wice_grid'
5
- s.date = '2014-08-26'
5
+ s.date = '2014-11-20'
6
6
  s.summary = 'A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters.'
7
7
  s.description = 'A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters.' +
8
8
  'One of the goals of this plugin was to allow the programmer to define the contents of the cell by himself, ' +
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wice_grid
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.10
4
+ version: 3.4.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuri Leikind
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-26 00:00:00.000000000 Z
11
+ date: 2014-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kaminari
@@ -141,4 +141,3 @@ specification_version: 3
141
141
  summary: A Rails grid plugin to create grids with sorting, pagination, and (automatically
142
142
  generated) filters.
143
143
  test_files: []
144
- has_rdoc: