diff --git a/app/coffee/modules/common/lightboxes.coffee b/app/coffee/modules/common/lightboxes.coffee index deb1ac0d..1f46c5bd 100644 --- a/app/coffee/modules/common/lightboxes.coffee +++ b/app/coffee/modules/common/lightboxes.coffee @@ -200,21 +200,35 @@ CreateEditUserstoryDirective = ($repo, $model, $rs, $rootScope, lightboxService) $el.on "click", ".button-green", (event) -> event.preventDefault() form = $el.find("form").checksley() + target = angular.element(event.currentTarget) + + loading = "" #Create spinner item + finish = target.text() #Save current text + if not form.validate() return if isNew + target.html(loading) # Add item + promise = $repo.create("userstories", $scope.us) broadcastEvent = "usform:new:success" + else + target.html(loading) # Add item + promise = $repo.save($scope.us) broadcastEvent = "usform:edit:success" promise.then (data) -> + target.html(finish) # Add item + lightboxService.close($el) $rootScope.$broadcast(broadcastEvent, data) promise.then null, (data) -> + target.html(loading) # Add item + form.setErrors(data) if data._error_message $confirm.notify("error", data._error_message) diff --git a/app/styles/dependencies/animation.scss b/app/styles/dependencies/animation.scss index 8c8e7e96..05a1f763 100644 --- a/app/styles/dependencies/animation.scss +++ b/app/styles/dependencies/animation.scss @@ -5,6 +5,10 @@ } } +.icon-spinner { + @include animation(spin .5s linear); +} + //Spinner @include keyframes(fadeIn) { 0% {