mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Add variant rows and price column
This commit is contained in:
@@ -1,34 +1,43 @@
|
||||
%table.products
|
||||
%col{ width:"15%" }
|
||||
%col{ width:"5%", style: "max-width:5em" }
|
||||
%col{ width:"5%", style: "max-width:5em" }
|
||||
%col{ width:"8%" }
|
||||
%col{ width:"5%", style: "max-width:5em"}
|
||||
- # producer
|
||||
%col{ width:"10%" }
|
||||
%col{ width:"5%", style: "max-width:5em"}
|
||||
%col{ width:"10%" }= # producer
|
||||
%col{ width:"10%" }
|
||||
%col{ width:"5%" }
|
||||
%col{ width:"5%", style: "max-width:5em" }
|
||||
%col{ width:"8%", style: "max-width:8em" }
|
||||
%thead
|
||||
%tr
|
||||
%th.align-left= t('admin.product.name')
|
||||
%th.align-right= t('admin.sku')
|
||||
%th.align-right= t('admin.unit')
|
||||
%th.align-right= t('admin.price')
|
||||
%th.align-right= t('admin.on_hand')
|
||||
%th.align-left= t('admin.producer')
|
||||
%th.align-left= t('admin.category')
|
||||
%th.align-left= t('admin.tax_category')
|
||||
%th.align-left= t('admin.inherits_properties')
|
||||
%tbody
|
||||
- products.each do |product|
|
||||
%th.align-right= t('admin.available_on')
|
||||
- products.each do |product|
|
||||
%tbody
|
||||
%tr
|
||||
%td.align-left.header
|
||||
.line-clamp-1= product.name
|
||||
%td.align-right
|
||||
.line-clamp-1= product.sku
|
||||
%td.align-right
|
||||
.line-clamp-1= "#{product.unit_value&.round(3)} #{product.variant_unit}"
|
||||
.line-clamp-1
|
||||
= product.variant_unit.upcase_first
|
||||
/ TODO: properly handle custom unit names
|
||||
= WeightsAndMeasures::UNITS[product.variant_unit] && "(" + WeightsAndMeasures::UNITS[product.variant_unit][product.variant_unit_scale]["name"] + ")"
|
||||
%td.align-right
|
||||
.line-clamp-1= product.on_hand || 0
|
||||
-# empty
|
||||
%td.align-right
|
||||
-# TODO: new requirement "DISPLAY ON DEMAND IF ALL VARIANTS ARE ON DEMAND". And translate value
|
||||
.line-clamp-1= if product.variants.all?(&:on_demand) then "On demand" else product.on_hand || 0 end
|
||||
%td.align-left
|
||||
.line-clamp-1= product.supplier.name
|
||||
%td.align-left
|
||||
@@ -36,4 +45,29 @@
|
||||
%td.align-left
|
||||
.line-clamp-1= product.tax_category&.name
|
||||
%td.align-left
|
||||
.line-clamp-1= product.inherits_properties ? 'YES' : 'NO' #TODO: consider using https://github.com/RST-J/human_attribute_values
|
||||
.line-clamp-1= product.inherits_properties ? 'YES' : 'NO' #TODO: consider using https://github.com/RST-J/human_attribute_values, else use I18n.t (also below)
|
||||
%td.align-right
|
||||
.line-clamp-1= product.available_on&.strftime('%F')
|
||||
- product.variants.each do |variant|
|
||||
%tr
|
||||
%td.align-left
|
||||
.line-clamp-1= variant.display_name
|
||||
%td.align-right
|
||||
.line-clamp-1= variant.sku
|
||||
%td.align-right
|
||||
.line-clamp-1= variant.unit_to_display
|
||||
%td.align-right
|
||||
.line-clamp-1= number_to_currency(variant.price)
|
||||
%td.align-right
|
||||
.line-clamp-1= variant.on_hand || 0 #TODO: spec for this according to requirements.
|
||||
%td.align-left
|
||||
.line-clamp-1= variant.product.supplier.name # same as product
|
||||
%td.align-left
|
||||
.line-clamp-1= variant.product.taxons.map(&:name).join(', ') # same as product
|
||||
%td.align-left
|
||||
.line-clamp-1= variant.tax_category&.name
|
||||
%td.align-left
|
||||
.line-clamp-1= variant.product.inherits_properties ? 'YES' : 'NO' # same as product
|
||||
%td.align-right
|
||||
.line-clamp-1= variant.available_on&.strftime('%F')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user