Class: Wice::Columns::ViewColumnDatetime
- Inherits:
-
ViewColumn
- Object
- ViewColumn
- Wice::Columns::ViewColumnDatetime
- Includes:
- ActionView::Helpers::DateHelper, JsCalendarHelpers
- Defined in:
- lib/wice/columns/column_datetime.rb
Overview
:nodoc:
Direct Known Subclasses
Constant Summary collapse
- @@datetime_chunk_names =
%w(year month day hour minute)
Constants inherited from ViewColumn
Wice::Columns::ViewColumn::FIELDS
Instance Attribute Summary
Attributes inherited from ViewColumn
#cell_rendering_block, #contains_a_text_input, #custom_filter, #grid, #main_table, #model, #table_name
Instance Method Summary collapse
-
#has_auto_reloading_calendar? ⇒ Boolean
:nodoc:.
-
#name_and_id_from_options(options, type) ⇒ Object
name_and_id_from_options in Rails Date helper does not substitute ‘.’ with ‘_’ like all other simpler form helpers do.
-
#prepare_for_calendar_filter ⇒ Object
:nodoc:.
-
#prepare_for_standard_filter ⇒ Object
:nodoc:.
-
#render_calendar_filter_internal(params) ⇒ Object
:nodoc:.
-
#render_filter_internal(params) ⇒ Object
:nodoc:.
-
#render_standard_filter_internal(params) ⇒ Object
:nodoc:.
-
#yield_declaration_of_column_filter ⇒ Object
:nodoc:.
Methods included from JsCalendarHelpers
#date_calendar_jquery, #prepare_data_for_calendar
Methods inherited from ViewColumn
#add_css_class, #attribute_name_fully_qualified_for_all_but_main_table_columns, #auto_reloading_input_with_negation_checkbox?, #capable_of_hosting_filter_related_icons?, #config, #controller, #css_class, #detachness, #filter_shown?, #filter_shown_in_main_table?, #form_parameter_name_id_and_query, #fully_qualified_attribute_name, #has_auto_reloading_input?, #has_auto_reloading_select?, #initialize, #render_filter, #table_alias_or_table_name, #yield_declaration
Constructor Details
This class inherits a constructor from Wice::Columns::ViewColumn
Instance Method Details
#has_auto_reloading_calendar? ⇒ Boolean
:nodoc:
98 99 100 |
# File 'lib/wice/columns/column_datetime.rb', line 98 def has_auto_reloading_calendar? #:nodoc: auto_reload && helper_style == :calendar end |
#name_and_id_from_options(options, type) ⇒ Object
name_and_id_from_options in Rails Date helper does not substitute ‘.’ with ‘_’ like all other simpler form helpers do. Thus, overriding it here.
13 14 15 16 |
# File 'lib/wice/columns/column_datetime.rb', line 13 def (, type) #:nodoc: [:name] = ([:prefix] || DEFAULT_PREFIX) + ([:discard_type] ? '' : "[#{type}]") [:id] = [:name].gsub(/([\[\(])|(\]\[)/, '_').gsub(/[\]\)]/, '').gsub(/\./, '_').gsub(/_+/, '_') end |
#prepare_for_calendar_filter ⇒ Object
:nodoc:
35 36 37 38 39 40 |
# File 'lib/wice/columns/column_datetime.rb', line 35 def prepare_for_calendar_filter #:nodoc: query, _, @name1, @dom_id = form_parameter_name_id_and_query(:fr => '') query2, _, @name2, @dom_id2 = form_parameter_name_id_and_query(:to => '') @queris_ids = [[query, @dom_id], [query2, @dom_id2] ] end |
#prepare_for_standard_filter ⇒ Object
:nodoc:
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/wice/columns/column_datetime.rb', line 20 def prepare_for_standard_filter #:nodoc: x = lambda{|sym| @@datetime_chunk_names.collect{|datetime_chunk_name| triple = form_parameter_name_id_and_query(sym => {datetime_chunk_name => ''}) [triple[0], triple[3]] } } @queris_ids = x.call(:fr) + x.call(:to) _, _, @name1, _ = form_parameter_name_id_and_query({:fr => ''}) _, _, @name2, _ = form_parameter_name_id_and_query({:to => ''}) end |
#render_calendar_filter_internal(params) ⇒ Object
:nodoc:
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/wice/columns/column_datetime.rb', line 50 def render_calendar_filter_internal(params) #:nodoc: calendar_data_from = prepare_data_for_calendar( :initial_date => params[:fr], :title => NlMessage['date_selector_tooltip_from'], :name => @name1, :fire_event => auto_reload, :grid_name => self.grid.name ) calendar_data_to = prepare_data_for_calendar( :initial_date => params[:to], :title => NlMessage['date_selector_tooltip_to'], :name => @name2, :fire_event => auto_reload, :grid_name => self.grid.name ) calendar_data_from.the_other_datepicker_id_to = calendar_data_to.dom_id calendar_data_to.the_other_datepicker_id_from = calendar_data_from.dom_id html1 = date_calendar_jquery calendar_data_from html2 = date_calendar_jquery calendar_data_to %!<div class="date-filter">#{html1}<br/>#{html2}</div>! end |
#render_filter_internal(params) ⇒ Object
:nodoc:
79 80 81 82 83 84 85 86 87 |
# File 'lib/wice/columns/column_datetime.rb', line 79 def render_filter_internal(params) #:nodoc: if helper_style == :standard prepare_for_standard_filter render_standard_filter_internal(params) else prepare_for_calendar_filter render_calendar_filter_internal(params) end end |
#render_standard_filter_internal(params) ⇒ Object
:nodoc:
43 44 45 46 47 48 |
# File 'lib/wice/columns/column_datetime.rb', line 43 def render_standard_filter_internal(params) #:nodoc: '<div class="date-filter">' + select_datetime(params[:fr], {:include_blank => true, :prefix => @name1}) + '<br/>' + select_datetime(params[:to], {:include_blank => true, :prefix => @name2}) + '</div>' end |
#yield_declaration_of_column_filter ⇒ Object
:nodoc:
90 91 92 93 94 95 |
# File 'lib/wice/columns/column_datetime.rb', line 90 def yield_declaration_of_column_filter #:nodoc: { :templates => @queris_ids.collect{|tuple| tuple[0] }, :ids => @queris_ids.collect{|tuple| tuple[1] } } end |