mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
Order cycle filter resets date filters on BOM
This commit is contained in:
@@ -49,6 +49,8 @@ angular.module("ofn.admin").controller "AdminOrderMgmtCtrl", [
|
||||
$scope.distributors.unshift blankOption()
|
||||
ocFetcher = dataFetcher("/api/order_cycles/accessible?as=distributor&q[orders_close_at_gt]=#{formatDate(daysFromToday(-90))}").then (data) ->
|
||||
$scope.orderCycles = data
|
||||
$scope.orderCyclesByID = []
|
||||
$scope.orderCyclesByID[oc.id] = oc for oc in $scope.orderCycles
|
||||
$scope.orderCycles.unshift blankOption()
|
||||
$scope.fetchOrders()
|
||||
ocFetcher.then ->
|
||||
@@ -162,6 +164,11 @@ angular.module("ofn.admin").controller "AdminOrderMgmtCtrl", [
|
||||
$scope.supplierFilter = $scope.suppliers[0].id
|
||||
$scope.orderCycleFilter = $scope.orderCycles[0].id
|
||||
$scope.quickSearch = ""
|
||||
|
||||
$scope.$watch "orderCycleFilter", (newVal, oldVal) ->
|
||||
unless $scope.orderCycleFilter == "0" || angular.equals(newVal, oldVal)
|
||||
$scope.startDate = $scope.orderCyclesByID[$scope.orderCycleFilter].first_order
|
||||
$scope.endDate = $scope.orderCyclesByID[$scope.orderCycleFilter].last_order
|
||||
]
|
||||
|
||||
daysFromToday = (days) ->
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
object @order_cycle
|
||||
|
||||
attributes :id, :name
|
||||
node( :first_order ) { |order| order.orders_open_at.strftime("%F") }
|
||||
node( :last_order ) { |order| (order.orders_close_at + 1.day).strftime("%F") }
|
||||
node( :suppliers ) do |oc|
|
||||
partial 'api/enterprises/bulk_index', :object => oc.suppliers
|
||||
end
|
||||
node( :distributors ) do |oc|
|
||||
partial 'api/enterprises/bulk_index', :object => oc.distributors
|
||||
end
|
||||
end
|
||||
|
||||
@@ -43,7 +43,7 @@ describe "AdminOrderMgmtCtrl", ->
|
||||
describe "fetching orders", ->
|
||||
beforeEach ->
|
||||
scope.initialiseVariables()
|
||||
httpBackend.expectGET("/api/orders/managed?template=bulk_index;page=1;per_page=500;q[completed_at_not_null]=true;q[completed_at_gt]=SomeDate;q[completed_at_lt]=SomeDate").respond "list of orders"
|
||||
httpBackend.expectGET("/api/orders/managed?template=bulk_index;page=1;per_page=500;q[state_not_eq]=canceled;q[completed_at_not_null]=true;q[completed_at_gt]=SomeDate;q[completed_at_lt]=SomeDate").respond "list of orders"
|
||||
|
||||
it "makes a call to dataFetcher, with current start and end date parameters", ->
|
||||
scope.fetchOrders()
|
||||
|
||||
Reference in New Issue
Block a user