Sha256: d1970c1bc33b68d757f98693bea9d29e772d1890a2a46722055fd8bbd2d5b2e3

Contents?: true

Size: 1.29 KB

Versions: 10

Compression:

Stored size: 1.29 KB

Contents

module UiBibz::Ui::Ux::Tables
  class Searchable < UiBibz::Ui::Base

    def initialize store, options, html_options = nil
      @store        = store
      @options      = options
      @html_options = html_options
    end

    # Render html tag
    def render
      content_tag :div, @html_options do
        concat content_tag(:div, table_name, class: 'title')
        concat TableSearchField.new({ store: @store, wrap_form: @options[:wrap_form] }).render if searchable?
        concat tag :br, class: 'ui-bibz-clear'
      end
    end

    def searchable?
      @options[:searchable].nil? ? true : @options[:searchable]
    end

  private

    def translate_searchable_attributes_by_active_record attr
      @store.model.human_attribute_name(attr)
    end

    def table_title
      if @options[:title] != false
        title = @options[:title] || "#{ @store.controller.humanize } list"
        UiBibz::Utils::Internationalization.new("ui_bibz.table.title.#{ model_name }", default: ["ui_bibz.table.title.defaults", title]).translate
      end
    end

    def model_name
      @store.model.to_s.underscore
    end

    def table_name
      "#{table_glyph}#{table_title}".html_safe
    end

    def table_glyph
      UiBibz::Ui::Core::Glyph.new(@options[:glyph]).render unless @options[:glyph].nil?
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ui_bibz-2.0.0.beta2.5 lib/ui_bibz/ui/ux/tables/extensions/searchable.rb
ui_bibz-2.0.0.beta2.4 lib/ui_bibz/ui/ux/tables/extensions/searchable.rb
ui_bibz-2.0.0.beta2.3 lib/ui_bibz/ui/ux/tables/extensions/searchable.rb
ui_bibz-2.0.0.beta2.2 lib/ui_bibz/ui/ux/tables/extensions/searchable.rb
ui_bibz-2.0.0.beta2.1 lib/ui_bibz/ui/ux/tables/extensions/searchable.rb
ui_bibz-2.0.0.beta2 lib/ui_bibz/ui/ux/tables/extensions/searchable.rb
ui_bibz-2.0.0.alpha32 lib/ui_bibz/ui/ux/tables/extensions/searchable.rb
ui_bibz-2.0.0.alpha31 lib/ui_bibz/ui/ux/tables/extensions/searchable.rb
ui_bibz-2.0.0.alpha30 lib/ui_bibz/ui/ux/tables/extensions/searchable.rb
ui_bibz-2.0.0.alpha29 lib/ui_bibz/ui/ux/tables/extensions/searchable.rb