From a209d6b2cf5b63316d0c6a73a3d64a91cc7c40a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Barrag=C3=A1n=20Merino?= Date: Wed, 24 Sep 2014 20:57:20 +0200 Subject: [PATCH] Fix #1067: When delete a project reload nav menu --- app/coffee/modules/projects/lightboxes.coffee | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/coffee/modules/projects/lightboxes.coffee b/app/coffee/modules/projects/lightboxes.coffee index 15e569b8..6da89b00 100644 --- a/app/coffee/modules/projects/lightboxes.coffee +++ b/app/coffee/modules/projects/lightboxes.coffee @@ -34,10 +34,10 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project form = $el.find("form").checksley({"onlyOneErrorElement": true}) onSuccessSubmit = (response) -> - lightboxService.close($el) + $rootscope.$broadcast("projects:reload") $confirm.notify("success", "Success") #TODO: i18n $location.url($projectUrl.get(response)) - $rootscope.$broadcast("projects:reload") + lightboxService.close($el) onErrorSubmit = (response) -> form.setErrors(response) @@ -124,7 +124,7 @@ module.directive("tgLbCreateProject", ["$rootScope", "$tgRepo", "$tgConfirm", "$ ## Delete Project Lightbox Directive ############################################################################# -DeleteProjectDirective = ($repo, $rootscope, $auth, $location, $navUrls, lightboxService) -> +DeleteProjectDirective = ($repo, $rootscope, $auth, $location, $navUrls, $confirm, lightboxService) -> link = ($scope, $el, $attrs) -> projectToDelete = null $scope.$on "deletelightbox:new", (ctx, project)-> @@ -139,11 +139,14 @@ DeleteProjectDirective = ($repo, $rootscope, $auth, $location, $navUrls, lightbo promise.then (data) -> lightboxService.close($el) + $rootscope.$broadcast("projects:reload") $location.path($navUrls.resolve("home")) + $confirm.notify("success") # FIXME: error handling? promise.then null, -> - console.log "FAIL" + $confirm.notify("error") + lightboxService.close($el) $el.on "click", ".button-red", (event) -> event.preventDefault() @@ -156,4 +159,4 @@ DeleteProjectDirective = ($repo, $rootscope, $auth, $location, $navUrls, lightbo return {link:link} module.directive("tgLbDeleteProject", ["$tgRepo", "$rootScope", "$tgAuth", "$tgLocation", "$tgNavUrls", - "lightboxService", DeleteProjectDirective]) + "$tgConfirm", "lightboxService", DeleteProjectDirective])