mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
add available units to instance prefs page
This commit is contained in:
@@ -10,6 +10,13 @@ module Spree
|
||||
end
|
||||
|
||||
def update
|
||||
available_units = []
|
||||
params.each do |name, value|
|
||||
if value == "1" && unit = name.match(/available_units_(.*)/)&.captures&.first
|
||||
available_units << unit
|
||||
end
|
||||
end
|
||||
Spree::Config[:available_units] = available_units.join(",")
|
||||
params.each do |name, value|
|
||||
next unless Spree::Config.has_preference? name
|
||||
|
||||
|
||||
@@ -144,5 +144,8 @@ module Spree
|
||||
# Enable cache
|
||||
preference :enable_products_cache?, :boolean,
|
||||
default: (Rails.env.production? || Rails.env.staging?)
|
||||
|
||||
# Available units
|
||||
preference :available_units, :string, default: "g,kg,T,mL,L,kL"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -87,6 +87,15 @@
|
||||
.field
|
||||
= preference_field_tag(:enable_localized_number?, Spree::Config[:enable_localized_number?], type: Spree::Config.preference_type(:enable_localized_number?))
|
||||
= label_tag(:enable_localized_number?, t('admin.number_localization.enable_localized_number')) + tag(:br)
|
||||
%fieldset.available_units.no-border-bottom
|
||||
%legend{:align => "center"}= t('admin.available_units')
|
||||
.field
|
||||
- all_units = ["g", "oz", "lb", "kg", "T", "mL", "L", "kL"]
|
||||
- selected_units = Spree::Config[:available_units].split(",")
|
||||
- all_units.each do |unit|
|
||||
- selected = selected_units.include?(unit)
|
||||
= preference_field_tag("available_units_#{unit}", selected, { type: :boolean, selected: selected })
|
||||
= label_tag(unit, unit.downcase) + tag(:br)
|
||||
|
||||
.form-buttons.filter-actions.actions{"data-hook" => "buttons"}
|
||||
= button Spree.t('actions.update'), 'icon-refresh'
|
||||
|
||||
@@ -394,6 +394,8 @@ en:
|
||||
unsaved_confirm_leave: "There are unsaved changed on this page. Continue without saving?"
|
||||
unsaved_changes: "You have unsaved changes"
|
||||
|
||||
available_units: "Available Units"
|
||||
|
||||
shopfront_settings:
|
||||
embedded_shopfront_settings: "Embedded Shopfront Settings"
|
||||
enable_embedded_shopfronts: "Enable Embedded Shopfronts"
|
||||
|
||||
Reference in New Issue
Block a user