Merge pull request #12307 from Matt-Yorkley/report-form-loading

Don't generate packing reports twice just to show the form
This commit is contained in:
Filipe
2024-03-26 12:42:45 +00:00
committed by GitHub
5 changed files with 30 additions and 10 deletions

View File

@@ -11,13 +11,13 @@ module Reporting
def table_headers
filter = proc { |key| key.to_sym.in?(fields_to_show) }
report.columns.keys.filter { |key| filter.call(key) }.map do |key|
report.table_columns.keys.filter { |key| filter.call(key) }.map do |key|
translate_header(key)
end
end
def available_headers
report.columns.keys.map { |key| [translate_header(key), key] }
report.table_columns.keys.map { |key| [translate_header(key), key] }
end
def fields_to_hide

View File

@@ -54,6 +54,10 @@ module Reporting
raise NotImplementedError
end
def table_columns
columns
end
# Exple { total_price: :currency }
def columns_format
{}

View File

@@ -4,11 +4,16 @@ module Reporting
module Reports
module Packing
class Customer < Base
def table_columns
Struct.new(:keys).new(
[:hub, :customer_code, :first_name, :last_name, :phone, :supplier, :product,
:variant, :weight, :height, :width, :depth, :quantity, :price, :temp_controlled]
)
end
def columns
# Reorder default columns
super.slice(:hub, :customer_code, :first_name, :last_name, :phone,
:supplier, :product, :variant, :weight, :height, :width, :depth, :quantity,
:price, :temp_controlled)
super.slice(*table_columns.keys)
end
def rules

View File

@@ -4,11 +4,16 @@ module Reporting
module Reports
module Packing
class Product < Base
def table_columns
Struct.new(:keys).new(
[:hub, :supplier, :product, :variant, :customer_code, :first_name,
:last_name, :phone, :quantity, :price, :temp_controlled]
)
end
def columns
# Reorder default columns
super.slice(:hub, :supplier, :product, :variant,
:customer_code, :first_name, :last_name, :phone,
:quantity, :price, :temp_controlled)
super.slice(*table_columns.keys)
end
def rules

View File

@@ -4,10 +4,16 @@ module Reporting
module Reports
module Packing
class Supplier < Base
def table_columns
Struct.new(:keys).new(
[:hub, :supplier, :customer_code, :first_name, :last_name, :phone,
:product, :variant, :quantity, :price, :temp_controlled]
)
end
def columns
# Reorder default columns
super.slice(:hub, :supplier, :customer_code, :first_name, :last_name, :phone,
:product, :variant, :quantity, :price, :temp_controlled)
super.slice(*table_columns.keys)
end
def rules