From a3373b019cb7db979daf5cb65f3b6ec95a27e6a6 Mon Sep 17 00:00:00 2001 From: Felix Van der Jeugt Date: Thu, 10 Sep 2015 14:35:17 +0200 Subject: [PATCH] convert datagrid partials to haml --- app/views/datagrid/_enum_checkboxes.html.erb | 11 ----------- app/views/datagrid/_enum_checkboxes.html.haml | 5 +++++ app/views/datagrid/_form.html.erb | 14 -------------- app/views/datagrid/_form.html.haml | 9 +++++++++ app/views/datagrid/_head.html.erb | 8 -------- app/views/datagrid/_head.html.haml | 5 +++++ app/views/datagrid/_order_for.html.erb | 10 ---------- app/views/datagrid/_order_for.html.haml | 9 +++++++++ app/views/datagrid/_range_filter.html.erb | 3 --- app/views/datagrid/_range_filter.html.haml | 3 +++ app/views/datagrid/_row.html.erb | 5 ----- app/views/datagrid/_row.html.haml | 3 +++ app/views/datagrid/_table.html.erb | 18 ------------------ app/views/datagrid/_table.html.haml | 9 +++++++++ 14 files changed, 43 insertions(+), 69 deletions(-) delete mode 100644 app/views/datagrid/_enum_checkboxes.html.erb create mode 100644 app/views/datagrid/_enum_checkboxes.html.haml delete mode 100644 app/views/datagrid/_form.html.erb create mode 100644 app/views/datagrid/_form.html.haml delete mode 100644 app/views/datagrid/_head.html.erb create mode 100644 app/views/datagrid/_head.html.haml delete mode 100644 app/views/datagrid/_order_for.html.erb create mode 100644 app/views/datagrid/_order_for.html.haml delete mode 100644 app/views/datagrid/_range_filter.html.erb create mode 100644 app/views/datagrid/_range_filter.html.haml delete mode 100644 app/views/datagrid/_row.html.erb create mode 100644 app/views/datagrid/_row.html.haml delete mode 100644 app/views/datagrid/_table.html.erb create mode 100644 app/views/datagrid/_table.html.haml diff --git a/app/views/datagrid/_enum_checkboxes.html.erb b/app/views/datagrid/_enum_checkboxes.html.erb deleted file mode 100644 index 929d29c..0000000 --- a/app/views/datagrid/_enum_checkboxes.html.erb +++ /dev/null @@ -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 -%> diff --git a/app/views/datagrid/_enum_checkboxes.html.haml b/app/views/datagrid/_enum_checkboxes.html.haml new file mode 100644 index 0000000..330234e --- /dev/null +++ b/app/views/datagrid/_enum_checkboxes.html.haml @@ -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 diff --git a/app/views/datagrid/_form.html.erb b/app/views/datagrid/_form.html.erb deleted file mode 100644 index 6db075c..0000000 --- a/app/views/datagrid/_form.html.erb +++ /dev/null @@ -1,14 +0,0 @@ -<%= form_for grid, options do |f| -%> - <% grid.filters.each do |filter| %> -
- <%= f.datagrid_label filter %> - <%= f.datagrid_filter filter, partials: options[:partials] %> -
- <% end %> -
- <%= 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" %> -
-<% end -%> diff --git a/app/views/datagrid/_form.html.haml b/app/views/datagrid/_form.html.haml new file mode 100644 index 0000000..4c337d1 --- /dev/null +++ b/app/views/datagrid/_form.html.haml @@ -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" diff --git a/app/views/datagrid/_head.html.erb b/app/views/datagrid/_head.html.erb deleted file mode 100644 index e939128..0000000 --- a/app/views/datagrid/_head.html.erb +++ /dev/null @@ -1,8 +0,0 @@ - - <% grid.html_columns(*options[:columns]).each do |column| %> - - <%= column.header %> - <%= datagrid_order_for(grid, column, options) if column.supports_order? && options[:order]%> - - <% end %> - diff --git a/app/views/datagrid/_head.html.haml b/app/views/datagrid/_head.html.haml new file mode 100644 index 0000000..072ea6a --- /dev/null +++ b/app/views/datagrid/_head.html.haml @@ -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] diff --git a/app/views/datagrid/_order_for.html.erb b/app/views/datagrid/_order_for.html.erb deleted file mode 100644 index 1b0c42d..0000000 --- a/app/views/datagrid/_order_for.html.erb +++ /dev/null @@ -1,10 +0,0 @@ -
- <%= 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") %> -
diff --git a/app/views/datagrid/_order_for.html.haml b/app/views/datagrid/_order_for.html.haml new file mode 100644 index 0000000..3203c39 --- /dev/null +++ b/app/views/datagrid/_order_for.html.haml @@ -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") | diff --git a/app/views/datagrid/_range_filter.html.erb b/app/views/datagrid/_range_filter.html.erb deleted file mode 100644 index 2bfba44..0000000 --- a/app/views/datagrid/_range_filter.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -<%= form.text_field(filter.name, from_options) %> - - -<%= form.text_field(filter.name, to_options) %> diff --git a/app/views/datagrid/_range_filter.html.haml b/app/views/datagrid/_range_filter.html.haml new file mode 100644 index 0000000..7ab4337 --- /dev/null +++ b/app/views/datagrid/_range_filter.html.haml @@ -0,0 +1,3 @@ += form.text_field(filter.name, from_options) +%span{:class => "separator #{filter.type}"} - += form.text_field(filter.name, to_options) diff --git a/app/views/datagrid/_row.html.erb b/app/views/datagrid/_row.html.erb deleted file mode 100644 index ab07133..0000000 --- a/app/views/datagrid/_row.html.erb +++ /dev/null @@ -1,5 +0,0 @@ - - <% grid.html_columns(*options[:columns]).each do |column| %> - <%= datagrid_value(grid, column, asset) %> - <% end %> - diff --git a/app/views/datagrid/_row.html.haml b/app/views/datagrid/_row.html.haml new file mode 100644 index 0000000..cc0b25f --- /dev/null +++ b/app/views/datagrid/_row.html.haml @@ -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) diff --git a/app/views/datagrid/_table.html.erb b/app/views/datagrid/_table.html.erb deleted file mode 100644 index 4b6b827..0000000 --- a/app/views/datagrid/_table.html.erb +++ /dev/null @@ -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 %> - - <%= datagrid_header(grid, options) %> - - - <% if assets.any? %> - <%= datagrid_rows(grid, assets, options) %> - <% else %> - <%= I18n.t('datagrid.no_results').html_safe %> - <% end %> - -<% end %> diff --git a/app/views/datagrid/_table.html.haml b/app/views/datagrid/_table.html.haml new file mode 100644 index 0000000..59f32da --- /dev/null +++ b/app/views/datagrid/_table.html.haml @@ -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