Table Card(ui_table_card)
UiBibz::Ui::Ux::Tables::TableCard
The
table_card
component is a mix between a table and a card component.
Pagination and search are integrated to the component
The pagination is managed through the gem will_paginate.
The methods of `will_paginate` work with the
table
component such as
per_page
.
Usage
This component is an extension of component element. A Ui Bibz component consists of 3 arguments:
# by variable
ui_table_card options, html_options
# or by block tapped
ui_table_card options, html_options do |t|
t.columns do |cls|
cls.column data_index, options, html_options
end
t.actions do |acs|
acs.link content, options, html_options
end
end
Examples
Some examples explain how to use the options present in the component.View
The columns are all displayed by default and the default actions are :
- show
- edit
- delete
ui_table_card(store: @users)
<form action="/components/tables_cards" accept-charset="UTF-8" method="get">
<input name="utf8" type="hidden" value="✓">
<div class="card-header">
<div class="title">Components list</div>
<div class="input-group input-group-sm table-search-field">
<span class="input-group-addon"><i class="glyph fa fa-search"></i></span>
<input type="search" name="search" class="form-control" placeholder="Search by Name...">
<span class="clear-search-btn input-group-addon"><i class="glyph fa fa-times-circle"></i></span>
</div>
<br class="ui-bibz-clear">
</div>
<table class="table table-responsive">
<thead>
<tr>
<th>
<a class="dropup" href="/components/tables_cards?action=tables_cards&column_id=id&direction=asc&sort=users.id">Id</a>
</th>
<th>
<a class="dropup" href="/components/tables_cards?action=tables_cards&column_id=email&direction=asc&sort=users.email">Email</a>
</th>
<th>
<a class="dropup" href="/components/tables_cards?action=tables_cards&column_id=active&direction=asc&sort=users.active">Active</a>
</th>
<th>
<a class="dropup" href="/components/tables_cards?action=tables_cards&column_id=company&direction=asc&sort=users.company">Company</a>
</th>
<th>
<a class="dropup" href="/components/tables_cards?action=tables_cards&column_id=created_at&direction=asc&sort=users.created_at">Created At</a>
</th>
<th>
<a class="dropup" href="/components/tables_cards?action=tables_cards&column_id=updated_at&direction=asc&sort=users.updated_at">Updated At</a>
</th>
<th class="action"></th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>test0@test.com</td>
<td>true</td>
<td>Company test 6646</td>
<td>2015-09-04 08:24:05 UTC</td>
<td>2015-09-04 08:24:05 UTC</td>
<td>
<div class="dropdown-action btn-group dropdown" role="group">
<button class="btn btn-primary btn-xs dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="glyph fa fa-ellipsis-v fa-fw"></i> Actions <span class="caret"></span></button>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="#show"><i class="glyph fa fa-eye"></i> Show</a>
<a class="dropdown-item" href="#show"><i class="glyph fa fa-pencil-alt"></i> Edit</a>
<a class="dropdown-item" data-confirm="Are you sure?" href="#show"><i class="glyph fa fa-trash"></i> Delete</a>
</div>
</div>
</td>
</tr>
</tbody>
</table>
<div class="card-footer">
<ul class="pagination pagination">
<li class="prev disabled"><span>← Previous</span></li>
<li class="active"><span>1</span></li>
<li><a rel="next" href="/components/tables_cards?page=2">2</a></li>
<li><a href="/components/tables_cards?page=3">3</a></li>
<li><a href="/components/tables_cards?page=4">4</a></li>
<li><a href="/components/tables_cards?page=5">5</a></li>
<li><a href="/components/tables_cards?page=6">6</a></li>
<li><a href="/components/tables_cards?page=7">7</a></li>
<li><a href="/components/tables_cards?page=8">8</a></li>
<li><a href="/components/tables_cards?page=9">9</a></li>
<li class="disabled"><span>…</span></li>
<li><a href="/components/tables_cards?page=29">29</a></li>
<li><a href="/components/tables_cards?page=30">30</a></li>
<li class="next"><a rel="next" href="/components/tables_cards?page=2">Next →</a></li>
</ul>
<input name="utf8" type="hidden" value="✓">
<div class="table-pagination-per-page">
Displaying User <b>1 - 5</b> of <b>150</b> in total | Per page: <select name="per_page" id="per_page" class="form-control">
<option selected="selected" value="5">5</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="200">200</option>
<option value="500">500</option>
</select>
</div>
<br class="ui-bibz-clear">
</div>
</form>
Table card Options
Table has several options:
Table card Blocks
Table has several blocks:
- columns
- actions