Sha256: 9868e3a958efce9c59abdd33fab0ab1d4611559647406613aab4aebccd997190

Contents?: true

Size: 1.96 KB

Versions: 5

Compression:

Stored size: 1.96 KB

Contents

<% exceptions ||= ['id', 'created_at', 'updated_at', 'deleted_at'] %>
<% excluded_columns ||= [] %>
<% hide_actions ||= false %>
<% sort_fields ||= [] %>

<table class="table table-striped datatables">
  <thead>
    <tr>
      <% unless list.empty? %>
        <% (list.first.class.column_names - exceptions - excluded_columns).each do |column| %>
          <% if sort_fields.include? column %>
            <% if /_id$/ =~ column %>
              <th><%= sort_link(@q, column, list.first.class.human_attribute_name(column.split("_id")[0])) %></th>
            <% else %>
              <th><%= sort_link(@q, column, list.first.class.human_attribute_name(column)) %></th>
            <% end %>
          <% else %>
            <% if /_id$/ =~ column %>
              <th><%= list.first.class.human_attribute_name(column.split("_id")[0]) %></th>
            <% else %>
              <th><%= list.first.class.human_attribute_name(column) %></th>
            <% end %>
          <% end %>
        <% end %>
        <% unless hide_actions %>
          <th>Ações</th>
        <% end %>
      <% end %>
    </tr>
  </thead>
  <tbody>
    <% list.each do |object| %>
    <tr>
      <% (list.first.class.column_names - exceptions - excluded_columns).each do |column| %>
      <td>
        <% if object.send(column).class == Date or
          object.send(column).class == DateTime or
          object.send(column).class == ActiveSupport::TimeWithZone or
          object.send(column).class == Time %>
          <%=l object.send(column) %>
        <% elsif /_id$/ =~ column && object.respond_to?(column.split('_id')[0]) %>
          <%= object.send(column.split("_id")[0]).name %>
        <% else %>
          <%= object.send(column) %>
        <% end %>
      </td>
      <% end %>
      <% unless hide_actions %>
        <td>
          <%= render 'shared/action_links', object: object %>
        </td>
      <% end %>
    </tr>
    <% end %>
  </tbody>
</table>

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
zutils-0.1.4 app/views/shared/_list.html.erb
zutils-0.1.3 app/views/shared/_list.html.erb
zutils-0.1.2 app/views/shared/_list.html.erb
zutils-0.1.1 app/views/shared/_list.html.erb
zutils-0.1.0 app/views/shared/_list.html.erb