Vertically align non-input content in table rows

This commit is contained in:
David Cook
2023-09-20 12:15:12 +10:00
committed by Rachel Arnould
parent 836f5a1fb3
commit 5e478b8a76
2 changed files with 16 additions and 9 deletions

View File

@@ -44,7 +44,7 @@
%td.align-right
= product_form.text_field :sku, 'aria-label': t('admin.products_page.columns.sku')
%td.align-right
.line-clamp-1
.content
= 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"] + ")"
@@ -52,14 +52,14 @@
-# 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
.content= if product.variants.all?(&:on_demand) then "On demand" else product.on_hand || 0 end
%td.align-left
.line-clamp-1= product.supplier.name
.content= product.supplier.name
%td.align-left
.line-clamp-1= product.primary_taxon.name
.content= product.primary_taxon.name
%td.align-left
%td.align-left
.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)
.content= 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
= render partial: 'admin/products_v3/components/product_actions', locals: { product: product }
- product.variants.each do |variant|
@@ -71,17 +71,17 @@
%td.align-right
= variant_form.text_field :sku, 'aria-label': t('admin.products_page.columns.sku')
%td.align-right
.line-clamp-1= variant.unit_to_display
.content= variant.unit_to_display
%td.align-right
= variant_form.text_field :price, 'aria-label': t('admin.products_page.columns.price'), value: number_to_currency(variant.price, unit: '')&.strip # TODO: add a spec to prove that this formatting is necessary. If so, it should be in a shared form helper for currency inputs
%td.align-right
.line-clamp-1= variant.on_hand || 0 #TODO: spec for this according to requirements.
.content= variant.on_hand || 0 #TODO: spec for this according to requirements.
%td.align-left
.line-clamp-1= variant.product.supplier.name # same as product
.content= variant.product.supplier.name # same as product
%td.align-left
-# empty
%td.align-left
.line-clamp-1= variant.tax_category&.name || "None" # TODO: convert to dropdown, else translate hardcoded string.
.content= variant.tax_category&.name || "None" # TODO: convert to dropdown, else translate hardcoded string.
%td.align-left
-# empty
%td.align-right

View File

@@ -64,6 +64,13 @@
td {
padding: $padding-tbl-cell;
border: none;
.content {
// Plain content fields need help to align with text in inputs (due to vertical-align)
margin: $vpadding-txt+1px 0;
@extend .line-clamp-1;
}
}
th {