Class: Wice::Columns::ViewColumnDatetime
- Inherits:
-
ViewColumn
- Object
- ViewColumn
- Wice::Columns::ViewColumnDatetime
- Includes:
- ActionView::Helpers::DateHelper, BsCalendarHelpers, JsCalendarHelpers
- Defined in:
- lib/wice/columns/column_datetime.rb
Overview
:nodoc:
Direct Known Subclasses
Constant Summary
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
- #chunk_names ⇒ Object
-
#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_bs_filter_internal(params) ⇒ Object
:nodoc:.
-
#render_calendar_filter_internal(params) ⇒ Object
:nodoc:.
-
#render_filter_internal(params) ⇒ Object
:nodoc:.
-
#render_html5_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 included from BsCalendarHelpers
#date_calendar_bs, #prepare_data_for_bscalendar
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
#chunk_names ⇒ Object
18 19 20 |
# File 'lib/wice/columns/column_datetime.rb', line 18 def chunk_names %w(year month day hour minute) end |
#has_auto_reloading_calendar? ⇒ Boolean
:nodoc:
141 142 143 |
# File 'lib/wice/columns/column_datetime.rb', line 141 def has_auto_reloading_calendar? #:nodoc: auto_reload && [:bootstrap, :calendar].include?(helper_style) 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:
37 38 39 40 41 42 |
# File 'lib/wice/columns/column_datetime.rb', line 37 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:
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/wice/columns/column_datetime.rb', line 22 def prepare_for_standard_filter #:nodoc: x = lambda{|sym| chunk_names.map{|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_bs_filter_internal(params) ⇒ Object
:nodoc:
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/wice/columns/column_datetime.rb', line 62 def render_bs_filter_internal(params) #:nodoc: calendar_data_from = prepare_data_for_bscalendar( initial_date: params[:fr], name: @name1, fire_event: auto_reload, grid_name: self.grid.name ) calendar_data_to = prepare_data_for_bscalendar( initial_date: params[: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_bs calendar_data_from html2 = date_calendar_bs calendar_data_to %!<div class="date-filter wg-bootstrap-datepicker">#{html1}#{html2}</div>! end |
#render_calendar_filter_internal(params) ⇒ Object
:nodoc:
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/wice/columns/column_datetime.rb', line 87 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 wg-jquery-datepicker">#{html1}<br/>#{html2}</div>! end |
#render_filter_internal(params) ⇒ Object
:nodoc:
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/wice/columns/column_datetime.rb', line 116 def render_filter_internal(params) #:nodoc: if helper_style == :standard prepare_for_standard_filter render_standard_filter_internal(params) elsif helper_style == :html5 prepare_for_calendar_filter render_html5_filter_internal(params) elsif helper_style == :bootstrap prepare_for_calendar_filter render_bs_filter_internal(params) else # :calendar prepare_for_calendar_filter render_calendar_filter_internal(params) end end |
#render_html5_filter_internal(params) ⇒ Object
:nodoc:
53 54 55 56 57 58 59 60 |
# File 'lib/wice/columns/column_datetime.rb', line 53 def render_html5_filter_internal(params) #:nodoc: css_class = 'form-control input-sm native-datepicker ' + (auto_reload ? 'auto-reload' : '') date_format = Wice::ConfigurationProvider.value_for(:DATE_FORMAT) '<div class="date-filter wg-html5-datepicker">' + date_field_tag(@name1, params[:fr].try(:strftime, date_format), {class: css_class, id: @dom_id}) + '<br/>' + date_field_tag(@name2, params[:to].try(:strftime, date_format), {class: css_class, id: @dom_id2}) + '</div>' end |
#render_standard_filter_internal(params) ⇒ Object
:nodoc:
45 46 47 48 49 50 |
# File 'lib/wice/columns/column_datetime.rb', line 45 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:
133 134 135 136 137 138 |
# File 'lib/wice/columns/column_datetime.rb', line 133 def yield_declaration_of_column_filter #:nodoc: { templates: @queris_ids.collect{|tuple| tuple[0] }, ids: @queris_ids.collect{|tuple| tuple[1] } } end |