mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Add Tags collumn
Currently display the list of tags, no fancy UI. Updating works
This commit is contained in:
@@ -8,7 +8,7 @@ module PermittedAttributes
|
||||
:shipping_category_id, :price, :unit_value,
|
||||
:unit_description, :variant_unit, :variant_unit_name, :variant_unit_scale, :display_name,
|
||||
:display_as, :tax_category_id, :weight, :height, :width, :depth, :taxon_ids,
|
||||
:primary_taxon_id, :supplier_id
|
||||
:primary_taxon_id, :supplier_id, :variant_tag_list
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
%td.col-category.align-left
|
||||
-# empty
|
||||
%td.col-tax_category.align-left
|
||||
- if feature?(:variant_tag, spree_current_user)
|
||||
%td.col-tags.align-left
|
||||
-# empty
|
||||
%td.col-inherits_properties.align-left
|
||||
.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
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
%tr{ 'data-nested-form-target': "target" }
|
||||
%tr.condensed
|
||||
%td
|
||||
%td{ colspan: 11 }
|
||||
- colspan = feature?(:variant_tag, spree_current_user) ? 12 : 11
|
||||
%td{ colspan: "#{colspan}" }
|
||||
%button.secondary.condensed.naked.icon-plus{ 'data-action': "nested-form#add",
|
||||
'aria-label': t('.new_variant') }
|
||||
=t('.new_variant')
|
||||
|
||||
@@ -26,11 +26,14 @@
|
||||
%col.col-producer{ style:"min-width: 6em" }= # (grow to fill)
|
||||
%col.col-category{ width:"8%" }
|
||||
%col.col-tax_category{ width:"8%" }
|
||||
- if feature?(:variant_tag, spree_current_user)
|
||||
%col.col-tags{ width:"8%" }
|
||||
%col.col-inherits_properties{ width:"5%" }
|
||||
%col{ width:"5%", style:"min-width: 3em"}= # Actions
|
||||
%thead
|
||||
%tr
|
||||
%td.form-actions-wrapper{ colspan: 12 }
|
||||
- colspan = feature?(:variant_tag, spree_current_user) ? 13 : 12
|
||||
%td.form-actions-wrapper{ colspan: "#{colspan}" }
|
||||
.form-actions-wrapper2
|
||||
%fieldset.form-actions{ class: ("hidden" unless defined?(@error_counts)), 'data-bulk-form-target': "actions" }
|
||||
.container
|
||||
@@ -60,6 +63,8 @@
|
||||
%th.align-left.col-producer= t('admin.products_page.columns.producer')
|
||||
%th.align-left.col-category= t('admin.products_page.columns.category')
|
||||
%th.align-left.col-tax_category= t('admin.products_page.columns.tax_category')
|
||||
- if feature?(:variant_tag, spree_current_user)
|
||||
%th.align-left.col-tags= t('admin.products_page.columns.tags')
|
||||
%th.align-left.col-inherits_properties= t('admin.products_page.columns.inherits_properties')
|
||||
%th.align-right= t('admin.products_page.columns.actions')
|
||||
- products.each_with_index do |product, product_index|
|
||||
|
||||
@@ -74,6 +74,9 @@
|
||||
aria_label: t('.tax_category_field_name'),
|
||||
placeholder_value: t('.search_for_tax_categories')))
|
||||
= error_message_on variant, :tax_category
|
||||
- if feature?(:variant_tag, spree_current_user)
|
||||
%td.col-tags.field.naked_inputs
|
||||
= f.text_field :variant_tag_list, 'aria-label': t('admin.products_page.columns.tags'), value: variant.variant_tag_list.join(",")
|
||||
%td.col-inherits_properties.align-left
|
||||
-# empty
|
||||
%td.align-right
|
||||
|
||||
@@ -29,6 +29,7 @@ export default class ColumnPreferencesController extends Controller {
|
||||
const element = e.target || e;
|
||||
const name = element.dataset.columnName;
|
||||
|
||||
// Css defined in app/webpacker/css/admin/products_v3.scss
|
||||
this.table.classList.toggle(`hide-${name}`, !element.checked);
|
||||
|
||||
// Reset cell colspans
|
||||
|
||||
@@ -186,7 +186,7 @@
|
||||
// Hide columns
|
||||
$columns:
|
||||
"image", "name", "sku", "unit_scale", "unit", "price", "on_hand", "producer", "category",
|
||||
"tax_category", "inherits_properties";
|
||||
"tax_category", "tags", "inherits_properties";
|
||||
@each $col in $columns {
|
||||
&.hide-#{$col} {
|
||||
.col-#{$col} {
|
||||
|
||||
@@ -636,6 +636,7 @@ en:
|
||||
inherits_properties: "Inherits Properties?"
|
||||
import_date: "Import Date"
|
||||
actions: Actions
|
||||
tags: Tags
|
||||
columns_selector:
|
||||
unit: Unit
|
||||
price: Price
|
||||
|
||||
@@ -81,7 +81,7 @@ module OpenFoodNetwork
|
||||
producer_visibility = display_producer_column?(user)
|
||||
|
||||
I18n.with_options scope: 'admin.products_page.columns' do
|
||||
{
|
||||
columns = {
|
||||
image: { name: t(:image), visible: true },
|
||||
name: { name: t(:name), visible: true },
|
||||
sku: { name: t(:sku), visible: true },
|
||||
@@ -92,8 +92,14 @@ module OpenFoodNetwork
|
||||
producer: { name: t(:producer), visible: producer_visibility },
|
||||
category: { name: t(:category), visible: true },
|
||||
tax_category: { name: t(:tax_category), visible: true },
|
||||
inherits_properties: { name: t(:inherits_properties), visible: true },
|
||||
}
|
||||
if OpenFoodNetwork::FeatureToggle.enabled?(:variant_tag, user)
|
||||
columns[:tags] = { name: t(:tags), visible: true }
|
||||
end
|
||||
|
||||
columns[:inherits_properties] = { name: t(:inherits_properties), visible: true }
|
||||
|
||||
columns
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user