Skip to content

Commit 50d64d5

Browse files
author
Tim Levett
committed
Merge pull request uPortal-Attic#132 from UW-Madison-DoIT/typeahead_to_search_beta_feature
MUMUP-1079 : Typeahead to search beta feature
2 parents fb02401 + 2e9b26e commit 50d64d5

File tree

16 files changed

+325
-93
lines changed

16 files changed

+325
-93
lines changed

angularjs-portal-frame/src/main/webapp/css/buckyless/header.less

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
.bucky-nav-large li:first-of-type+li{
22
position:absolute;width:30%;left:35%
33
}
4+
.portlet-search-bar ul.dropdown-menu {
5+
min-width: 90%;
6+
7+
li:first-of-type+li {
8+
position: relative;
9+
width: inherit;
10+
left: 0;
11+
}
12+
}
413
#myuw-header span {
514
font-size:25px;
615
}

angularjs-portal-frame/src/main/webapp/frame.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
<script type="text/javascript" src="js/sortable.js"></script>
6363
<script type="text/javascript" src="js/angular-page.js"></script>
6464
<script type="text/javascript" src="js/main/main-controllers.js"></script>
65+
<script type="text/javascript" src="js/main/search-controller.js"></script>
6566
<script type="text/javascript" src="js/main/main-service.js"></script>
6667
<script type="text/javascript" src="js/main/main-directives.js"></script>
6768
<script type="text/javascript" src="js/controllers.js"></script>

angularjs-portal-frame/src/main/webapp/js/angular-page.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
'portal.misc.service',
1212
'portal.main.controllers',
1313
'portal.main.service',
14-
'portal.main.directives'
14+
'portal.main.directives',
15+
'portal.search.controllers',
1516
]);
1617
app.config(['$routeProvider',function($routeProvider, $locationProvider) {
1718
$routeProvider.

angularjs-portal-frame/src/main/webapp/js/main/main-controllers.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
sidebarShowProfile: false,
1414
profileImg: "img/terrace.jpg",
1515
notificationsDemo : false,
16-
pithyContentOnHome : false } );
16+
pithyContentOnHome : false,
17+
typeaheadSearch: false} );
1718
} ]);
1819

1920
/* Username */
@@ -22,7 +23,7 @@
2223
var that = this;
2324
that.user = [];
2425
mainService.getUser().then(function(result){
25-
that.user = result.data.person;
26+
that.user = result;
2627
});
2728
}]);
2829

@@ -31,14 +32,6 @@
3132
this.navbarCollapsed = true;
3233
$scope.showSearch = false;
3334
$scope.showSearchFocus = false;
34-
$scope.submit = function(){
35-
if($scope.initialFilter != "") {
36-
$location.path("/apps/search/"+ $scope.initialFilter);
37-
$scope.initialFilter = "";
38-
$scope.showSearch = false;
39-
$scope.showSearchFocus = false;
40-
}
41-
};
4235

4336
this.toggleSearch = function() {
4437
$scope.showSearch = !$scope.showSearch;

angularjs-portal-frame/src/main/webapp/js/main/main-directives.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818
}
1919
});
2020

21-
app.directive('search', function() {
21+
app.directive('search', [function() {
2222
return {
2323
restrict : 'E',
24-
templateUrl : 'partials/search.html'
24+
templateUrl : 'partials/search.html',
25+
controller: 'SearchController'
2526
}
26-
});
27+
}]);
2728

2829
app.directive('username', function() {
2930
return {

angularjs-portal-frame/src/main/webapp/js/main/main-service.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,24 @@
33
(function() {
44
var app = angular.module('portal.main.service', []);
55

6-
app.factory('mainService', function($http, miscService) {
6+
app.factory('mainService', ['$http', 'miscService', function($http, miscService) {
77
var prom = $http.get('/portal/api/session.json', { cache: true});
88
var sidebarPromise = $http.get('/web/samples/sidebar.json');
9+
var userPromise;
910

1011
var getUser = function() {
11-
return prom.success(
12+
if (userPromise) {
13+
return userPromise;
14+
}
15+
16+
userPromise = prom.then(
1217
function(data, status) { //success function
13-
return data.person;
14-
}).error(function(data, status) { // failure function
18+
return data.data.person;
19+
}, function(data, status) { // failure function
1520
miscService.redirectUser(status, "Get User Info");
1621
});
17-
}
22+
return userPromise;
23+
};
1824

1925
var getSidebar = function() {
2026
return sidebarPromise.success(
@@ -23,13 +29,13 @@ app.factory('mainService', function($http, miscService) {
2329
}).error(function(data, status) { // failure function
2430
miscService.redirectUser(status, "Get sidebar info");
2531
});
26-
}
32+
};
2733

2834
return {
2935
getUser: getUser,
3036
getSidebar : getSidebar
31-
}
37+
};
3238

33-
});
39+
}]);
3440

3541
})();
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
'use strict';
2+
3+
(function() {
4+
var app = angular.module('portal.search.controllers', []);
5+
app.controller('SearchController', [ 'miscService', '$location', '$scope', '$localStorage', function(miscService, $location, $scope, $localStorage) {
6+
$scope.initialFilter = '';
7+
$scope.filterMatches = [];
8+
$scope.portletListLoading = true;
9+
if($localStorage && $localStorage.typeaheadSearch) {
10+
//TODO : Add in search for somewhere for frame
11+
}
12+
13+
$scope.$watch('initialFilter', function(newVal, oldVal) {
14+
if (!newVal || !$scope.portlets) {
15+
$scope.filterMatches = [];
16+
return;
17+
}
18+
19+
$scope.filterMatches = [];//this is where you would run your filter function
20+
});
21+
22+
$scope.onSelect = function(portlet) {
23+
$location.path("/apps/search/"+ portlet.name);
24+
$scope.initialFilter = "";
25+
$scope.showSearch = false;
26+
$scope.showSearchFocus = false;
27+
};
28+
29+
$scope.submit = function(){
30+
if($scope.initialFilter != "") {
31+
$location.path("/apps/search/"+ $scope.initialFilter);
32+
$scope.initialFilter = "";
33+
$scope.showSearch = false;
34+
$scope.showSearchFocus = false;
35+
}
36+
};
37+
}]);
38+
})();

angularjs-portal-frame/src/main/webapp/js/services.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ app.factory('miscService', function($http, $window, $location) {
3434
return {
3535
redirectUser: redirectUser,
3636
pushPageview: pushPageview,
37-
pushGAEvent : pushGAEvent
37+
pushGAEvent : pushGAEvent,
3838
}
3939

4040
});

angularjs-portal-frame/src/main/webapp/partials/search.html

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
11
<form ng-submit="submit()">
2-
<div class="input-group">
3-
<input type="search" class="main-search" placeholder="Search MyUW" name="initialFilter" ng-model="initialFilter" aria-label="Search MyUW" focus-me="showSearchFocus">
2+
<div class="input-group portlet-search-bar">
3+
<input type="search" class="main-search"
4+
placeholder="Search MyUW"
5+
name="initialFilter"
6+
ng-model="initialFilter"
7+
aria-label="Search MyUW"
8+
focus-me="showSearchFocus"
9+
ng-show="$storage.typeaheadSearch"
10+
typeahead="title as match.title for match in filterMatches | limitTo:10"
11+
typeahead-on-select="onSelect($item, $model, $label)"
12+
typeahead-loading="portletListLoading"
13+
typeahead-min-length="2"
14+
typeahead-focus-first='false'
15+
autocomplete="off" >
16+
17+
<input type="search" class="main-search"
18+
placeholder="Search MyUW"
19+
name="initialFilter"
20+
ng-model="initialFilter"
21+
aria-label="Search MyUW"
22+
focus-me="showSearchFocus"
23+
ng-hide="$storage.typeaheadSearch"
24+
autocomplete="off" />
25+
26+
427
<span class="input-group-btn">
528
<button class="btn btn-default btn-search">
629
<i class="fa fa-search"></i>

angularjs-portal-home/src/main/webapp/home.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
<script type="text/javascript" src="js/sortable.js"></script>
6363
<script type="text/javascript" src="js/angular-page.js"></script>
6464
<script type="text/javascript" src="js/main/main-controllers.js"></script>
65+
<script type="text/javascript" src="js/main/search-controller.js"></script>
6566
<script type="text/javascript" src="js/main/main-service.js"></script>
6667
<script type="text/javascript" src="js/main/main-directives.js"></script>
6768
<script type="text/javascript" src="js/layout/layout-controller.js"></script>

0 commit comments

Comments
 (0)