Resend invitations
parent
553096c496
commit
8d0cb8c54f
|
@ -257,72 +257,6 @@ MembershipsRowAvatarDirective = ($log) ->
|
||||||
module.directive("tgMembershipsRowAvatar", ["$log", MembershipsRowAvatarDirective])
|
module.directive("tgMembershipsRowAvatar", ["$log", MembershipsRowAvatarDirective])
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
|
||||||
## Member Actions Directive
|
|
||||||
#############################################################################
|
|
||||||
|
|
||||||
MembershipsRowActionsDirective = ($log, $repo, $confirm) ->
|
|
||||||
activedTemplate = _.template("""
|
|
||||||
<div class="active">
|
|
||||||
Active
|
|
||||||
</div>
|
|
||||||
<a class="delete" href="">
|
|
||||||
<span class="icon icon-delete"></span>
|
|
||||||
</a>
|
|
||||||
""") # i18n
|
|
||||||
|
|
||||||
pendingTemplate = _.template("""
|
|
||||||
<a class="pending" href="">
|
|
||||||
Pending
|
|
||||||
<span class="icon icon-reload"></span>
|
|
||||||
</a>
|
|
||||||
<a class="delete" href="" title="Delete">
|
|
||||||
<span class="icon icon-delete"></span>
|
|
||||||
</a>
|
|
||||||
""") # i18n
|
|
||||||
|
|
||||||
link = ($scope, $el, $attrs) ->
|
|
||||||
render = (member) ->
|
|
||||||
if member.user
|
|
||||||
html = activedTemplate()
|
|
||||||
else
|
|
||||||
html = pendingTemplate()
|
|
||||||
|
|
||||||
$el.html(html)
|
|
||||||
|
|
||||||
if not $attrs.tgMembershipsRowActions?
|
|
||||||
return $log.error "MembershipsRowActionsDirective: the directive need a member"
|
|
||||||
|
|
||||||
$ctrl = $el.controller()
|
|
||||||
member = $scope.$eval($attrs.tgMembershipsRowActions)
|
|
||||||
render(member)
|
|
||||||
|
|
||||||
$el.on "click", ".pending", (event) ->
|
|
||||||
event.preventDefault()
|
|
||||||
#TODO: Re-send the invitation
|
|
||||||
console.log "re-sending the invitation to #{member.email}"
|
|
||||||
|
|
||||||
$el.on "click", ".delete", (event) ->
|
|
||||||
event.preventDefault()
|
|
||||||
|
|
||||||
title = "Delete member" # i18n
|
|
||||||
subtitle = if member.user then member.full_name else "the invitation to #{member.email}" # i18n
|
|
||||||
|
|
||||||
$confirm.ask(title, subtitle).then ->
|
|
||||||
$repo.remove(member).then ->
|
|
||||||
$ctrl.loadMembers()
|
|
||||||
$confirm.notify("success", null, "We've deleted #{subtitle}.") # i18n
|
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
|
||||||
$el.off()
|
|
||||||
|
|
||||||
return {link: link}
|
|
||||||
|
|
||||||
|
|
||||||
module.directive("tgMembershipsRowActions", ["$log", "$tgRepo", "$tgConfirm",
|
|
||||||
MembershipsRowActionsDirective])
|
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## Member IsAdminCheckbox Directive
|
## Member IsAdminCheckbox Directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
@ -422,3 +356,74 @@ MembershipsRowRoleSelectorDirective = ($log, $repo, $confirm) ->
|
||||||
|
|
||||||
module.directive("tgMembershipsRowRoleSelector", ["$log", "$tgRepo", "$tgConfirm",
|
module.directive("tgMembershipsRowRoleSelector", ["$log", "$tgRepo", "$tgConfirm",
|
||||||
MembershipsRowRoleSelectorDirective])
|
MembershipsRowRoleSelectorDirective])
|
||||||
|
|
||||||
|
|
||||||
|
#############################################################################
|
||||||
|
## Member Actions Directive
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
|
MembershipsRowActionsDirective = ($log, $repo, $rs, $confirm) ->
|
||||||
|
activedTemplate = _.template("""
|
||||||
|
<div class="active">
|
||||||
|
Active
|
||||||
|
</div>
|
||||||
|
<a class="delete" href="">
|
||||||
|
<span class="icon icon-delete"></span>
|
||||||
|
</a>
|
||||||
|
""") # i18n
|
||||||
|
|
||||||
|
pendingTemplate = _.template("""
|
||||||
|
<a class="pending" href="">
|
||||||
|
Pending
|
||||||
|
<span class="icon icon-reload"></span>
|
||||||
|
</a>
|
||||||
|
<a class="delete" href="" title="Delete">
|
||||||
|
<span class="icon icon-delete"></span>
|
||||||
|
</a>
|
||||||
|
""") # i18n
|
||||||
|
|
||||||
|
link = ($scope, $el, $attrs) ->
|
||||||
|
render = (member) ->
|
||||||
|
if member.user
|
||||||
|
html = activedTemplate()
|
||||||
|
else
|
||||||
|
html = pendingTemplate()
|
||||||
|
|
||||||
|
$el.html(html)
|
||||||
|
|
||||||
|
if not $attrs.tgMembershipsRowActions?
|
||||||
|
return $log.error "MembershipsRowActionsDirective: the directive need a member"
|
||||||
|
|
||||||
|
$ctrl = $el.controller()
|
||||||
|
member = $scope.$eval($attrs.tgMembershipsRowActions)
|
||||||
|
render(member)
|
||||||
|
|
||||||
|
$el.on "click", ".pending", (event) ->
|
||||||
|
event.preventDefault()
|
||||||
|
onSuccess = ->
|
||||||
|
# i18n
|
||||||
|
$confirm.notify("success", "We've sent the invitationi again to '#{$scope.member.email}'.")
|
||||||
|
onError = ->
|
||||||
|
$confirm.notify("error", "We haven't sent the invitation.") # i18n
|
||||||
|
|
||||||
|
$rs.memberships.resendInvitation($scope.member.id).then(onSuccess, onError)
|
||||||
|
|
||||||
|
$el.on "click", ".delete", (event) ->
|
||||||
|
event.preventDefault()
|
||||||
|
|
||||||
|
title = "Delete member" # i18n
|
||||||
|
subtitle = if member.user then member.full_name else "the invitation to #{member.email}" # i18n
|
||||||
|
|
||||||
|
$confirm.ask(title, subtitle).then ->
|
||||||
|
$repo.remove(member).then ->
|
||||||
|
$ctrl.loadMembers()
|
||||||
|
$confirm.notify("success", null, "We've deleted #{subtitle}.") # i18n
|
||||||
|
|
||||||
|
$scope.$on "$destroy", ->
|
||||||
|
$el.off()
|
||||||
|
|
||||||
|
return {link: link}
|
||||||
|
|
||||||
|
|
||||||
|
module.directive("tgMembershipsRowActions", ["$log", "$tgRepo", "$tgResources", "$tgConfirm",
|
||||||
|
MembershipsRowActionsDirective])
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
taiga = @.taiga
|
taiga = @.taiga
|
||||||
|
|
||||||
resourceProvider = ($repo) ->
|
resourceProvider = ($repo, $http, $urls) ->
|
||||||
service = {}
|
service = {}
|
||||||
|
|
||||||
service.get = (id) ->
|
service.get = (id) ->
|
||||||
|
@ -33,9 +33,13 @@ resourceProvider = ($repo) ->
|
||||||
params = _.extend({}, params, filters or {})
|
params = _.extend({}, params, filters or {})
|
||||||
return $repo.queryPaginated("memberships", params)
|
return $repo.queryPaginated("memberships", params)
|
||||||
|
|
||||||
|
service.resendInvitation = (id) ->
|
||||||
|
url = $urls.resolve("memberships")
|
||||||
|
return $http.post("#{url}/#{id}/resend_invitation", {})
|
||||||
|
|
||||||
return (instance) ->
|
return (instance) ->
|
||||||
instance.memberships = service
|
instance.memberships = service
|
||||||
|
|
||||||
|
|
||||||
module = angular.module("taigaResources")
|
module = angular.module("taigaResources")
|
||||||
module.factory("$tgMembershipsResourcesProvider", ["$tgRepo", resourceProvider])
|
module.factory("$tgMembershipsResourcesProvider", ["$tgRepo", "$tgHttp", "$tgUrls", resourceProvider])
|
||||||
|
|
Loading…
Reference in New Issue