mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-07 07:36:58 +00:00
Building out and testing our Product and OrderCycle Angular stuff
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#Shop.controller "OrderCycleCtrl", ($scope, OrderCycle) ->
|
||||
|
||||
#$scope.setOrderCycle = ()->
|
||||
#console.log "foo"
|
||||
##OrderCycle.
|
||||
Shop.controller "OrderCycleCtrl", ($scope, $rootScope, OrderCycle) ->
|
||||
$scope.order_cycle = OrderCycle.order_cycle
|
||||
$scope.changeOrderCycle = ->
|
||||
OrderCycle.set_order_cycle()
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
angular.module("Shop").controller "ProductsCtrl", ($scope, Product) ->
|
||||
angular.module("Shop").controller "ProductsCtrl", ($scope, $rootScope, Product) ->
|
||||
$scope.products = Product.all()
|
||||
|
||||
|
||||
#$scope.order_cycle = OrderCycle.order_cycle
|
||||
#$scope.updateProducts = ->
|
||||
#$scope.products = Product.all()
|
||||
#$scope.$watch "order_cycle.order_cycle_id", $scope.updateProducts
|
||||
#$scope.updateProducts()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
Shop.factory 'OrderCycle', ($resource) ->
|
||||
class OrderCycle
|
||||
@set_order_cycle: (id)->
|
||||
new $resource("/shop/order_cycle").$save () ->
|
||||
console.log "pushed"
|
||||
# Push id to endpoint
|
||||
Shop.factory 'OrderCycle', ($resource, Product) ->
|
||||
new class OrderCycle
|
||||
@order_cycle = {
|
||||
order_cycle_id: null
|
||||
}
|
||||
|
||||
set_order_cycle: (id = null)->
|
||||
new $resource("/shop/order_cycle").save {order_cycle_id: id}, ->
|
||||
Product.update()
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
Shop.factory 'Product', ($resource) ->
|
||||
class Product
|
||||
@all: ->
|
||||
response = $resource("/shop/products").query()
|
||||
|
||||
new class Product
|
||||
@products: null
|
||||
update: ->
|
||||
@products = $resource("/shop/products").query()
|
||||
all: ->
|
||||
@products || @update()
|
||||
|
||||
Reference in New Issue
Block a user