From 5cd58d12075fa5d29cd9f2b729703f9b6c56546d Mon Sep 17 00:00:00 2001 From: Juanfran Date: Mon, 7 Mar 2016 14:41:07 +0100 Subject: [PATCH] loading while deleting user --- app/coffee/modules/user-settings/lightboxes.coffee | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/coffee/modules/user-settings/lightboxes.coffee b/app/coffee/modules/user-settings/lightboxes.coffee index 68545809..32f32bce 100644 --- a/app/coffee/modules/user-settings/lightboxes.coffee +++ b/app/coffee/modules/user-settings/lightboxes.coffee @@ -33,7 +33,7 @@ module = angular.module("taigaUserSettings") ## Delete User Lightbox Directive ############################################################################# -DeleteUserDirective = ($repo, $rootscope, $auth, $location, $navUrls, lightboxService) -> +DeleteUserDirective = ($repo, $rootscope, $auth, $location, $navUrls, lightboxService, $loading) -> link = ($scope, $el, $attrs) -> $scope.$on "deletelightbox:new", (ctx, user)-> lightboxService.open($el) @@ -42,15 +42,21 @@ DeleteUserDirective = ($repo, $rootscope, $auth, $location, $navUrls, lightboxSe $el.off() submit = -> + currentLoading = $loading() + .target(submitButton) + .start() + promise = $repo.remove($scope.user) promise.then (data) -> + currentLoading.finish() lightboxService.close($el) $auth.logout() $location.path($navUrls.resolve("login")) # FIXME: error handling? promise.then null, -> + currentLoading.finish() console.log "FAIL" $el.on "click", ".button-green", (event) -> @@ -61,10 +67,12 @@ DeleteUserDirective = ($repo, $rootscope, $auth, $location, $navUrls, lightboxSe event.preventDefault() submit() + submitButton = $el.find(".button-red") + return { link: link, templateUrl: "user/lightbox/lightbox-delete-account.html" } module.directive("tgLbDeleteUser", ["$tgRepo", "$rootScope", "$tgAuth", "$tgLocation", "$tgNavUrls", - "lightboxService", DeleteUserDirective]) + "lightboxService", "$tgLoading", DeleteUserDirective])