Display extended variant name in quick cart

This commit is contained in:
Rohan Mitchell
2015-03-13 12:58:53 +11:00
parent 44511b8b61
commit efbf2c7ffa
4 changed files with 44 additions and 4 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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