From 3d28459471369ccdd444f2b301fb29a991d734e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Barrag=C3=A1n=20Merino?= Date: Tue, 22 Jul 2014 21:19:31 +0200 Subject: [PATCH] Delete a member --- app/coffee/modules/admin/memberships.coffee | 28 ++++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/app/coffee/modules/admin/memberships.coffee b/app/coffee/modules/admin/memberships.coffee index b25e1dcd..900deffe 100644 --- a/app/coffee/modules/admin/memberships.coffee +++ b/app/coffee/modules/admin/memberships.coffee @@ -43,8 +43,9 @@ class MembershipsController extends mixOf(taiga.Controller, taiga.PageMixin, tai ] constructor: (@scope, @rootScope, @repo, @confirm, @rs, @params, @q, @location) -> + @scope.sectionName = "Memberships" #i18n + @scope.project = {} @scope.filters = {} - @scope.sectionName = "Memberships" promise = @.loadInitialData() promise.then null, -> @@ -251,7 +252,7 @@ module.directive("tgMembershipsMemberAvatar", ["$log", MembershipsMemberAvatarDi ## Member Actions Directive ############################################################################# -MembershipsMemberActionsDirective = ($log) -> +MembershipsMemberActionsDirective = ($log, $repo, $confirm) -> activedTemplate = _.template("""
Active @@ -265,7 +266,7 @@ MembershipsMemberActionsDirective = ($log) -> Pending - + """) # i18n @@ -276,6 +277,8 @@ MembershipsMemberActionsDirective = ($log) -> return pendingTemplate() link = ($scope, $el, $attrs) -> + $ctrl = $el.controller() + if not $attrs.tgMembershipsMemberActions? return $log.error "MembershipsMemberActionsDirective: the directive need a member" @@ -283,13 +286,30 @@ MembershipsMemberActionsDirective = ($log) -> html = render(member) $el.html(html) + $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("tgMembershipsMemberActions", ["$log", MembershipsMemberActionsDirective]) +module.directive("tgMembershipsMemberActions", ["$log", "$tgRepo", "$tgConfirm", + MembershipsMemberActionsDirective]) #############################################################################