Skip to content
Snippets Groups Projects
Commit 92b98903 authored by CamilleC's avatar CamilleC
Browse files

Cleaning of currency-controllers

parent 5ddef2c0
No related branches found
No related tags found
1 merge request!257Add filters in node's list
...@@ -73,7 +73,8 @@ function CurrencyLookupController($scope, $state, UIUtils, csCurrency) { ...@@ -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 = { $scope.formData = {
useRelative: csSettings.data.useRelative useRelative: csSettings.data.useRelative
}; };
...@@ -99,29 +100,21 @@ function CurrencyViewController($scope, $q, $translate, $timeout, BMA, UIUtils, ...@@ -99,29 +100,21 @@ function CurrencyViewController($scope, $q, $translate, $timeout, BMA, UIUtils,
$scope.xpercent = 0; $scope.xpercent = 0;
$scope.$on('$ionicView.enter', function(e, state) { $scope.$on('$ionicView.enter', function(e, state) {
$translate('COMMON.DATE_PATTERN') if (state.stateParams && state.stateParams.name) { // Load by name
.then(function(datePattern) { csCurrency.searchByName(state.stateParams.name)
$scope.datePattern = datePattern; .then(function(currency){
if (state.stateParams && state.stateParams.name) { // Load by name $scope.load(currency);
csCurrency.searchByName(state.stateParams.name) });
.then(function(currency){ }
$scope.load(currency); else {
}); csCurrency.all()
} .then(function (currencies) {
else { if (currencies && currencies.length > 0) {
csCurrency.all() $scope.load(currencies[0]);
.then(function (currencies) { }
if (currencies && currencies.length > 0) { })
$scope.load(currencies[0]); .catch(UIUtils.onError('ERROR.GET_CURRENCY_FAILED'));
} }
})
.catch(UIUtils.onError('ERROR.GET_CURRENCY_FAILED'));
}
});
});
$scope.$on('$ionicView.beforeLeave', function(){
csNetwork.close();
}); });
$scope.load = function(currency) { $scope.load = function(currency) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment