class UiBibz::Ui::Ux::Tables::TableCard
Create a TableCard
This element is an extend of UiBibz::Ui::Core::Boxes::card.
Attributes¶ ↑
-
content
- Content of element -
options
- Options of element -
html_options
- Html Options of element
Options¶ ↑
You can add HTML attributes using the html_options
. You can pass arguments in options attribute:
-
store
-Store
generate by 'table_search_pagination
' method -
url
- String -
table_options
- Hash-
actionable
- Boolean -
sortable
- Boolean -
searchable
- Boolean -
status
(:inverse
) -
thead
- Hash (status
)(+inverse+, +default+)
-
bordered
- Boolean -
hoverable
- Boolean -
size
(sm
) -
responsive
- Boolean -
breakpoint
(:sm
,:md
,:lg
,:xl
,:xxl
)
-
Signatures¶ ↑
UiBibz::Ui::Ux::Tables::TableCard.new(store: @store) UiBibz::Ui::Ux::Tables::TableCard.new(store: @store) do |t| t.columns do |c| c.column '#', { data_index: '#' } end t.actions do |a| a.link '', url: url, glyph: '' end end
Examples¶ ↑
UiBibz::Ui::Ux::Tables::TableCard.new(store: @users, table_options: { actionable: false }).render UiBibz::Ui::Ux::Tables::TableCard.new(store: @users).tap do |t| t.header 'My Table card' t.columns do |c| c.column :id, { name: '# }, { class: 'column-id' } c.column :name_fr, { name: 'Name FR', link: edit_user_path(:id), order: 2 } c.column :name_en c.column :state_id, { name: 'state', format: lambda{ |records, record| "Test #{ record.id}"} } end t.actions do |a| a.link 'state', url: users_path(:id), glyph: 'eye' a.divider a.link 'momo', url: users_path(:id), glyph: 'home' end end.render
Helper¶ ↑
table_card(options = {}, html_options = {}) table_card(options = {}, html_options = {}) do |t| t.header(content, options = {}, html_options = {}) # or t.header(options = {}, html_options = {}) do content end t.body(content, options = {}, html_options = {}) # or t.body(options = {}, html_options = {}) do content end t.columns do |cls| cls.column(name, options = {}, html_options = {}) cls.column(options = {}, html_options = {}) do name end end t.actions do |acs| acs.action(name, options = {}, html_options = {}) acs.action(options = {}, html_options = {}) do content end end t.footer(content, options = {}, html_options = {}) # or t.footer(options = {}, html_options = {}) do content end end
Attributes
table[R]
Public Class Methods
new(content = nil, options = nil, html_options = nil, &block)
click to toggle source
See UiBibz::Ui::Core::Boxes::Card.initialize
Calls superclass method
UiBibz::Ui::Core::Boxes::Card::new
# File lib/ui_bibz/ui/ux/tables/table_card.rb, line 111 def initialize(content = nil, options = nil, html_options = nil, &block) super table_options = (@options[:table_options] || {}).merge({ store: store }) @table = UiBibz::Ui::Ux::Tables::Table.new(table_options, @options[:table_html_options]) end
Public Instance Methods
actions(&block)
click to toggle source
Add table actions item
# File lib/ui_bibz/ui/ux/tables/table_card.rb, line 138 def actions(&block) @table.actions(&block) end
actions_list()
click to toggle source
for test
# File lib/ui_bibz/ui/ux/tables/table_card.rb, line 143 def actions_list @table.actions_list end
columns(&block)
click to toggle source
Add table columns item
# File lib/ui_bibz/ui/ux/tables/table_card.rb, line 133 def columns(&block) @table.columns(&block) end
pre_render()
click to toggle source
Render html tag
# File lib/ui_bibz/ui/ux/tables/table_card.rb, line 118 def pre_render init_components content_tag :div, html_options do form_tag(url_for(url_parameters), method: :get) do store.parameters.with_indifferent_access.reject { |k, v| default_parameters?(k) || v.blank? }.each do |k, v| concat tag(:input, type: 'hidden', name: k, value: v) end concat tag(:input, type: 'hidden', name: 'store_id', value: store.id) unless store.id.nil? # if there is more one table in html page concat @items.join.html_safe end end end
Private Instance Methods
component_html_classes()
click to toggle source
# File lib/ui_bibz/ui/ux/tables/table_card.rb, line 149 def component_html_classes %w[card table-card] end
default_parameters?(key)
click to toggle source
# File lib/ui_bibz/ui/ux/tables/table_card.rb, line 166 def default_parameters?(key) %w[store_id per_page page search utf8 search controller action link_type].include?(key) end
init_components()
click to toggle source
# File lib/ui_bibz/ui/ux/tables/table_card.rb, line 160 def init_components @items << search.render if search.searchable? @items << table.render unless @store.nil? @items << pagination.render if pagination.paginable? end
pagination()
click to toggle source
# File lib/ui_bibz/ui/ux/tables/table_card.rb, line 184 def pagination @pagination ||= Paginable.new store, @options.merge({ wrap_form: false }), { class: 'card-footer' } end
search()
click to toggle source
# File lib/ui_bibz/ui/ux/tables/table_card.rb, line 180 def search @search ||= Searchable.new store, @options.merge({ wrap_form: false }), { class: 'card-header' } end
store()
click to toggle source
# File lib/ui_bibz/ui/ux/tables/table_card.rb, line 153 def store raise 'Store is nil!' if @options[:store].nil? raise 'Store can be created only with "table_search_pagination" method!' if @options[:store].try(:records).nil? @store ||= Store.new @options[:store] end
table_html()
click to toggle source
# File lib/ui_bibz/ui/ux/tables/table_card.rb, line 176 def table_html content_tag :div, @table.render, class: 'card-table' end
url_parameters()
click to toggle source
# File lib/ui_bibz/ui/ux/tables/table_card.rb, line 170 def url_parameters { controller: store.controller, action: store.action, id: store.param_id } end