Change UX to transform from fields_to_hide to fields_to_show

Fill `params[:fields_to_show]` with its default value
This commit is contained in:
Jean-Baptiste Bellet
2022-05-18 10:59:58 +02:00
parent 9094a65ab6
commit a46416a98e
4 changed files with 6 additions and 3 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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"

View File

@@ -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