Class: Wice::ViewColumnDatetime

Inherits:
ViewColumn show all
Includes:
ActionView::Helpers::DateHelper, JsCalendarHelpers
Defined in:
lib/view_columns.rb

Overview

:nodoc:

Direct Known Subclasses

ViewColumnDate

Constant Summary collapse

@@datetime_chunk_names =
%w(year month day hour minute)

Constants inherited from ViewColumn

Wice::ViewColumn::FIELDS

Instance Attribute Summary

Attributes inherited from ViewColumn

#cell_rendering_block, #contains_a_text_input, #css_class, #custom_filter, #grid, #main_table, #model_class, #table_name

Instance Method Summary collapse

Methods included from JsCalendarHelpers

#date_calendar_jquery, #date_calendar_prototype, #datetime_calendar_prototype

Methods inherited from ViewColumn

#attribute_name_fully_qualified_for_all_but_main_table_columns, #auto_reloading_input_with_negation_checkbox?, #capable_of_hosting_filter_related_icons?, #config, #controller, #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_javascript

Constructor Details

This class inherits a constructor from Wice::ViewColumn

Instance Method Details

#has_auto_reloading_calendar?Boolean

:nodoc:

Returns:

  • (Boolean)


384
385
386
# File 'lib/view_columns.rb', line 384

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.



320
321
322
323
# File 'lib/view_columns.rb', line 320

def name_and_id_from_options(options, type)  #:nodoc:
  options[:name] = (options[:prefix] || DEFAULT_PREFIX) + (options[:discard_type] ? '' : "[#{type}]")
  options[:id] = options[:name].gsub(/([\[\(])|(\]\[)/, '_').gsub(/[\]\)]/, '').gsub(/\./, '_').gsub(/_+/, '_')
end

#prepare_for_calendar_filterObject

:nodoc:



342
343
344
345
346
347
# File 'lib/view_columns.rb', line 342

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_filterObject

:nodoc:



327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/view_columns.rb', line 327

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:



357
358
359
360
361
362
363
364
365
# File 'lib/view_columns.rb', line 357

def render_calendar_filter_internal(params) #:nodoc:
  html1, js1 = datetime_calendar_prototype(params[:fr], @view,
    {:include_blank => true, :prefix => @name1, :id => @dom_id, :fire_event => auto_reload, :grid_name => self.grid.name},
    :title => WiceGridNlMessageProvider.get_message(:DATE_SELECTOR_TOOLTIP_FROM))
  html2, js2 = datetime_calendar_prototype(params[:to], @view,
    {:include_blank => true, :prefix => @name2, :id => @dom_id2, :fire_event => auto_reload, :grid_name => self.grid.name},
    :title => WiceGridNlMessageProvider.get_message(:DATE_SELECTOR_TOOLTIP_TO))
  [%!<div class="date-filter">#{html1}<br/>#{html2}</div>!, js1 + js2]
end

#render_filter_internal(params) ⇒ Object

:nodoc:



368
369
370
371
372
373
374
375
376
377
# File 'lib/view_columns.rb', line 368

def render_filter_internal(params) #:nodoc:
  # falling back to the Rails helpers for Datetime
  if helper_style == :standard || Defaults::JS_FRAMEWORK == :jquery
    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:



350
351
352
353
354
355
# File 'lib/view_columns.rb', line 350

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_filterObject

:nodoc:



379
380
381
382
# File 'lib/view_columns.rb', line 379

def yield_declaration_of_column_filter #:nodoc:
  %$templates : [ #{@queris_ids.collect{|tuple| "'" + tuple[0] + "'"}.join(', ')} ],
      ids : [ #{@queris_ids.collect{|tuple| "'" + tuple[1] + "'"}.join(', ')} ] $
end