mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Packing Report: Refactor view to be reusable by other reports
For now this view is used only in the context of packing, but later we would move all existing rpeort to use same view
This commit is contained in:
committed by
Jean-Baptiste Bellet
parent
1ff98a1d8a
commit
d53d38906a
@@ -30,7 +30,7 @@ module Admin
|
||||
assign_view_data
|
||||
load_form_options
|
||||
|
||||
render report_type
|
||||
render "show"
|
||||
end
|
||||
|
||||
def assign_view_data
|
||||
@@ -39,6 +39,9 @@ module Admin
|
||||
@report_subtypes = report_class.report_subtypes.map do |subtype|
|
||||
[t("packing.#{subtype}_report", scope: i18n_scope), subtype]
|
||||
end
|
||||
if @report_type == "packing"
|
||||
@report_message = I18n.t("spree.admin.reports.customer_names_message.customer_names_tip")
|
||||
end
|
||||
end
|
||||
|
||||
def load_form_options
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
- if @report_subtypes.any?
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_type)
|
||||
.omega.fourteen.columns
|
||||
= select_tag(:report_subtype, options_for_select(@report_subtypes, @report_subtype))
|
||||
|
||||
.row.rendering-options
|
||||
.alpha.two.columns
|
||||
= label_tag :report_format, t(".generate_report")
|
||||
.omega.fourteen.columns
|
||||
= select_tag :report_format, options_for_select({t('.on_screen') => '', t('.csv_spreadsheet') => 'csv', t('.excel_spreadsheet') => 'xlsx', t('.openoffice_spreadsheet') => 'ods'})
|
||||
-#.inline-checkbox
|
||||
-# = check_box_tag "options[exclude_summaries]", true, params[:options].andand[:exclude_summaries]
|
||||
-# = label_tag t(".hide_summary_rows")
|
||||
|
||||
-#.inline-checkbox
|
||||
-# = check_box_tag "options[exclude_summaries]", true, params[:options].andand[:exclude_summaries]
|
||||
-# = label_tag t(".hide_summary_rows")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
- if params[:q].present?
|
||||
%table.report__table{id: id}
|
||||
%table.report__table
|
||||
%thead
|
||||
%tr
|
||||
- @report.table_headers.each do |heading|
|
||||
|
||||
16
app/views/admin/reports/filters/_packing.html.haml
Normal file
16
app/views/admin/reports/filters/_packing.html.haml
Normal file
@@ -0,0 +1,16 @@
|
||||
= render partial: 'admin/reports/date_range_form'
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_hubs)
|
||||
.omega.fourteen.columns
|
||||
= collection_select("q", "order_distributor_id_in", @distributors, :id, :name, {selected: params.dig(:q, :order_distributor_id_in)}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_producers)
|
||||
.omega.fourteen.columns
|
||||
= select_tag("q[supplier_id_in]", options_from_collection_for_select(@suppliers, :id, :name, params.dig(:q, :supplier_id_in)), {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_customers_cycle)
|
||||
.omega.fourteen.columns
|
||||
= select_tag("q[order_cycle_id_in]", options_for_select(report_order_cycle_options(@order_cycles), params.dig(:q, :order_cycle_id_in)), {class: "select2 fullwidth", multiple: true})
|
||||
@@ -1,36 +0,0 @@
|
||||
= form_tag main_app.admin_reports_path, report_type: 'packing' do
|
||||
%fieldset.no-border-bottom
|
||||
%legend{ align: 'center'}= t(:report_filters)
|
||||
= render partial: 'date_range_form'
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_hubs)
|
||||
.omega.fourteen.columns
|
||||
= collection_select("q", "order_distributor_id_in", @distributors, :id, :name, {selected: params.dig(:q, :order_distributor_id_in)}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_producers)
|
||||
.omega.fourteen.columns
|
||||
= select_tag("q[supplier_id_in]", options_from_collection_for_select(@suppliers, :id, :name, params.dig(:q, :supplier_id_in)), {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_customers_cycle)
|
||||
.omega.fourteen.columns
|
||||
= select_tag("q[order_cycle_id_in]", options_for_select(report_order_cycle_options(@order_cycles), params.dig(:q, :order_cycle_id_in)), {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
%fieldset
|
||||
%legend{ align: 'center'}= t(:report_display_options)
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_type)
|
||||
.omega.fourteen.columns
|
||||
= select_tag(:report_subtype, options_for_select(@report_subtypes, @report_subtype))
|
||||
|
||||
= render partial: "rendering_options"
|
||||
|
||||
.actions.filter-actions
|
||||
= button t(:go), "report__submit-btn"
|
||||
|
||||
- if params[:q].present?
|
||||
= render partial: "spree/admin/reports/customer_names_message"
|
||||
|
||||
= render "table", id: "listing_orders"
|
||||
16
app/views/admin/reports/show.html.haml
Normal file
16
app/views/admin/reports/show.html.haml
Normal file
@@ -0,0 +1,16 @@
|
||||
= form_tag main_app.admin_reports_path, report_type: @report_type do
|
||||
%fieldset.no-border-bottom
|
||||
%legend{ align: 'center'}= t(:report_filters)
|
||||
= render partial: "admin/reports/filters/#{@report_type}"
|
||||
|
||||
%fieldset
|
||||
%legend{ align: 'center'}= t(:report_render_options)
|
||||
= render partial: "rendering_options"
|
||||
|
||||
.actions.filter-actions
|
||||
= button t(:go), "report__submit-btn"
|
||||
|
||||
- if @report_message.present?
|
||||
%p.report__message= @report_message
|
||||
|
||||
= render "table"
|
||||
@@ -2637,7 +2637,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using
|
||||
report_tax_rates: Tax rates
|
||||
report_tax_types: Tax types
|
||||
report_filters: Report Filters
|
||||
report_display_options: Display Options
|
||||
report_render_options: Render Options
|
||||
report_header_order_cycle: Order Cycle
|
||||
report_header_user: User
|
||||
report_header_email: Email
|
||||
|
||||
Reference in New Issue
Block a user