Fixing a minor regression

This commit is contained in:
Will Marshall
2014-06-19 12:10:05 +10:00
parent 4684c92c6e
commit a7f4256897
5 changed files with 6 additions and 9 deletions

View File

@@ -1,12 +1,11 @@
Darkswarm.controller "ProductsCtrl", ($scope, $rootScope, Product, OrderCycle) ->
$scope.products = Product.products
$scope.loading = Product.loading
$scope.Product = Product
$scope.limit = 3
$scope.ordering = {order: "name"}
$scope.order_cycle = OrderCycle.order_cycle
$scope.incrementLimit = ->
if $scope.limit < $scope.products.length
if $scope.limit < $scope.Product.products.length
$scope.limit = $scope.limit + 1
$scope.searchKeypress = (e)->

View File

@@ -9,6 +9,7 @@ Darkswarm.factory 'Product', ($resource) ->
loading: true
update: =>
@loading = true
@products = $resource("/shop/products").query =>
@loading = false
@

View File

@@ -14,7 +14,7 @@
%div{bindonce: true}
%product{"ng-controller" => "ProductNodeCtrl",
"ng-repeat" => "product in products | filter:query | orderBy:ordering.order | limitTo: limit track by product.id"}
"ng-repeat" => "product in Product.products | filter:query | orderBy:ordering.order | limitTo: limit track by product.id"}
%div
= render partial: "shop/products/summary"
%div{"bo-if" => "hasVariants"}
@@ -22,12 +22,10 @@
.variants.row{"bo-if" => "!hasVariants"}
= render partial: "shop/products/master"
%product{"ng-show" => "loading"}
%product{"ng-show" => "Product.loading"}
.row.summary
.small-12.columns.text-center
Loading products
.row
.small-12.columns
%input.button.primary.right.add_to_cart{type: :submit, value: "Add to Cart"}

View File

@@ -77,7 +77,6 @@ feature "As a consumer I want to shop with a distributor", js: true do
page.should have_content "Next order closing in 2 days"
Spree::Order.last.order_cycle.should == oc1
page.should have_content product.name
save_screenshot "/Users/willmarshall/Desktop/shop.png"
page.should have_content product.master.display_name
page.should have_content product.master.display_as
end

View File

@@ -18,4 +18,4 @@ describe 'ProductsCtrl', ->
ctrl = $controller 'ProductsCtrl', {$scope: scope, Product: Product, OrderCycle: OrderCycle}
it 'fetches products from Product', ->
expect(scope.products).toEqual 'testy mctest'
expect(scope.Product.products).toEqual 'testy mctest'