diff --git a/app/controllers/admin/reports_controller.rb b/app/controllers/admin/reports_controller.rb index f7505208ec..1e1ff30314 100644 --- a/app/controllers/admin/reports_controller.rb +++ b/app/controllers/admin/reports_controller.rb @@ -46,6 +46,7 @@ module Admin # Initialize data params[:display_summary_row] = true if request.get? + params[:fields_to_show] = @report.columns.keys if request.get? @data = Reporting::FrontendData.new(spree_current_user) end diff --git a/app/views/admin/reports/_rendering_options.html.haml b/app/views/admin/reports/_rendering_options.html.haml index 88f58c04c6..2ab2856d92 100644 --- a/app/views/admin/reports/_rendering_options.html.haml +++ b/app/views/admin/reports/_rendering_options.html.haml @@ -19,9 +19,9 @@ - if @report.available_headers.present? .row - .alpha.two.columns= label_tag nil, t(:report_hide_columns) + .alpha.two.columns= label_tag nil, t(:report_columns) .omega.fourteen.columns - = select_tag(:fields_to_hide, options_for_select(@report.available_headers, params[:fields_to_hide]), + = select_tag(:fields_to_show, options_for_select(@report.available_headers, params[:fields_to_show]), class: "select2 fullwidth", multiple: true) .row.rendering-options diff --git a/config/locales/en.yml b/config/locales/en.yml index 82c667fb07..1b843282e0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2625,7 +2625,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using report_payment_totals: 'Payment Totals' report_all: 'all' report_order_cycle: "Order Cycle" - report_hide_columns: Columns to Hide + report_columns: Columns report_enterprises: "Enterprises" report_enterprise_fee: "Fees Names" report_users: "Users" diff --git a/spec/controllers/admin/reports_controller_spec.rb b/spec/controllers/admin/reports_controller_spec.rb index c306451f95..c367c33712 100644 --- a/spec/controllers/admin/reports_controller_spec.rb +++ b/spec/controllers/admin/reports_controller_spec.rb @@ -250,6 +250,7 @@ describe Admin::ReportsController, type: :controller do .and_return(report = double(:report)) allow(report).to receive(:table_headers).and_return [] allow(report).to receive(:table_rows).and_return [] + allow(report).to receive(:columns).and_return({}) spree_get :show, report_type: :products_and_inventory, test: "foo" expect(assigns(:report)).to eq(report) end @@ -300,6 +301,7 @@ describe Admin::ReportsController, type: :controller do .and_return(report = double(:report)) allow(report).to receive(:table_headers).and_return [] allow(report).to receive(:table_rows).and_return [] + allow(report).to receive(:columns).and_return({}) spree_get :show, report_type: :customers, test: "foo" expect(assigns(:report)).to eq(report) end