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

#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, #has_auto_reloading_input?, #has_auto_reloading_select?, #initialize, #render_filter, #yield_javascript

Constructor Details

This class inherits a constructor from Wice::ViewColumn

Instance Method Details

#has_auto_reloading_calendar?Boolean

:nodoc:

Returns:

  • (Boolean)


362
363
364
# File 'lib/view_columns.rb', line 362

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.



298
299
300
301
# File 'lib/view_columns.rb', line 298

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:



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

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:



305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/view_columns.rb', line 305

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:



335
336
337
338
339
340
341
342
343
# File 'lib/view_columns.rb', line 335

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},
    :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},
    :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:



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

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:



328
329
330
331
332
333
# File 'lib/view_columns.rb', line 328

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:



357
358
359
360
# File 'lib/view_columns.rb', line 357

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