From f4d359c390a81cbd91a228a248fa1dcc9ab35bc0 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 26 Sep 2017 12:03:20 +0200 Subject: [PATCH] SUPPORT-1236: Fixed subject links in search results --- .../js/loopSearchBoxController.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/loop_search_node/js/loopSearchBoxController.js b/modules/loop_search_node/js/loopSearchBoxController.js index fcf9176c..bb1c7662 100644 --- a/modules/loop_search_node/js/loopSearchBoxController.js +++ b/modules/loop_search_node/js/loopSearchBoxController.js @@ -240,7 +240,20 @@ angular.module('searchBoxApp').controller('loopSearchBoxController', ['CONFIG', function filterUpdated(data) { $scope.query.text = ''; - delete $scope.query.filters['taxonomy'][data['filter']]; + // Ensure that data structure exists in the search query before accessing + // it. + if (!$scope.query.hasOwnProperty('filters')) { + $scope.query.filters = { + 'taxonomy': {} + } + } + if (!$scope.query.filters.hasOwnProperty('taxonomy')) { + $scope.query.filter.taxonomy = { } + } + + if ($scope.query.filters.taxonomy.hasOwnProperty(data['filter'])) { + delete $scope.query.filters['taxonomy'][data['filter']]; + } $scope.query.filters['taxonomy'][data['filter']] = {}; $scope.query.filters['taxonomy'][data['filter']][data['selection']] = true;