mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Allow multiple collaborators to be added at once with a list of emails
This commit is contained in:
parent
639424f664
commit
34c8f22dd7
2 changed files with 27 additions and 12 deletions
|
@ -48,8 +48,8 @@ script(type='text/ng-template', id='shareProjectModalTemplate')
|
|||
.small #{translate("share_with_your_collabs")}
|
||||
.form-group
|
||||
input.form-control(
|
||||
type="email"
|
||||
placeholder="Enter email address..."
|
||||
type="text"
|
||||
placeholder="joe@example.com, sue@example.com, ..."
|
||||
ng-model="inputs.email"
|
||||
focus-on="open"
|
||||
)
|
||||
|
@ -64,7 +64,7 @@ script(type='text/ng-template', id='shareProjectModalTemplate')
|
|||
|
|
||||
button.btn.btn-info(
|
||||
type="submit"
|
||||
ng-click="addMember()"
|
||||
ng-click="addMembers()"
|
||||
) #{translate("share")}
|
||||
div.text-center(ng-hide="canAddCollaborators")
|
||||
p #{translate("need_to_upgrade_for_more_collabs")}.
|
||||
|
|
|
@ -22,19 +22,34 @@ define [
|
|||
allowedNoOfMembers = $scope.project.features.collaborators
|
||||
$scope.canAddCollaborators = noOfMembers < allowedNoOfMembers or allowedNoOfMembers == INFINITE_COLLABORATORS
|
||||
|
||||
$scope.addMember = () ->
|
||||
$scope.addMembers = () ->
|
||||
return if !$scope.inputs.email? or $scope.inputs.email == ""
|
||||
|
||||
emails = $scope.inputs.email.split(/,\s*/)
|
||||
$scope.inputs.email = ""
|
||||
$scope.state.error = null
|
||||
$scope.state.inflight = true
|
||||
projectMembers
|
||||
.addMember($scope.inputs.email, $scope.inputs.privileges)
|
||||
.success (data) ->
|
||||
|
||||
do addNextMember = () ->
|
||||
if emails.length == 0 or !$scope.canAddCollaborators
|
||||
$scope.state.inflight = false
|
||||
$scope.inputs.email = ""
|
||||
$scope.project.members.push data?.user
|
||||
.error () ->
|
||||
$scope.state.inflight = false
|
||||
$scope.state.error = "Sorry, something went wrong :("
|
||||
$scope.$apply()
|
||||
return
|
||||
|
||||
email = emails.shift()
|
||||
projectMembers
|
||||
.addMember(email, $scope.inputs.privileges)
|
||||
.success (data) ->
|
||||
if data?.user # data.user is false if collaborator limit is hit.
|
||||
$scope.project.members.push data.user
|
||||
setTimeout () ->
|
||||
# Give $scope a chance to update $scope.canAddCollaborators
|
||||
# with new collaborator information.
|
||||
addNextMember()
|
||||
, 0
|
||||
.error () ->
|
||||
$scope.state.inflight = false
|
||||
$scope.state.error = "Sorry, something went wrong :("
|
||||
|
||||
|
||||
$scope.removeMember = (member) ->
|
||||
|
|
Loading…
Reference in a new issue