Sha256: 2ec14c037f411f7c6a6621042d74c616efa445cb7d80b9109bebd34818d59982

Contents?: true

Size: 1.22 KB

Versions: 34

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

class ClockPickerInput < SimpleForm::Inputs::StringInput
  # Note that where we use `wrapper: :clockpicker` or `wrapper: horizontal_clockpicker`,
  # #input is not called and we call #prefix_column and #input_column directly.
  def input(_wrapper_options)
    template.content_tag(:div, class: "row collapse #{class_name}-wrapper") do
      template.concat prefix_column
      template.concat input_column
    end
  end

  def prefix_column(_wrapper_options = {})
    template.content_tag(:div, class: "small-3 input-group-addon columns") do
      template.concat(icon_clock)
    end
  end

  def input_column(_wrapper_options = {})
    html_options = input_html_options
    html_options[:class] ||= []
    html_options[:class] << class_name
    template.content_tag(:div, class: "small-9 columns") do
      datestamp = @builder.object.public_send(attribute_name)
      value = datestamp.present? ? I18n.l(datestamp, format: :time) : ""
      template.concat @builder.text_field(attribute_name, html_options.merge(value: value))
    end
  end

  def icon_clock
    "<span class='prefix'><i class='fa fa-clock-o'></i></span>".html_safe
  end

  def input_type
    :string
  end

  def class_name
    "clockpicker"
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
renalware-core-2.0.53 app/inputs/clock_picker_input.rb
renalware-core-2.0.52 app/inputs/clock_picker_input.rb
renalware-core-2.0.51 app/inputs/clock_picker_input.rb
renalware-core-2.0.50 app/inputs/clock_picker_input.rb
renalware-core-2.0.48 app/inputs/clock_picker_input.rb
renalware-core-2.0.47 app/inputs/clock_picker_input.rb
renalware-core-2.0.46 app/inputs/clock_picker_input.rb
renalware-core-2.0.45 app/inputs/clock_picker_input.rb
renalware-core-2.0.44 app/inputs/clock_picker_input.rb
renalware-core-2.0.43 app/inputs/clock_picker_input.rb
renalware-core-2.0.42 app/inputs/clock_picker_input.rb
renalware-core-2.0.41 app/inputs/clock_picker_input.rb
renalware-core-2.0.40 app/inputs/clock_picker_input.rb
renalware-core-2.0.39 app/inputs/clock_picker_input.rb
renalware-core-2.0.38 app/inputs/clock_picker_input.rb
renalware-core-2.0.37 app/inputs/clock_picker_input.rb
renalware-core-2.0.36 app/inputs/clock_picker_input.rb
renalware-core-2.0.35 app/inputs/clock_picker_input.rb
renalware-core-2.0.34 app/inputs/clock_picker_input.rb
renalware-core-2.0.33 app/inputs/clock_picker_input.rb