mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
send user details on modal dismiss. Role uses same autocomplete lib as institution
This commit is contained in:
parent
533b51146e
commit
0868ce9cc7
3 changed files with 15 additions and 16 deletions
|
@ -149,7 +149,6 @@ script(type="text/ng-template", id="userProfileModalTemplate")
|
||||||
type='text',
|
type='text',
|
||||||
name='first_name',
|
name='first_name',
|
||||||
ng-model="userInfoForm.first_name",
|
ng-model="userInfoForm.first_name",
|
||||||
ng-blur="sendUpdate()",
|
|
||||||
placeholder="First Name",
|
placeholder="First Name",
|
||||||
select-when="formVisable"
|
select-when="formVisable"
|
||||||
)
|
)
|
||||||
|
@ -160,27 +159,29 @@ script(type="text/ng-template", id="userProfileModalTemplate")
|
||||||
type='text',
|
type='text',
|
||||||
name='last_name',
|
name='last_name',
|
||||||
ng-model="userInfoForm.last_name",
|
ng-model="userInfoForm.last_name",
|
||||||
ng-blur="sendUpdate()",
|
|
||||||
placeholder='Last Name'
|
placeholder='Last Name'
|
||||||
)
|
)
|
||||||
|
|
||||||
.form-group#institution_auto_complete
|
.form-group.user_details_auto_complete
|
||||||
label(for="institution") Institution
|
label(for="institution") Institution
|
||||||
autocomplete(
|
autocomplete(
|
||||||
ng-model="userInfoForm.institution",
|
ng-model="userInfoForm.institution",
|
||||||
name="institution",
|
name="institution",
|
||||||
data="institutions",
|
data="institutions",
|
||||||
ng-blur="sendUpdate()",
|
|
||||||
on-type="updateInstitutionsList",
|
on-type="updateInstitutionsList",
|
||||||
attr-placeholder="Institution",
|
attr-placeholder="Institution",
|
||||||
attr-inputclass="form-control"
|
attr-inputclass="form-control"
|
||||||
)
|
)
|
||||||
|
|
||||||
.form-group
|
.form-group.user_details_auto_complete
|
||||||
label(for="role") Role
|
label(for="role") Role
|
||||||
input(type='text', name='role', ng-model="userInfoForm.role", placeholder='Role', ng-blur="sendUpdate()", list="_roles").form-control
|
autocomplete(
|
||||||
datalist#_roles
|
ng-model="userInfoForm.role",
|
||||||
option(ng-repeat='role in roles') {{role}}
|
name="role",
|
||||||
|
data="roles",
|
||||||
|
attr-placeholder="Role",
|
||||||
|
attr-inputclass="form-control"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
.modal-footer
|
.modal-footer
|
||||||
|
|
|
@ -37,7 +37,10 @@ define [
|
||||||
App.controller "UserProfileModalController", ($scope, $modalInstance, $http, Institutions) ->
|
App.controller "UserProfileModalController", ($scope, $modalInstance, $http, Institutions) ->
|
||||||
$scope.roles = ["Student", "Post-graduate student", "Post-doctoral researcher", "Lecturer", "Professor"]
|
$scope.roles = ["Student", "Post-graduate student", "Post-doctoral researcher", "Lecturer", "Professor"]
|
||||||
|
|
||||||
$scope.sendUpdate = ->
|
$modalInstance.result.finally ->
|
||||||
|
sendUpdate()
|
||||||
|
|
||||||
|
sendUpdate = ->
|
||||||
request = $http.post "/user/settings", $scope.userInfoForm
|
request = $http.post "/user/settings", $scope.userInfoForm
|
||||||
request.success (data, status)->
|
request.success (data, status)->
|
||||||
request.error (data, status)->
|
request.error (data, status)->
|
||||||
|
@ -45,14 +48,9 @@ define [
|
||||||
|
|
||||||
$scope.updateInstitutionsList = (inputVal)->
|
$scope.updateInstitutionsList = (inputVal)->
|
||||||
|
|
||||||
# this is a little hack to use until we change auto compelete lib with redesign and can
|
|
||||||
# listen for blur events on institution field to send the post
|
|
||||||
if inputVal?.indexOf("(") != -1 and inputVal?.indexOf(")") != -1
|
|
||||||
$scope.sendUpdate()
|
|
||||||
|
|
||||||
query = $scope.userInfoForm.institution
|
query = $scope.userInfoForm.institution
|
||||||
if query?.length <= 3
|
if query?.length <= 3
|
||||||
return #saves us algolia searches, need ~4 chars to get uni anyway
|
return #saves us algolia searches
|
||||||
|
|
||||||
Institutions.search $scope.userInfoForm.institution, (err, response)->
|
Institutions.search $scope.userInfoForm.institution, (err, response)->
|
||||||
$scope.institutions = _.map response.hits, (institution)->
|
$scope.institutions = _.map response.hits, (institution)->
|
||||||
|
|
|
@ -153,7 +153,7 @@ ul.project-list {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#institution_auto_complete {
|
.user_details_auto_complete {
|
||||||
|
|
||||||
ul>li{
|
ul>li{
|
||||||
list-style:none;
|
list-style:none;
|
||||||
|
|
Loading…
Reference in a new issue