From 00df441bc20d71eee46cf5b7911c6cd7ed4bb003 Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 28 Mar 2014 16:47:52 +1100 Subject: [PATCH] Re-add changes to variant bulk show to fix 'I'm a teapot' fails --- app/assets/javascripts/admin/bulk_product_update.js.coffee | 3 +-- app/views/spree/api/variants/bulk_show.v1.rabl | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/admin/bulk_product_update.js.coffee b/app/assets/javascripts/admin/bulk_product_update.js.coffee index 30d3a18f09..c2641615e2 100644 --- a/app/assets/javascripts/admin/bulk_product_update.js.coffee +++ b/app/assets/javascripts/admin/bulk_product_update.js.coffee @@ -259,11 +259,11 @@ productEditModule.controller "AdminProductEditCtrl", [ $scope.addVariant = (product) -> product.variants.push id: $scope.nextVariantId() - price: null unit_value: null unit_description: null on_demand: false on_hand: null + price: null $scope.displayProperties[product.id].showVariants = true @@ -358,7 +358,6 @@ productEditModule.controller "AdminProductEditCtrl", [ # conflicted with some changes I made before merging my work, so for now I've reverted to the old way of # doing things. TODO: Review together and decide on strategy here. -- Rohan, 14-1-2014 #if subset($scope.productsWithoutDerivedAttributes(), data) - if $scope.productListsMatch $scope.products, data $scope.resetProducts data $timeout -> $scope.displaySuccess() diff --git a/app/views/spree/api/variants/bulk_show.v1.rabl b/app/views/spree/api/variants/bulk_show.v1.rabl index 458d79e89b..52e293a890 100644 --- a/app/views/spree/api/variants/bulk_show.v1.rabl +++ b/app/views/spree/api/variants/bulk_show.v1.rabl @@ -1,6 +1,7 @@ object @variant -attributes :id, :price, :options_text, :unit_value, :unit_description, :on_demand +attributes :id, :options_text, :unit_value, :unit_description, :on_demand # Infinity is not a valid JSON object, but Rails encodes it anyway -node( :on_hand ) { |v| v.on_hand.to_f.finite? ? v.on_hand : "On demand" } \ No newline at end of file +node( :on_hand ) { |v| v.on_hand.nil? ? 0 : ( v.on_hand.to_f.finite? ? v.on_hand : "On demand" ) } +node( :price ) { |v| v.price.nil? ? 0.to_f : v.price } \ No newline at end of file