Sha256: 65c229849ad8f3cd7e78afc1b60913f69a14373064553af38f6171735f468586

Contents?: true

Size: 934 Bytes

Versions: 14

Compression:

Stored size: 934 Bytes

Contents

module UiBibz::Ui::Ux::Tables

  # As
  #
  class As

    def initialize col, record, content, table_options
      @col     = col
      @record  = record
      @content = content
      @form    = table_options.try(:[], :form)
    end

    def render
      case @col.as
      when :boolean
        boolean_render
      when :progress
        progress_render
      when :input
        inp_options = (@col.input_options || {}).merge({ label: false })
        @form.input @col.data_index, inp_options
      end
    end

    private

    def boolean_render
      if @content == true
        glyph = UiBibz::Ui::Core::Icons::Glyph.new('check-circle', status: :success)
      else
        glyph = UiBibz::Ui::Core::Icons::Glyph.new('minus-circle', status: :danger)
      end
      glyph.render
    end

    def progress_render
      UiBibz::Ui::Core::Notifications::ProgressBar.new(@content, @col.progress_options).render
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ui_bibz-2.4.0 lib/ui_bibz/ui/ux/tables/components/as.rb
ui_bibz-2.3.15 lib/ui_bibz/ui/ux/tables/components/as.rb
ui_bibz-2.3.14 lib/ui_bibz/ui/ux/tables/components/as.rb
ui_bibz-2.3.13 lib/ui_bibz/ui/ux/tables/components/as.rb
ui_bibz-2.3.12 lib/ui_bibz/ui/ux/tables/components/as.rb
ui_bibz-2.3.11 lib/ui_bibz/ui/ux/tables/components/as.rb
ui_bibz-2.3.10 lib/ui_bibz/ui/ux/tables/components/as.rb
ui_bibz-2.3.9 lib/ui_bibz/ui/ux/tables/components/as.rb
ui_bibz-2.3.8 lib/ui_bibz/ui/ux/tables/components/as.rb
ui_bibz-2.3.7 lib/ui_bibz/ui/ux/tables/components/as.rb
ui_bibz-2.3.6 lib/ui_bibz/ui/ux/tables/components/as.rb
ui_bibz-2.3.5 lib/ui_bibz/ui/ux/tables/components/as.rb
ui_bibz-2.3.4 lib/ui_bibz/ui/ux/tables/components/as.rb
ui_bibz-2.3.3 lib/ui_bibz/ui/ux/tables/components/as.rb