Performance enhancements

This commit is contained in:
Will Marshall
2014-07-11 16:14:44 +10:00
parent 7bd65d7854
commit 500e067cfb
4 changed files with 5 additions and 4 deletions

View File

@@ -1,6 +1,5 @@
Darkswarm.controller "ProductNodeCtrl", ($scope, $modal) ->
$scope.enterprise = $scope.product.supplier # For the modal, so it's consistent
$scope.hasVariants = $scope.product.variants.length > 0
$scope.triggerProductModal = ->
$modal.open(templateUrl: "product_modal.html", scope: $scope)

View File

@@ -26,3 +26,5 @@ Darkswarm.factory 'Product', ($resource, Enterprises, Dereferencer, Taxons) ->
if product.variants.length > 0
prices = (v.price for v in product.variants)
product.price = Math.min.apply(null, prices)
product.hasVariants = product.variants.length > 0

View File

@@ -20,9 +20,9 @@
"ng-repeat" => "product in filteredProducts = (Product.products | products:query | taxons:activeTaxons | orderBy:ordering.order) track by product.id "}
%div
= render partial: "shop/products/summary"
%div{"bo-if" => "hasVariants"}
%div{"bo-if" => "product.hasVariants"}
= render partial: "shop/products/variants"
.variants.row{"bo-if" => "!hasVariants"}
.variants.row{"bo-if" => "!product.hasVariants"}
= render partial: "shop/products/master"
%product{"ng-show" => "Product.loading"}

View File

@@ -11,6 +11,6 @@
%producer-modal {{ enterprise.name }}
.small-2.columns.summary-price.text-right.price
%span{"ng-if" => "hasVariants"}
%span{"ng-if" => "product.hasVariants"}
%em from
{{ product.price | currency }}