diff --git a/src/app/search/directive/search_results.js b/src/app/search/directive/search_results.js index b2df3875..318a467f 100644 --- a/src/app/search/directive/search_results.js +++ b/src/app/search/directive/search_results.js @@ -20,7 +20,7 @@ * @see ProjectListController */ angular.module('sb.search').directive('searchResults', - function ($log, $parse, Criteria, $injector, Preference) { + function ($log, $parse, Criteria, $injector, Preference, User) { 'use strict'; return { @@ -36,6 +36,41 @@ angular.module('sb.search').directive('searchResults', args.searchWithoutCriteria === 'true'; var criteria = []; + //Controls dropdown events + $scope.dropdownControl = function(choice){ + if (choice === 'open'){ + angular.element(document.querySelector('#query')) + .addClass('open'); + return; + } + angular.element(document.querySelector('#query')) + .removeClass('open'); + }; + + //Controls which columns are chosen + $scope.columnControl = function(filter){ + if ($scope.chosenCriteria.includes(filter)){ + $scope.chosenCriteria.splice($scope.chosenCriteria + .indexOf(filter), 1); + return; + } + $scope.chosenCriteria.push(filter); + }; + + //Dropdown Options + $scope.queryFilters = { + 'created_at': 'Created At', + 'updated_at': 'Updated At', + 'status': 'Status', + 'private': 'Private', + 'creator_id': 'Creator' + + }; + + + $scope.chosenCriteria = ['created_at', 'updated_at', 'status']; + $scope.timeCriteria = ['created_at', 'updated_at']; + $scope.isSearching = false; $scope.searchResults = []; @@ -53,6 +88,16 @@ angular.module('sb.search').directive('searchResults', */ $scope.sortDirection = 'desc'; + function showFullName(story_object){ + var full_name; + story_object.forEach(function(story){ + full_name = User.get({'id': story.creator_id}); + full_name.$promise.then(function(data){ + story.creator_id = data.full_name; + }); + }); + } + /** * Handle error result. */ @@ -71,6 +116,7 @@ angular.module('sb.search').directive('searchResults', $scope.searchOffset = parseInt(headers('X-Offset')) || 0; $scope.searchLimit = parseInt(headers('X-Limit')) || 0; $scope.searchResults = results; + showFullName($scope.searchResults); $scope.isSearching = false; } diff --git a/src/app/search/template/story_search_item.html b/src/app/search/template/story_search_item.html index 27a38027..fc1e7ae6 100644 --- a/src/app/search/template/story_search_item.html +++ b/src/app/search/template/story_search_item.html @@ -1,9 +1,9 @@ -