Class: UiBibz::Ui::Ux::Tables::TableCard
- Inherits:
-
Core::Boxes::Card
- Object
- Base
- Core::Component
- Core::Boxes::Card
- UiBibz::Ui::Ux::Tables::TableCard
- Includes:
- Concerns::HtmlConcern
- Defined in:
- lib/ui_bibz/ui/ux/tables/table_card.rb
Overview
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( = {}, = {})
table_card( = {}, = {}) do |t|
t.header(content, = {}, = {})
# or
t.header( = {}, = {}) do
content
end
t.body(content, = {}, = {})
# or
t.body( = {}, = {}) do
content
end
t.columns do |cls|
cls.column(name, = {}, = {})
cls.column( = {}, = {}) do
name
end
end
t.actions do |acs|
acs.action(name, = {}, = {})
acs.action( = {}, = {}) do
content
end
end
t.(content, = {}, = {})
# or
t.( = {}, = {}) do
content
end
end
Constant Summary
Constants inherited from Core::Component
Core::Component::BREAKPOINTS, Core::Component::SIZES, Core::Component::STATUSES
Instance Attribute Summary
Attributes inherited from Core::Component
#content, #html_options, #options
Attributes inherited from Base
Instance Method Summary collapse
-
#actions(&block) ⇒ Object
Add table actions item.
-
#actions_list ⇒ Object
for test.
-
#columns(&block) ⇒ Object
Add table columns item.
-
#initialize(content = nil, options = nil, html_options = nil, &block) ⇒ TableCard
constructor
See UiBibz::Ui::Core::Boxes::Card.initialize.
-
#pre_render ⇒ Object
Render html tag.
Methods inherited from Core::Component
Methods included from PopoverExtension
#popover_data_html, #tooltip_data_html
Methods included from GlyphExtension
#generate_glyph, #glyph_and_content_html
Methods included from KlassExtension
#exclude_classes, #exclude_classes_in_html_options, #join_classes, #status
Methods inherited from Base
#generate_id, #i18n_set?, #inject_url
Constructor Details
#initialize(content = nil, options = nil, html_options = nil, &block) ⇒ TableCard
See UiBibz::Ui::Core::Boxes::Card.initialize
111 112 113 114 115 |
# File 'lib/ui_bibz/ui/ux/tables/table_card.rb', line 111 def initialize(content = nil, = nil, = nil, &block) super = (@options[:table_options] || {}).merge({ store: store }) @table = UiBibz::Ui::Ux::Tables::Table.new(, @options[:table_html_options]) end |
Instance Method Details
#actions(&block) ⇒ Object
Add table actions item
138 139 140 |
# File 'lib/ui_bibz/ui/ux/tables/table_card.rb', line 138 def actions(&block) @table.actions(&block) end |
#actions_list ⇒ Object
for test
143 144 145 |
# File 'lib/ui_bibz/ui/ux/tables/table_card.rb', line 143 def actions_list @table.actions_list end |
#columns(&block) ⇒ Object
Add table columns item
133 134 135 |
# File 'lib/ui_bibz/ui/ux/tables/table_card.rb', line 133 def columns(&block) @table.columns(&block) end |
#pre_render ⇒ Object
Render html tag
118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/ui_bibz/ui/ux/tables/table_card.rb', line 118 def pre_render init_components content_tag :div, 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 |