diff --git a/app/assets/javascripts/admin/services/bulk_products.js.coffee b/app/assets/javascripts/admin/services/bulk_products.js.coffee index 6085d48fcc..4e06a87bd2 100644 --- a/app/assets/javascripts/admin/services/bulk_products.js.coffee +++ b/app/assets/javascripts/admin/services/bulk_products.js.coffee @@ -19,6 +19,7 @@ angular.module("ofn.admin").factory "BulkProducts", (PagedFetcher, dataFetcher) # when a respond_overrride for the clone action is used. id = data.product.id dataFetcher("/api/products/" + id + "?template=bulk_show").then (newProduct) => + @unpackProduct newProduct @insertProductAfter(product, newProduct) updateVariantLists: (serverProducts, productsWithUnsavedVariants) -> diff --git a/app/views/spree/api/products/bulk_show.v1.rabl b/app/views/spree/api/products/bulk_show.v1.rabl index d2cd23bd03..c336d72530 100644 --- a/app/views/spree/api/products/bulk_show.v1.rabl +++ b/app/views/spree/api/products/bulk_show.v1.rabl @@ -1,5 +1,11 @@ object @product -attributes :id, :name, :variant_unit, :variant_unit_scale, :variant_unit_name, :on_demand + +# TODO: This is used by bulk product edit when a product is cloned. +# But the list of products is serialized by Api::Admin::ProductSerializer. +# This should probably be unified. + +attributes :id, :name, :sku, :variant_unit, :variant_unit_scale, :variant_unit_name, :on_demand, :inherits_properties +attributes :on_hand, :price, :available_on, :permalink_live, :tax_category_id # Infinity is not a valid JSON object, but Rails encodes it anyway node( :taxon_ids ) { |p| p.taxons.map{ |t| t.id }.join(",") } @@ -8,6 +14,8 @@ node( :price ) { |p| p.price.nil? ? '0.0' : p.price } node( :available_on ) { |p| p.available_on.blank? ? "" : p.available_on.strftime("%F %T") } node( :permalink_live ) { |p| p.permalink } +node( :producer_id ) { |p| p.supplier_id } +node( :category_id ) { |p| p.primary_taxon_id } node( :supplier ) do |p| partial 'api/enterprises/bulk_show', :object => p.supplier end diff --git a/lib/open_food_network/orders_and_fulfillments_report.rb b/lib/open_food_network/orders_and_fulfillments_report.rb index 2d4e1d1f1f..03c4ec801a 100644 --- a/lib/open_food_network/orders_and_fulfillments_report.rb +++ b/lib/open_food_network/orders_and_fulfillments_report.rb @@ -222,7 +222,7 @@ module OpenFoodNetwork proc { |line_items| line_items.first.order.order_cycle.andand.name }, proc { |line_items| line_items.first.order.payments.first.andand.payment_method.andand.name }, proc { |line_items| line_items.first.order.user.andand.customer_of(line_items.first.order.distributor).andand.code }, - proc { |line_items| "" }, + proc { |line_items| line_items.first.order.user.andand.customer_of(line_items.first.order.distributor).andand.tags.andand.join(', ') }, proc { |line_items| line_items.first.order.bill_address.andand.address1 }, proc { |line_items| line_items.first.order.bill_address.andand.address2 }, diff --git a/spec/javascripts/unit/admin/services/bulk_products_spec.js.coffee b/spec/javascripts/unit/admin/services/bulk_products_spec.js.coffee index 54b57aed48..7d4c5d1d7c 100644 --- a/spec/javascripts/unit/admin/services/bulk_products_spec.js.coffee +++ b/spec/javascripts/unit/admin/services/bulk_products_spec.js.coffee @@ -62,12 +62,15 @@ describe "BulkProducts service", -> id: 17 spyOn(BulkProducts, "insertProductAfter") + spyOn(BulkProducts, "unpackProduct") BulkProducts.products = [originalProduct] $httpBackend.expectGET("/admin/products/oranges/clone.json").respond 200, product: clonedProduct $httpBackend.expectGET("/api/products/17?template=bulk_show").respond 200, clonedProduct BulkProducts.cloneProduct BulkProducts.products[0] $httpBackend.flush() + expect(BulkProducts.unpackProduct).toHaveBeenCalledWith clonedProduct + BulkProducts.unpackProduct(clonedProduct) expect(BulkProducts.insertProductAfter).toHaveBeenCalledWith originalProduct, clonedProduct