From cc58763cf182ec18efeb374bee0d9091dfb647df Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Tue, 8 Sep 2020 09:40:30 -0400 Subject: use stateChange inside EventCtrl to clear filters instead of rootScope https://github.com/pliablepixels/zmNinja/commit/ace86431e16405d5b4e3bb78fab4f82c3cb6f980#commitcomment-42123734 --- www/js/EventCtrl.js | 28 +++++++++++++++------------- www/js/EventDateTimeFilterCtrl.js | 5 +---- www/js/app.js | 1 - www/templates/events-popover.html | 2 +- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/www/js/EventCtrl.js b/www/js/EventCtrl.js index 02c22cc3..909830c3 100644 --- a/www/js/EventCtrl.js +++ b/www/js/EventCtrl.js @@ -180,21 +180,23 @@ angular.module('zmApp.controllers') } + $scope.$on("$stateChangeStart", function(event, toState){ + // clear the seach except when we are going to /events-date-time-filter + if (toState.url != "/events-date-time-filter") { + NVR.debug ("removing montage temporary filter"); + $rootScope.isEventFilterOn = false; + $rootScope.fromDate = ""; + $rootScope.fromTime = ""; + $rootScope.toDate = ""; + $rootScope.toTime = ""; + $rootScope.fromString = ""; + $rootScope.toString = ""; + $rootScope.monitorsFilter=""; + } + + }); $scope.$on('$ionicView.beforeLeave', function () { - //$window.removeEventListener('orientationchange', updateUI); - - if ($stateParams.lastCheckTime != undefined && $stateParams.lastCheckTime != '' && moment($stateParams.lastCheckTime).isValid() && !$rootScope.enteringEventFilter) { - NVR.debug ("removing montage temporary filter"); - $rootScope.isEventFilterOn = false; - $rootScope.fromDate = ""; - $rootScope.fromTime = ""; - $rootScope.toDate = ""; - $rootScope.toTime = ""; - $rootScope.fromString = ""; - $rootScope.toString = ""; - $rootScope.monitorsFilter=""; - } NVR.debug ("Cancelling page reload timer"); $interval.cancel(intervalReloadEvents); document.removeEventListener("pause", onPause, false); diff --git a/www/js/EventDateTimeFilterCtrl.js b/www/js/EventDateTimeFilterCtrl.js index 733d6263..28779310 100644 --- a/www/js/EventDateTimeFilterCtrl.js +++ b/www/js/EventDateTimeFilterCtrl.js @@ -25,10 +25,7 @@ angular.module('zmApp.controllers') } }; - $scope.$on('$ionicView.beforeLeave', function () { - $rootScope.enteringEventFilter=false; - }); - + $scope.$on('$ionicView.beforeEnter', function () { $scope.today = moment().format("YYYY-MM-DD"); $scope.monitors = NVR.getMonitorsNow(); diff --git a/www/js/app.js b/www/js/app.js index 60b1fd30..c35d52aa 100755 --- a/www/js/app.js +++ b/www/js/app.js @@ -1139,7 +1139,6 @@ angular.module('zmApp', [ - $rootScope.enteringEventFilter=false; $rootScope.dpadId = 0; $rootScope.textScaleFactor = 1.0; $rootScope.isLoggedIn = false; diff --git a/www/templates/events-popover.html b/www/templates/events-popover.html index 73629ef7..923d693f 100644 --- a/www/templates/events-popover.html +++ b/www/templates/events-popover.html @@ -1,7 +1,7 @@