On 08/02/2012 04:16 AM, Jozef Zigmund wrote:
On Thu, 2012-07-26 at 09:15 +0200, ifarkas(a)redhat.com wrote:
> From: Imre Farkas <ifarkas(a)redhat.com>
>
> ---
> src/app/helpers/application_helper.rb | 6 +--
> src/app/helpers/provider_accounts_helper.rb | 8 ----
> src/app/views/layouts/_filter_table.html.haml | 40 ++++++++++++++------
> src/app/views/layouts/_filter_table_form.html.haml | 25 ------------
> 4 files changed, 31 insertions(+), 48 deletions(-)
> delete mode 100644 src/app/views/layouts/_filter_table_form.html.haml
>
> diff --git a/src/app/helpers/application_helper.rb
b/src/app/helpers/application_helper.rb
> index 594bc86..6ddee96 100644
> --- a/src/app/helpers/application_helper.rb
> +++ b/src/app/helpers/application_helper.rb
> @@ -67,12 +67,10 @@ module ApplicationHelper
> end
> end
>
> - def filter_table(columns, rows, options = {}, form = nil, &block)
> + def filter_table(columns, rows, options = {}, &block)
> _class = rows.first.try(:class) || Object
> - render :partial => 'layouts/filter_table_form', :locals => {
> - :without_form => options[:without_form] || false,
> + render :partial => 'layouts/filter_table', :locals => {
> :form_header => options[:form_header] || :form_header,
> - :form => form,
> :filter_controls => options[:filter_controls] || :filter_controls,
> :form_footer => options[:form_footer] || :form_footer,
> :object_count => rows.count,
> diff --git a/src/app/helpers/provider_accounts_helper.rb
b/src/app/helpers/provider_accounts_helper.rb
> index 5ddf0d3..da6ae37 100644
> --- a/src/app/helpers/provider_accounts_helper.rb
> +++ b/src/app/helpers/provider_accounts_helper.rb
> @@ -17,14 +17,6 @@ module ProviderAccountsHelper
> def provider_accounts_header(options = {})
> columns = []
>
> - if !options[:without_checkbox] &&
(!options.has_key?(:with_checkbox_placeholder) || !options[:with_checkbox_placeholder])
> - columns << { :name => 'checkbox', :sortable => false,
:class => 'checkbox' }
> - end
> -
> - if options[:with_checkbox_placeholder]
> - columns << { :sortable => false }
> - end
> -
> unless options[:without_alert]
> columns << { :name => '', :sortable => false, :class
=> 'alert' }
> end
^ the table's headers are shifted, the checkbox column is forgotten
Nice catch during that early hour! ;-)
Thanks for the review!
> diff --git a/src/app/views/layouts/_filter_table.html.haml
b/src/app/views/layouts/_filter_table.html.haml
> index 71ae254..453266c 100644
> --- a/src/app/views/layouts/_filter_table.html.haml
> +++ b/src/app/views/layouts/_filter_table.html.haml
> @@ -1,12 +1,30 @@
> -%table.flat.checkbox_table{ 'data-none_selected' =>
t("default_none_selected_message"), 'data-confirm' =>
t("default_confirm_message") }
> - %thead
> - %tr
> - - columns.each do |column|
> - - if column[:name] == 'checkbox'
> - %th{:class => column[:class]}= check_box_tag :select_all, true, false,
:class => 'select_all'
> - -else
> - %th{:class => column[:class]}= column[:name]
> - - if !rows.any?
> += form_tag({}, :class => 'filterable-data') do
> +
> + - if content_for? filter_controls or content_for? form_header
> + %div.controls
> + %ul.filter-controls
> + = yield filter_controls if content_for? filter_controls
> +
> + - if content_for? form_header
> + %ul.actions
> + = yield form_header
> +
> + %table.flat.checkbox_table{ 'data-none_selected' =>
t("default_none_selected_message"), 'data-confirm' =>
t("default_confirm_message") }
> + %thead
> %tr
> - %td{:colspan => columns.size}= t('search.no_results')
> - = rows.collect {|row| capture_haml(row, &block)}.join.html_safe
> \ No newline at end of file
> + - columns.each do |column|
> + - if column[:name] == 'checkbox'
> + %th{:class => column[:class]}= check_box_tag :select_all, true,
false, :class => 'select_all'
> + -else
> + %th{:class => column[:class]}= column[:name]
> + - if !rows.any?
> + %tr
> + %td{:colspan => columns.size}= t('search.no_results')
> + = rows.collect {|row| capture_haml(row, &block)}.join.html_safe
> +
> + - if content_for? form_footer
> + %fieldset.options
> + = yield form_footer
> +
> +- if rows.is_a?(WillPaginate::Collection)
> + = render_pagination(rows)
> diff --git a/src/app/views/layouts/_filter_table_form.html.haml
b/src/app/views/layouts/_filter_table_form.html.haml
> deleted file mode 100644
> index 1d010a2..0000000
> --- a/src/app/views/layouts/_filter_table_form.html.haml
> +++ /dev/null
> @@ -1,25 +0,0 @@
> -- if form.present? || without_form
> - = render :partial => 'layouts/filter_table', :locals => { :columns
=> columns, :rows => rows, :block => block }
> -
> - - if rows.is_a?(WillPaginate::Collection)
> - = render_pagination(rows)
> -- else
> - = form_tag({}, :class => 'filterable-data') do
> -
> - - if content_for? filter_controls or content_for? form_header
> - %div.controls
> - %ul.filter-controls
> - = yield filter_controls if content_for? filter_controls
> -
> - - if content_for? form_header
> - %ul.actions
> - = yield form_header
> -
> - = render :partial => 'layouts/filter_table', :locals => { :columns
=> columns, :rows => rows, :block => block }
> -
> - - if content_for? form_footer
> - %fieldset.options
> - = yield form_footer
> -
> - - if rows.is_a?(WillPaginate::Collection)
> - = render_pagination(rows)