From c88d01cbe606429f16b2392d4fdc6ffa87857778 Mon Sep 17 00:00:00 2001 From: Stef Date: Mon, 15 Jan 2018 17:59:39 +1300 Subject: [PATCH] Small changes to .js files --- dplace_app/static/js/controllers/search.js | 8 ++++---- dplace_app/static/js/controllers/search/variable.js | 2 +- dplace_app/static/js/searchModelService.js | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/dplace_app/static/js/controllers/search.js b/dplace_app/static/js/controllers/search.js index 11912134..68aebd4b 100644 --- a/dplace_app/static/js/controllers/search.js +++ b/dplace_app/static/js/controllers/search.js @@ -83,8 +83,10 @@ function SearchCtrl($scope, $window, $location, colorMapService, searchModelServ break; case 'environmental': index = $scope.searchModel.getEnvironmentalData().selectedVariables.indexOf(object); - $scope.searchModel.getEnvironmentalData().selectedVariables.splice(index, 1); - $scope.searchModel.getEnvironmentalData().badgeValue = $scope.searchModel.getEnvironmentalData().selectedVariables.length; + if (index > -1) { + $scope.searchModel.getEnvironmentalData().selectedVariables.splice(index, 1); + $scope.searchModel.getEnvironmentalData().badgeValue = $scope.searchModel.getEnvironmentalData().selectedVariables.length; + } break; case 'family': var langSelectedObjs = $scope.searchModel.getLanguageClassifications().selected; @@ -126,9 +128,7 @@ function SearchCtrl($scope, $window, $location, colorMapService, searchModelServ variable = $scope.searchModel.getEnvironmentalData().selectedVariables.map(function(v) { return v.selectedVariable.id; }).indexOf(object.variable); if (variable > -1) { $scope.searchModel.getEnvironmentalData().selectedVariables[variable].selectedVariable.allSelected = false; - } - } break; case 'variable': diff --git a/dplace_app/static/js/controllers/search/variable.js b/dplace_app/static/js/controllers/search/variable.js index ab05a7b4..4deeab8c 100644 --- a/dplace_app/static/js/controllers/search/variable.js +++ b/dplace_app/static/js/controllers/search/variable.js @@ -7,7 +7,7 @@ function VariableSearchCtrl($scope, searchModelService, getCategories, Variable, } else { $scope.variables = searchModelService.getModel().getEnvironmentalData().selectedVariables; if ($scope.variables.length == 0) { - $scope.variables.push({'vals': ['', ''], 'selectedFilter': $scope.filters[0], 'variables': [], 'categories': []}); + $scope.variables.push({'vals': ['', ''], 'selectedFilter': $scope.filters[0], 'categories': []}); $scope.variables[0].categories = searchModelService.getModel().getEnvironmentalData().categories; } } diff --git a/dplace_app/static/js/searchModelService.js b/dplace_app/static/js/searchModelService.js index 8af061a4..e36691b3 100644 --- a/dplace_app/static/js/searchModelService.js +++ b/dplace_app/static/js/searchModelService.js @@ -112,7 +112,6 @@ function SearchModelService(VariableCategory, GeographicRegion, LanguageFamily, } else { container.society.style = {'background-color': results.geographic_regions.codes[container.society.region.tdwg_code]}; } - }); }