mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Renaming Product to Products and starting to figure out cart
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
Darkswarm.controller "CartCtrl", ($scope, CurrentOrder) ->
|
||||
$scope.CurrentOrder = CurrentOrder
|
||||
Darkswarm.controller "CartCtrl", ($scope, Cart) ->
|
||||
$scope.Cart = Cart
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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)->
|
||||
|
||||
@@ -3,3 +3,5 @@ Darkswarm.factory 'Cart', (CurrentOrder)->
|
||||
new class Cart
|
||||
order: CurrentOrder.order
|
||||
|
||||
# How to structure this?
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Darkswarm.factory 'Product', ($resource, Enterprises, Dereferencer, Taxons) ->
|
||||
Darkswarm.factory 'Products', ($resource, Enterprises, Dereferencer, Taxons) ->
|
||||
new class Products
|
||||
constructor: ->
|
||||
@update()
|
||||
@@ -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)
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
%span.nav-branded
|
||||
%i.ofn-i_027-shopping-cart
|
||||
%span
|
||||
{{ CurrentOrder.cart_count }}
|
||||
{{ Cart.order.line_items.length }}
|
||||
items
|
||||
|
||||
@@ -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"}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user