From 92b98903a0e974437e2789bed1c78f3e68157f3d Mon Sep 17 00:00:00 2001 From: CamilleC <kmille.c.cc@gmail.com> Date: Tue, 17 Jan 2017 11:09:48 +0100 Subject: [PATCH] Cleaning of currency-controllers --- www/js/controllers/currency-controllers.js | 41 +++++++++------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/www/js/controllers/currency-controllers.js b/www/js/controllers/currency-controllers.js index 7706ec738..3f5e38292 100644 --- a/www/js/controllers/currency-controllers.js +++ b/www/js/controllers/currency-controllers.js @@ -73,7 +73,8 @@ function CurrencyLookupController($scope, $state, UIUtils, csCurrency) { }; } -function CurrencyViewController($scope, $q, $translate, $timeout, BMA, UIUtils, csSettings, csCurrency, csNetwork) { +function CurrencyViewController($scope, $q, $translate, $timeout, $filter, + BMA, UIUtils, csSettings, csCurrency, csNetwork) { $scope.formData = { useRelative: csSettings.data.useRelative }; @@ -99,29 +100,21 @@ function CurrencyViewController($scope, $q, $translate, $timeout, BMA, UIUtils, $scope.xpercent = 0; $scope.$on('$ionicView.enter', function(e, state) { - $translate('COMMON.DATE_PATTERN') - .then(function(datePattern) { - $scope.datePattern = datePattern; - if (state.stateParams && state.stateParams.name) { // Load by name - csCurrency.searchByName(state.stateParams.name) - .then(function(currency){ - $scope.load(currency); - }); - } - else { - csCurrency.all() - .then(function (currencies) { - if (currencies && currencies.length > 0) { - $scope.load(currencies[0]); - } - }) - .catch(UIUtils.onError('ERROR.GET_CURRENCY_FAILED')); - } - }); - }); - - $scope.$on('$ionicView.beforeLeave', function(){ - csNetwork.close(); + if (state.stateParams && state.stateParams.name) { // Load by name + csCurrency.searchByName(state.stateParams.name) + .then(function(currency){ + $scope.load(currency); + }); + } + else { + csCurrency.all() + .then(function (currencies) { + if (currencies && currencies.length > 0) { + $scope.load(currencies[0]); + } + }) + .catch(UIUtils.onError('ERROR.GET_CURRENCY_FAILED')); + } }); $scope.load = function(currency) { -- GitLab