From f99ed81863c76b21efb908f123fab2ea1f096f80 Mon Sep 17 00:00:00 2001 From: niko Date: Thu, 4 Oct 2018 11:46:38 +0200 Subject: [PATCH] Make 'Clear All' button work on order cycle page --- .../controllers/order_cycles_controller.js.coffee | 8 ++++++-- .../controllers/order_cycles_controller_spec.js.coffee | 10 ++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/admin/order_cycles/controllers/order_cycles_controller.js.coffee b/app/assets/javascripts/admin/order_cycles/controllers/order_cycles_controller.js.coffee index 75f379856d0..7ed549e5258 100644 --- a/app/assets/javascripts/admin/order_cycles/controllers/order_cycles_controller.js.coffee +++ b/app/assets/javascripts/admin/order_cycles/controllers/order_cycles_controller.js.coffee @@ -3,8 +3,12 @@ angular.module("admin.orderCycles").controller "OrderCyclesCtrl", ($scope, $q, C $scope.columns = Columns.columns $scope.saveAll = -> OrderCycles.saveChanges($scope.order_cycles_form) $scope.ordersCloseAtLimit = -31 # days - $scope.involvingFilter = 0 - $scope.scheduleFilter = 0 + + $scope.resetSelectFilters = -> + $scope.scheduleFilter = 0 + $scope.involvingFilter = 0 + $scope.query = '' + $scope.resetSelectFilters() compileData = -> for schedule in $scope.schedules diff --git a/spec/javascripts/unit/admin/order_cycles/controllers/order_cycles_controller_spec.js.coffee b/spec/javascripts/unit/admin/order_cycles/controllers/order_cycles_controller_spec.js.coffee index 4c36884c0a4..c66bc43dfab 100644 --- a/spec/javascripts/unit/admin/order_cycles/controllers/order_cycles_controller_spec.js.coffee +++ b/spec/javascripts/unit/admin/order_cycles/controllers/order_cycles_controller_spec.js.coffee @@ -72,3 +72,13 @@ describe "OrderCyclesCtrl", -> it "the RequestMonitor will not longer have a state of loading", -> expect(scope.RequestMonitor.loading).toBe false + + describe "filtering order cycles", -> + it "filters by and resets filter variables", -> + scope.query = "test" + scope.scheduleFilter = 1 + scope.involvingFilter = 1 + scope.resetSelectFilters() + expect(scope.query).toBe "" + expect(scope.scheduleFilter).toBe 0 + expect(scope.involvingFilter).toBe 0 \ No newline at end of file