mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Working reloading of products, changing order cycles, sticky state
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
Shop.factory 'OrderCycle', ($resource, Product) ->
|
||||
new class OrderCycle
|
||||
@order_cycle:
|
||||
class OrderCycle
|
||||
@order_cycle = {
|
||||
order_cycle_id: null
|
||||
}
|
||||
|
||||
set_order_cycle: (id = null)->
|
||||
new $resource("/shop/order_cycle").save {order_cycle_id: id}, ->
|
||||
@set_order_cycle: ->
|
||||
new $resource("/shop/order_cycle").save {order_cycle_id: @order_cycle.order_cycle_id}, ->
|
||||
Product.update()
|
||||
|
||||
|
||||
@@ -3,5 +3,7 @@ Shop.factory 'Product', ($resource) ->
|
||||
@products: null
|
||||
update: ->
|
||||
@products = $resource("/shop/products").query()
|
||||
console.log @products
|
||||
@products
|
||||
all: ->
|
||||
@products || @update()
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
window.Shop = angular.module("Shop", ["ngResource"])
|
||||
window.Shop = angular.module("Shop", ["ngResource"]).config ($httpProvider) ->
|
||||
$httpProvider.defaults.headers.post['X-CSRF-Token'] = $('meta[name="csrf-token"]').attr('content')
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
%ordercycle{"ng-controller" => "OrderCycleCtrl"}
|
||||
- if @order_cycles.empty?
|
||||
Orders are currently closed for this hub
|
||||
%p Please contact your hub directly to see if they accept late orders, or wait until the next cycle opens.
|
||||
%p
|
||||
Please contact your hub directly to see if they accept late orders,
|
||||
or wait until the next cycle opens.
|
||||
|
||||
= render partial: "shop/next_order_cycle"
|
||||
= render partial: "shop/last_order_cycle"
|
||||
@@ -9,6 +11,6 @@
|
||||
- else
|
||||
Ready for:
|
||||
%select{"ng-model" => "order_cycle.order_cycle_id",
|
||||
"ng-init" => "order_cycle.order_cycle_id = #{current_order_cycle.id}",
|
||||
"ng-change" => "changeOrderCycle()",
|
||||
"ng-options" => "c for c in #{@order_cycles.map {|oc| oc.id}.to_json}"}
|
||||
|
||||
|
||||
@@ -13,6 +13,13 @@ describe ShopController do
|
||||
controller.stub(:current_distributor).and_return d
|
||||
end
|
||||
|
||||
describe "Fetching products" do
|
||||
it "should return products for the current order cycle" do
|
||||
spree_get :products
|
||||
end
|
||||
it "should not return other products"
|
||||
end
|
||||
|
||||
describe "Selecting order cycles" do
|
||||
it "should select an order cycle when only one order cycle is open" do
|
||||
oc1 = create(:order_cycle, distributors: [d])
|
||||
|
||||
Reference in New Issue
Block a user