Module: Wice::BsCalendarHelpers

Included in:
Columns::ViewColumnBootstrapDatepicker
Defined in:
lib/wice/helpers/bs_calendar_helpers.rb

Overview

:nodoc:

Defined Under Namespace

Classes: CalendarData

Instance Method Summary collapse

Instance Method Details

#date_calendar_bs(calendar_data) ⇒ Object

:nodoc:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/wice/helpers/bs_calendar_helpers.rb', line 19

def date_calendar_bs(calendar_data)  #:nodoc:
  placeholder =
    if calendar_data.the_other_datepicker_id_to
      I18n.t("wice_grid.date_selector_tooltip_from")
    else
      I18n.t("wice_grid.date_selector_tooltip_to")
    end

  text_field_tag_options = {
      :id                   => calendar_data.dom_id,
      'data-provide'        => 'datepicker',
      'data-date-language'  => I18n.locale,
      'data-date-autoclose' => true,
      'data-date-format'    => Wice::ConfigurationProvider.value_for(:DATE_FORMAT_BOOTSTRAP),
      'placeholder'         => placeholder
  }

  text_field_tag_options['class'] = 'form-control input-sm'

  if Rails.env.development?
    text_field_tag_options['class'] += ' check-for-bsdatepicker'
  end

  if calendar_data.fire_event
    text_field_tag_options['data-close-calendar-event-name'] = calendar_data.close_calendar_event_name
  end

  if calendar_data.the_other_datepicker_id_to
    text_field_tag_options['data-the-other-bsdatepicker-id-to'] = calendar_data.the_other_datepicker_id_to
  end

  if calendar_data.the_other_datepicker_id_from
    text_field_tag_options['data-the-other-bsdatepicker-id-from'] = calendar_data.the_other_datepicker_id_from
  end

  date_picker = text_field_tag(calendar_data.name, calendar_data.date_string, text_field_tag_options)

  "<div id=\"#{calendar_data.datepicker_placeholder_id}\">#{date_picker}</div>"
end

#prepare_data_for_bscalendar(options) ⇒ Object

:nodoc:



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/wice/helpers/bs_calendar_helpers.rb', line 59

def prepare_data_for_bscalendar(options)  #:nodoc:
  date_format = Wice::ConfigurationProvider.value_for(:DATE_FORMAT)

  CalendarData.new.tap do |calendar_data|
    calendar_data.name                      = options[:name]
    calendar_data.date_string               = options[:initial_date].nil? ? '' : options[:initial_date].strftime(date_format)
    calendar_data.dom_id                    = options[:name].gsub(/([\[\(])|(\]\[)/, '_').gsub(/[\]\)]/, '').gsub(/\./, '_').gsub(/_+/, '_')
    calendar_data.datepicker_placeholder_id = calendar_data.dom_id + '_date_placeholder'
    calendar_data.date_div_id               = calendar_data.dom_id + '_date_view'
    calendar_data.close_calendar_event_name = "wg:calendarChanged_#{options[:grid_name]}"
    calendar_data.fire_event                = options[:fire_event]
  end
end