convert datagrid partials to haml
This commit is contained in:
parent
06e3a5821e
commit
a3373b019c
14 changed files with 43 additions and 69 deletions
|
@ -1,11 +0,0 @@
|
||||||
<%#
|
|
||||||
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 -%>
|
|
5
app/views/datagrid/_enum_checkboxes.html.haml
Normal file
5
app/views/datagrid/_enum_checkboxes.html.haml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
- 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
|
|
@ -1,14 +0,0 @@
|
||||||
<%= 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 -%>
|
|
9
app/views/datagrid/_form.html.haml
Normal file
9
app/views/datagrid/_form.html.haml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
= form_for grid, options do |f|
|
||||||
|
- grid.filters.each do |filter|
|
||||||
|
.datagrid-filter.filter
|
||||||
|
= f.datagrid_label filter
|
||||||
|
= f.datagrid_filter filter, partials: options[:partials]
|
||||||
|
.datagrid-actions
|
||||||
|
= f.submit I18n.t("datagrid.form.search").html_safe, :class => "datagrid-submit"
|
||||||
|
- 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"
|
|
@ -1,8 +0,0 @@
|
||||||
<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>
|
|
5
app/views/datagrid/_head.html.haml
Normal file
5
app/views/datagrid/_head.html.haml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
%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]
|
|
@ -1,10 +0,0 @@
|
||||||
<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>
|
|
9
app/views/datagrid/_order_for.html.haml
Normal file
9
app/views/datagrid/_order_for.html.haml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
.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") |
|
|
@ -1,3 +0,0 @@
|
||||||
<%= form.text_field(filter.name, from_options) %>
|
|
||||||
<span class="separator <%= filter.type %>"> - </span>
|
|
||||||
<%= form.text_field(filter.name, to_options) %>
|
|
3
app/views/datagrid/_range_filter.html.haml
Normal file
3
app/views/datagrid/_range_filter.html.haml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
= form.text_field(filter.name, from_options)
|
||||||
|
%span{:class => "separator #{filter.type}"} -
|
||||||
|
= form.text_field(filter.name, to_options)
|
|
@ -1,5 +0,0 @@
|
||||||
<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>
|
|
3
app/views/datagrid/_row.html.haml
Normal file
3
app/views/datagrid/_row.html.haml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
%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)
|
|
@ -1,18 +0,0 @@
|
||||||
<%#
|
|
||||||
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 %>
|
|
9
app/views/datagrid/_table.html.haml
Normal file
9
app/views/datagrid/_table.html.haml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
= content_tag :table, options[:html] do
|
||||||
|
%thead
|
||||||
|
= datagrid_header(grid, options)
|
||||||
|
%tbody
|
||||||
|
- if assets.any?
|
||||||
|
= datagrid_rows(grid, assets, options)
|
||||||
|
- else
|
||||||
|
%tr
|
||||||
|
%td.noresults{:colspan => "100%"}= I18n.t('datagrid.no_results').html_safe
|
Loading…
Reference in a new issue