add datagrid partials to allow pretty tables
This commit is contained in:
parent
b2936f7645
commit
870fb16f00
7 changed files with 69 additions and 0 deletions
11
app/views/datagrid/_enum_checkboxes.html.erb
Normal file
11
app/views/datagrid/_enum_checkboxes.html.erb
Normal file
|
@ -0,0 +1,11 @@
|
|||
<%#
|
||||
Indent in this file may cause extra space to appear.
|
||||
You can add indent if whitespace doesn't matter for you
|
||||
%>
|
||||
<%- elements.each do |value, text, checked| -%>
|
||||
<%- id = [form.object_name, filter.name, value].join('_').underscore -%>
|
||||
<%= form.label filter.name, options.merge(:for => id) do -%>
|
||||
<%= form.check_box(filter.name, form.datagrid_extra_checkbox_options.merge(:multiple => true, :id => id, :checked => checked), value.to_s, nil) -%>
|
||||
<%= text -%>
|
||||
<%- end -%>
|
||||
<%- end -%>
|
14
app/views/datagrid/_form.html.erb
Normal file
14
app/views/datagrid/_form.html.erb
Normal file
|
@ -0,0 +1,14 @@
|
|||
<%= form_for grid, options do |f| -%>
|
||||
<% grid.filters.each do |filter| %>
|
||||
<div class="datagrid-filter filter">
|
||||
<%= f.datagrid_label filter %>
|
||||
<%= f.datagrid_filter filter, partials: options[:partials] %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="datagrid-actions">
|
||||
<%= f.submit I18n.t("datagrid.form.search").html_safe, :class => "datagrid-submit" %>
|
||||
<%# https://github.com/rails/rails/pull/14949 -%>
|
||||
<% empty_parameter = Rails.version >= "4.1.0" && Rails.version <= '4.1.2' ? nil : {}-%>
|
||||
<%= link_to I18n.t('datagrid.form.reset').html_safe, url_for(grid.to_param => empty_parameter), :class => "datagrid-reset" %>
|
||||
</div>
|
||||
<% end -%>
|
8
app/views/datagrid/_head.html.erb
Normal file
8
app/views/datagrid/_head.html.erb
Normal file
|
@ -0,0 +1,8 @@
|
|||
<tr>
|
||||
<% grid.html_columns(*options[:columns]).each do |column| %>
|
||||
<th class="<%= datagrid_column_classes(grid, column) %>">
|
||||
<%= column.header %>
|
||||
<%= datagrid_order_for(grid, column, options) if column.supports_order? && options[:order]%>
|
||||
</th>
|
||||
<% end %>
|
||||
</tr>
|
10
app/views/datagrid/_order_for.html.erb
Normal file
10
app/views/datagrid/_order_for.html.erb
Normal file
|
@ -0,0 +1,10 @@
|
|||
<div class="order">
|
||||
<%= link_to(
|
||||
I18n.t("datagrid.table.order.asc").html_safe,
|
||||
url_for(grid.param_name => grid.as_query.merge(:order => column.name, :descending => false)),
|
||||
:class => "asc") %>
|
||||
<%= link_to(
|
||||
I18n.t("datagrid.table.order.desc").html_safe,
|
||||
url_for(grid.param_name => grid.as_query.merge(:order => column.name, :descending => true )),
|
||||
:class => "desc") %>
|
||||
</div>
|
3
app/views/datagrid/_range_filter.html.erb
Normal file
3
app/views/datagrid/_range_filter.html.erb
Normal file
|
@ -0,0 +1,3 @@
|
|||
<%= form.text_field(filter.name, from_options) %>
|
||||
<span class="separator <%= filter.type %>"> - </span>
|
||||
<%= form.text_field(filter.name, to_options) %>
|
5
app/views/datagrid/_row.html.erb
Normal file
5
app/views/datagrid/_row.html.erb
Normal file
|
@ -0,0 +1,5 @@
|
|||
<tr class="<%= options[:cycle] && cycle(*options[:cycle]) %>">
|
||||
<% grid.html_columns(*options[:columns]).each do |column| %>
|
||||
<td class="<%= datagrid_column_classes(grid, column) %>"><%= datagrid_value(grid, column, asset) %></td>
|
||||
<% end %>
|
||||
</tr>
|
18
app/views/datagrid/_table.html.erb
Normal file
18
app/views/datagrid/_table.html.erb
Normal file
|
@ -0,0 +1,18 @@
|
|||
<%#
|
||||
Local variables:
|
||||
* grid - instance of Datagrid
|
||||
* assets - Array of database Entities
|
||||
* options - passed options Hash
|
||||
%>
|
||||
<%= content_tag :table, options[:html] do %>
|
||||
<thead>
|
||||
<%= datagrid_header(grid, options) %>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if assets.any? %>
|
||||
<%= datagrid_rows(grid, assets, options) %>
|
||||
<% else %>
|
||||
<tr><td class="noresults" colspan="100%"><%= I18n.t('datagrid.no_results').html_safe %></td></tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
<% end %>
|
Loading…
Reference in a new issue