mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-20 04:59:16 +00:00
Display extended variant name in quick cart
This commit is contained in:
@@ -8,6 +8,7 @@ Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http)->
|
||||
for line_item in @line_items
|
||||
line_item.variant.line_item = line_item
|
||||
Variants.register line_item.variant
|
||||
line_item.variant.extended_name = @extendedVariantName(line_item.variant)
|
||||
|
||||
orderChanged: =>
|
||||
@unsaved()
|
||||
@@ -67,4 +68,12 @@ Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http)->
|
||||
variant: variant
|
||||
quantity: null
|
||||
max_quantity: null
|
||||
@line_items.push variant.line_item
|
||||
@line_items.push variant.line_item
|
||||
|
||||
extendedVariantName: (variant) =>
|
||||
if variant.product_name == variant.name_to_display
|
||||
variant.product_name
|
||||
else
|
||||
name = "#{variant.product_name} - #{variant.name_to_display}"
|
||||
name += " (#{variant.options_text})" if variant.options_text
|
||||
name
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Api::VariantSerializer < ActiveModel::Serializer
|
||||
attributes :id, :is_master, :count_on_hand, :name_to_display, :unit_to_display,
|
||||
:on_demand, :price, :fees, :price_with_fees
|
||||
:options_text, :on_demand, :price, :fees, :price_with_fees, :product_name
|
||||
|
||||
def price_with_fees
|
||||
object.price_with_fees(options[:current_distributor], options[:current_order_cycle])
|
||||
@@ -13,4 +13,9 @@ class Api::VariantSerializer < ActiveModel::Serializer
|
||||
def fees
|
||||
object.fees_by_type_for(options[:current_distributor], options[:current_order_cycle])
|
||||
end
|
||||
|
||||
def product_name
|
||||
object.product.name
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
/ %em {{ line_item.variant.unit_to_display }}
|
||||
/ - if {{ line_item.product.name }} == {{ line_item.variant.name_to_display }}
|
||||
%strong
|
||||
{{ line_item.variant.name_to_display }}
|
||||
{{ line_item.variant.extended_name }}
|
||||
|
||||
.columns.small-3.text-right
|
||||
%small
|
||||
|
||||
Reference in New Issue
Block a user