Przeglądaj źródła

got autocomplete presented correctly

Henry Oswald 12 lat temu
rodzic
commit
09f5a67f9b

+ 7 - 1
services/web/app/views/project/list.jade

@@ -124,7 +124,13 @@ block content
 											.input
 												input(type='text', name='last_name', ng-model="userInfoForm.last_name", ng-blur="sendUpdate()", placeholder='Last Name')
 											.input
-												input(type='text', name='institution',  ng-model="userInfoForm.institution", placeholder='Institution', ng-blur="sendUpdate()")
+												input(type='text', name='institution',  ng-model="userInfoForm.institution", placeholder='Institution', ng-blur="sendUpdate()", ng-keyup="updateInstitutionsList()", list="_institutions")
+												datalist#_institutions
+													option(ng-repeat='institution in institutions') {{institution.name}}
+
+
+
+
 											.input
 												input(type='text', name='role',  ng-model="userInfoForm.role", placeholder='Role', ng-blur="sendUpdate()")
 					.span3

+ 9 - 2
services/web/public/coffee/UserDetailsUpdater.coffee

@@ -1,9 +1,12 @@
-define ["libs/angular"], (a)->
+define ["libs/algolia", "libs/typeahead", "libs/angular"], (algolia)->
 
 	app = angular.module("userProfileInformationApp", [])
 
-	app.controller "UpdateForm", ($scope, $http)->
+	app.factory "Institutions", ->
+		new AlgoliaSearch("SK53GL4JLY", "75dc5e65794cd47eb7f725e6bb5075be").initIndex("institutions")
 
+	app.controller "UpdateForm", ($scope, $http, Institutions)->
+		$scope.institutions = 
 		$scope.hidePersonalInfoSection = true
 
 		$http.get("/user/personal_info").success (data)->
@@ -30,5 +33,9 @@ define ["libs/angular"], (a)->
 			results = _.filter $scope.userInfoForm, (value)-> value? and value?.length != 0
 			results.length * 20
 
+		$scope.updateInstitutionsList = ->
+			Institutions.search $scope.userInfoForm.institution, (err, response)->
+				$scope.institutions = response.hits
+
 	angular.bootstrap(document.getElementById("userProfileInformation"), ['userProfileInformationApp'])