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 .

Important
To add, update, remove columns or actions in the component table you must add the option tap: true.

Usage

This component is an extension of component element. A Ui Bibz component consists of 3 arguments:
  • content[value/block]
  • options[hash]<default: {}>
  • html_options[hash]<default: {}>

# by variable
ui_table_card options, html_options

# or by block with tap
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

Options

The specific options for this component are:
  • glyph[string/hash](use component glyph method)
  • table_options[hash]
  • tap[boolean]Required (if you want add header, body or footer item.)
  • store[object]Required
  • searchable[boolean]
  • paginable[boolean]
  • title[string]
  • table_html_options[hash]
  • cache[string](use to cache your component)
  • controller[string](use component stimulus-options method)
  • action[string](use component stimulus-options method)
  • target[string](use component stimulus-options method)

Items

The allowed items for this component are:

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
Components/tables list

IdEmailActiveCompanyCreated AtUpdated At
4test3@test.comtrueCompany test 13792017-10-30 13:52:28 UTC2017-10-30 13:52:28 UTC
8test7@test.comtrueCompany test 36222017-10-30 13:52:28 UTC2017-10-30 13:52:28 UTC
9test8@test.comtrueCompany test 44262017-10-30 13:52:28 UTC2017-10-30 13:52:28 UTC
ui_table_card({ store: @users, tap: true })
<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">
    <thead>
      <tr>
        <th>
          <a class="dropup" href="/components/tables_cards?action=tables_cards&amp;column_id=id&amp;direction=asc&amp;sort=users.id">Id</a>
        </th>
        <th>
          <a class="dropup" href="/components/tables_cards?action=tables_cards&amp;column_id=email&amp;direction=asc&amp;sort=users.email">Email</a>
        </th>
        <th>
          <a class="dropup" href="/components/tables_cards?action=tables_cards&amp;column_id=active&amp;direction=asc&amp;sort=users.active">Active</a>
        </th>
        <th>
          <a class="dropup" href="/components/tables_cards?action=tables_cards&amp;column_id=company&amp;direction=asc&amp;sort=users.company">Company</a>
        </th>
        <th>
          <a class="dropup" href="/components/tables_cards?action=tables_cards&amp;column_id=created_at&amp;direction=asc&amp;sort=users.created_at">Created At</a>
        </th>
        <th>
          <a class="dropup" href="/components/tables_cards?action=tables_cards&amp;column_id=updated_at&amp;direction=asc&amp;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-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&nbsp;-&nbsp;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:

  • glyph[string/hash](use component glyph method)
  • store[object]Required
  • table_options[hash]
  • searchable[boolean]
  • paginable[boolean]
  • title[string]
  • table_html_options[hash]

Table card Blocks

Table has several blocks:

  • columns
  • actions