From b3e67fa1640721d66b0f8f28658eda12204d07bd Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 15 Jan 2015 17:34:04 +1100 Subject: [PATCH] Take two on disabled logic --- .../javascripts/darkswarm/services/cart.js.coffee | 3 +-- app/views/shared/menu/_cart.html.haml | 14 +++++++------- app/views/shop/products/_form.html.haml | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/darkswarm/services/cart.js.coffee b/app/assets/javascripts/darkswarm/services/cart.js.coffee index 98df66f592..74f978bf3a 100644 --- a/app/assets/javascripts/darkswarm/services/cart.js.coffee +++ b/app/assets/javascripts/darkswarm/services/cart.js.coffee @@ -8,7 +8,6 @@ Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http)-> for line_item in @line_items line_item.variant.line_item = line_item Variants.register line_item.variant - @dirty = @empty() orderChanged: => @unsaved() @@ -32,7 +31,7 @@ Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http)-> saved: => - @dirty = @empty() + @dirty = false $(window).unbind "beforeunload" unsaved: => diff --git a/app/views/shared/menu/_cart.html.haml b/app/views/shared/menu/_cart.html.haml index 74f9ee2b29..dda3149ea2 100644 --- a/app/views/shared/menu/_cart.html.haml +++ b/app/views/shared/menu/_cart.html.haml @@ -1,6 +1,6 @@ -%span.cart-span{"ng-controller" => "CartCtrl", "ng-class" => "{ dirty: Cart.dirty }"} +%span.cart-span{"ng-controller" => "CartCtrl", "ng-class" => "{ dirty: Cart.dirty || Cart.empty() }"} %a#cart.icon{cart: true} - %span.nav-branded + %span.nav-branded %i.ofn-i_027-shopping-cart %span {{ Cart.line_items_present().length }} @@ -23,19 +23,19 @@ %span.quantity {{ line_item.quantity }} %i.ofn-i_009-close %span.price {{ line_item.variant.price_with_fees | localizeCurrency }} - + .columns.small-2 %small \= - %strong + %strong .total-price.right {{ line_item.variant.totalPrice() | localizeCurrency }} %li.total-cart{"ng-show" => "Cart.line_items_present().length > 0"} .row .columns.small-6 - %em Total: + %em Total: .columns.small-6.text-right - %strong {{ Cart.total() | localizeCurrency }} + %strong {{ Cart.total() | localizeCurrency }} .text-right - %a.button.primary.small{href: checkout_path, "ng-disabled" => "Cart.dirty"} Quick checkout + %a.button.primary.small{href: checkout_path, "ng-disabled" => "Cart.dirty || Cart.empty()"} Quick checkout diff --git a/app/views/shop/products/_form.html.haml b/app/views/shop/products/_form.html.haml index 01e3b5ef19..252d810bab 100644 --- a/app/views/shop/products/_form.html.haml +++ b/app/views/shop/products/_form.html.haml @@ -13,7 +13,7 @@ %form{action: cart_path} .small-12.medium-4.large-3.columns %input.button.primary.right.add_to_cart{type: :submit, value: "Your shopping cart", - "ng-disabled" => "Cart.dirty"} + "ng-disabled" => "Cart.dirty || Cart.empty()"} %div.pad-top{bindonce: true} %product.animate-repeat{"ng-controller" => "ProductNodeCtrl", @@ -42,5 +42,5 @@ .small-12.columns %form{action: cart_path} %input.button.primary.right.add_to_cart{type: :submit, value: "Your shopping cart", - "ng-disabled" => "Cart.dirty"} + "ng-disabled" => "Cart.dirty || Cart.empty()"}