Class: UiBibz::Ui::Ux::Tables::Table
- Inherits:
-
Core::Component
- Object
- Base
- Core::Component
- UiBibz::Ui::Ux::Tables::Table
- Defined in:
- lib/ui_bibz/ui/ux/tables/table.rb
Overview
Create a Table
This element is an extend of UiBibz::Ui::Core::Component.
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 -
actionable
- Boolean -
sortable
- Boolean -
searchable
- Boolean -
default_actions
- Boolean -
status
(:inverse
,:default
,:success
,:primary
,:secondary
,:info
,:danger
,:warning
) -
thead
- Hash (status
)(+:inverse+, +:default+)
-
bordered
- Boolean -
hoverable
- Boolean -
size
(:sm
) -
responsive
- Boolean -
breakpoint
(:sm
,:md
,:lg
,:xl
,:xxl
)
Signatures
UiBibz::Ui::Ux::Tables::Table.new(store: @store)
UiBibz::Ui::Ux::Tables::Table.new(store: @store) do |t|
t.columns do |c|
c.column :id, name: '#'
end
t.actions do |a|
a.link '', url: url, glyph: ''
end
end
Examples
UiBibz::Ui::Ux::Tables::Table.new(store: @users).render
UiBibz::Ui::Ux::Tables::Table.new(store: @users).tap do |t|
t.columns do |c|
c.column :id, { name: '#' }
c.column :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( = {}, = {})
table( = {}, = {}) do |t|
t.columns do |cls|
cls.column(name, = {}, = {})
cls.column( = {}, = {}) do
name
end
end
t.actions do |acs|
acs.link(content, = {}, = {})
acs.link( = {}, = {}) do
content
end
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 items.
-
#actions_list ⇒ Object
for test.
-
#columns(&block) ⇒ Object
Add table columns items.
-
#initialize(content = nil, options = nil, html_options = nil, &block) ⇒ Table
constructor
See UiBibz::Ui::Core::Component.initialize.
-
#pre_render ⇒ Object
Render html tag.
-
#store ⇒ Object
Store must be generated by table_search_pagination method.
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
Methods inherited from Base
#generate_id, #i18n_set?, #inject_url
Constructor Details
#initialize(content = nil, options = nil, html_options = nil, &block) ⇒ Table
See UiBibz::Ui::Core::Component.initialize
99 100 101 102 103 |
# File 'lib/ui_bibz/ui/ux/tables/table.rb', line 99 def initialize(content = nil, = nil, = nil, &block) super @columns = Columns.new @actions = Actions.new store end |
Instance Method Details
#actions(&block) ⇒ Object
Add table actions items
111 112 113 |
# File 'lib/ui_bibz/ui/ux/tables/table.rb', line 111 def actions(&block) @actions.tap(&block) end |
#actions_list ⇒ Object
for test
116 117 118 |
# File 'lib/ui_bibz/ui/ux/tables/table.rb', line 116 def actions_list @actions end |
#columns(&block) ⇒ Object
Add table columns items
106 107 108 |
# File 'lib/ui_bibz/ui/ux/tables/table.rb', line 106 def columns(&block) @columns.tap(&block) end |
#pre_render ⇒ Object
Render html tag
121 122 123 |
# File 'lib/ui_bibz/ui/ux/tables/table.rb', line 121 def pre_render [:responsive] ? content_tag(:div, table_html, class: responsive) : table_html end |
#store ⇒ Object
Store must be generated by table_search_pagination method
126 127 128 129 130 131 |
# File 'lib/ui_bibz/ui/ux/tables/table.rb', line 126 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 |