diff --git a/app/assets/javascripts/darkswarm/controllers/cart_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/cart_controller.js.coffee index fa60b0589c..600ba72bdc 100644 --- a/app/assets/javascripts/darkswarm/controllers/cart_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/cart_controller.js.coffee @@ -1,2 +1,2 @@ -Darkswarm.controller "CartCtrl", ($scope, CurrentOrder) -> - $scope.CurrentOrder = CurrentOrder +Darkswarm.controller "CartCtrl", ($scope, Cart) -> + $scope.Cart = Cart diff --git a/app/assets/javascripts/darkswarm/controllers/order_cycle_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/order_cycle_controller.js.coffee index 5913ae4b03..2f1394e90a 100644 --- a/app/assets/javascripts/darkswarm/controllers/order_cycle_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/order_cycle_controller.js.coffee @@ -12,8 +12,8 @@ Darkswarm.controller "OrderCycleCtrl", ($scope, OrderCycle, $timeout) -> $("#order_cycle_id").trigger("openTrigger") -Darkswarm.controller "OrderCycleChangeCtrl", ($scope, OrderCycle, Product, $timeout) -> +Darkswarm.controller "OrderCycleChangeCtrl", ($scope, OrderCycle, Products, $timeout) -> $scope.changeOrderCycle = -> - OrderCycle.push_order_cycle Product.update + OrderCycle.push_order_cycle Products.update $timeout -> $("#order_cycle_id").trigger("closeTrigger") diff --git a/app/assets/javascripts/darkswarm/controllers/products_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/products_controller.js.coffee index 361c1ebca4..3ef47530c9 100644 --- a/app/assets/javascripts/darkswarm/controllers/products_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/products_controller.js.coffee @@ -1,5 +1,5 @@ -Darkswarm.controller "ProductsCtrl", ($scope, $rootScope, Product, OrderCycle, FilterSelectorsService) -> - $scope.Product = Product +Darkswarm.controller "ProductsCtrl", ($scope, $rootScope, Products, OrderCycle, FilterSelectorsService) -> + $scope.Products = Products $scope.totalActive = FilterSelectorsService.totalActive $scope.clearAll = FilterSelectorsService.clearAll $scope.filterText = FilterSelectorsService.filterText @@ -9,7 +9,7 @@ Darkswarm.controller "ProductsCtrl", ($scope, $rootScope, Product, OrderCycle, F $scope.order_cycle = OrderCycle.order_cycle $scope.incrementLimit = -> - if $scope.limit < $scope.Product.products.length + if $scope.limit < Products.products.length $scope.limit = $scope.limit + 1 $scope.searchKeypress = (e)-> diff --git a/app/assets/javascripts/darkswarm/services/cart.js.coffee b/app/assets/javascripts/darkswarm/services/cart.js.coffee index 6a91911472..2567d6a90c 100644 --- a/app/assets/javascripts/darkswarm/services/cart.js.coffee +++ b/app/assets/javascripts/darkswarm/services/cart.js.coffee @@ -3,3 +3,5 @@ Darkswarm.factory 'Cart', (CurrentOrder)-> new class Cart order: CurrentOrder.order + # How to structure this? + diff --git a/app/assets/javascripts/darkswarm/services/product.js.coffee b/app/assets/javascripts/darkswarm/services/products.js.coffee similarity index 91% rename from app/assets/javascripts/darkswarm/services/product.js.coffee rename to app/assets/javascripts/darkswarm/services/products.js.coffee index 63c9e7c0b0..05ac50c2fd 100644 --- a/app/assets/javascripts/darkswarm/services/product.js.coffee +++ b/app/assets/javascripts/darkswarm/services/products.js.coffee @@ -1,4 +1,4 @@ -Darkswarm.factory 'Product', ($resource, Enterprises, Dereferencer, Taxons) -> +Darkswarm.factory 'Products', ($resource, Enterprises, Dereferencer, Taxons) -> new class Products constructor: -> @update() diff --git a/app/controllers/spree/orders_controller_decorator.rb b/app/controllers/spree/orders_controller_decorator.rb index adfa4cd2ad..e9245b4a32 100644 --- a/app/controllers/spree/orders_controller_decorator.rb +++ b/app/controllers/spree/orders_controller_decorator.rb @@ -21,7 +21,6 @@ Spree::OrdersController.class_eval do end end - # Patch populate to be Ajax def populate populator = Spree::OrderPopulator.new(current_order(true), current_currency) if populator.populate(params.slice(:products, :variants, :quantity), true) diff --git a/app/views/shared/menu/_cart.html.haml b/app/views/shared/menu/_cart.html.haml index a7320554c6..080961922f 100644 --- a/app/views/shared/menu/_cart.html.haml +++ b/app/views/shared/menu/_cart.html.haml @@ -2,5 +2,5 @@ %span.nav-branded %i.ofn-i_027-shopping-cart %span - {{ CurrentOrder.cart_count }} + {{ Cart.order.line_items.length }} items diff --git a/app/views/shop/products/_filters.html.haml b/app/views/shop/products/_filters.html.haml index 7879bcc5d1..c57f927e61 100644 --- a/app/views/shop/products/_filters.html.haml +++ b/app/views/shop/products/_filters.html.haml @@ -8,7 +8,7 @@ .light Filter by Type %ul.small-block-grid-2.medium-block-grid-3.large-block-grid-4 - %taxon-selector{objects: "Product.products | products:query", + %taxon-selector{objects: "Products.products | products:query", results: "activeTaxons"} .row.filter-box.animate-show{"ng-show" => "filtersActive && totalActive() > 0"} diff --git a/app/views/shop/products/_form.html.haml b/app/views/shop/products/_form.html.haml index 2aaf7a4f5f..8e4e3fce35 100644 --- a/app/views/shop/products/_form.html.haml +++ b/app/views/shop/products/_form.html.haml @@ -17,7 +17,7 @@ %div.pad-top{bindonce: true} %product.animate-repeat{"ng-controller" => "ProductNodeCtrl", - "ng-repeat" => "product in filteredProducts = (Product.products | products:query | taxons:activeTaxons | orderBy:ordering.order) track by product.id "} + "ng-repeat" => "product in filteredProducts = (Products.products | products:query | taxons:activeTaxons | orderBy:ordering.order) track by product.id "} %div = render partial: "shop/products/summary" %div{"bo-if" => "product.hasVariants"} @@ -25,12 +25,12 @@ .variants.row{"bo-if" => "!product.hasVariants"} = render partial: "shop/products/master" - %product{"ng-show" => "Product.loading"} + %product{"ng-show" => "Products.loading"} .row.summary .small-12.columns.text-center Loading products - %div{"ng-show" => "filteredProducts.length == 0 && !Product.loading"} + %div{"ng-show" => "filteredProducts.length == 0 && !Products.loading"} .row.summary .small-12.columns %p.no-results diff --git a/app/views/shop/products/_master.html.haml b/app/views/shop/products/_master.html.haml index 92a17be43d..c8efb21420 100644 --- a/app/views/shop/products/_master.html.haml +++ b/app/views/shop/products/_master.html.haml @@ -13,8 +13,7 @@ "ofn-disable-scroll" => true, max: "{{product.on_demand && 9999 || product.count_on_hand }}", name: "variants[{{product.master.id}}]", - id: "variants_{{product.master.id}}", - "ng-model" => "product.quantity"} + id: "variants_{{product.master.id}}"} %small x {{ product.master.unit_to_display }} -# WITH GROUP BUY @@ -25,8 +24,7 @@ "ofn-disable-scroll" => true, max: "{{product.on_demand && 9999 || product.count_on_hand }}", name: "variants[{{product.master.id}}]", - id: "variants_{{product.master.id}}", - "ng-model" => "product.quantity"} + id: "variants_{{product.master.id}}"} .small-3.columns{"bo-if" => "product.group_buy"} %input{type: :number, @@ -34,8 +32,7 @@ placeholder: "max", "ofn-disable-scroll" => true, max: "{{product.on_demand && 9999 || product.count_on_hand }}", - name: "variant_attributes[{{product.master.id}}][max_quantity]", - "ng-model" => "product.max_quantity"} + name: "variant_attributes[{{product.master.id}}][max_quantity]"} %small x {{ product.master.unit_to_display }} .small-2.columns.text-right diff --git a/app/views/shop/products/_variants.html.haml b/app/views/shop/products/_variants.html.haml index 2d281dafe8..f2129abe7b 100644 --- a/app/views/shop/products/_variants.html.haml +++ b/app/views/shop/products/_variants.html.haml @@ -16,8 +16,7 @@ placeholder: "0", "ofn-disable-scroll" => true, max: "{{variant.on_demand && 9999 || variant.count_on_hand }}", - name: "variants[{{variant.id}}]", id: "variants_{{variant.id}}", - "bo-model" => "variant.quantity"} + name: "variants[{{variant.id}}]", id: "variants_{{variant.id}}"} %small x {{ variant.unit_to_display }} -# WITH GROUP BUY @@ -28,8 +27,7 @@ placeholder: "min", "ofn-disable-scroll" => true, max: "{{variant.on_demand && 9999 || variant.count_on_hand }}", - name: "variants[{{variant.id}}]", id: "variants_{{variant.id}}", - "bo-model" => "variant.quantity"} + name: "variants[{{variant.id}}]", id: "variants_{{variant.id}}"} .small-3.columns{"bo-if" => "product.group_buy"} %input{type: :number, @@ -37,8 +35,7 @@ placeholder: "max", "ofn-disable-scroll" => true, max: "{{variant.on_demand && 9999 || variant.count_on_hand }}", - name: "variant_attributes[{{variant.id}}][max_quantity]", - "ng-model" => "variant.max_quantity"} + name: "variant_attributes[{{variant.id}}][max_quantity]"} %small x {{ variant.unit_to_display }} .small-2.columns.text-right.price