Sha256: ab6d361117fb81f6e2c70f86ac18c780cd80fca464188935f1872b19fef9d629

Contents?: true

Size: 1009 Bytes

Versions: 7

Compression:

Stored size: 1009 Bytes

Contents

module LatoCore

  class Inputs::Datetime::Cell < Cell

    @@requested_args = [:name]

    @@default_args = {
      value: '',
      label: '',
      placeholder: '',
      help: '',
      required: false,
      disabled: false,
      class: 'md-12'
    }

    def initialize(args = {})
      @args = validate_args(
        args: args,
        requested_args: @@requested_args,
        default_args: @@default_args
      )

      set_conditions
    end

    def show
      render 'show.html'
    end

    private

    def set_conditions
      @show_label = !@args[:label].nil? && !@args[:label].blank?
      @show_help = !@args[:help].nil? && !@args[:help].blank?

      @value = generate_value
    end

    # This function generate the value for the input if it is possible.
    def generate_value
      return unless @args[:value]

      if @args[:value].is_a?(DateTime) || @args[:value].is_a?(Time)
        return @args[:value].strftime('%d/%m/%Y %H:%M')
      end

      @args[:value]
    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lato_core-2.2.2 app/cells/lato_core/inputs/datetime/cell.rb
lato_core-2.2.0 app/cells/lato_core/inputs/datetime/cell.rb
lato_core-2.1.4 app/cells/lato_core/inputs/datetime/cell.rb
lato_core-2.1.3 app/cells/lato_core/inputs/datetime/cell.rb
lato_core-2.1.2 app/cells/lato_core/inputs/datetime/cell.rb
lato_core-2.1.1 app/cells/lato_core/inputs/datetime/cell.rb
lato_core-2.1 app/cells/lato_core/inputs/datetime/cell.rb