Add some loading spiners on some save buttons
parent
68f48f6a1c
commit
09f4b382ff
|
@ -92,18 +92,22 @@ module.controller("ProjectProfileController", ProjectProfileController)
|
|||
## Project Profile Directive
|
||||
#############################################################################
|
||||
|
||||
ProjectProfileDirective = ($rootscope, $log, $repo, $confirm) ->
|
||||
ProjectProfileDirective = ($rootscope, $log, $repo, $confirm, $loading) ->
|
||||
link = ($scope, $el, $attrs) ->
|
||||
form = $el.find("form").checksley({"onlyOneErrorElement": true})
|
||||
submit = =>
|
||||
submit = (target) =>
|
||||
return if not form.validate()
|
||||
|
||||
$loading.start(target)
|
||||
|
||||
promise = $repo.save($scope.project)
|
||||
promise.then ->
|
||||
$loading.finish(target)
|
||||
$confirm.notify("success")
|
||||
$scope.$emit("project:loaded", $scope.project)
|
||||
|
||||
promise.then null, (data) ->
|
||||
$loading.finish(target)
|
||||
form.setErrors(data)
|
||||
if data._error_message
|
||||
$confirm.notify("error", data._error_message)
|
||||
|
@ -112,31 +116,41 @@ ProjectProfileDirective = ($rootscope, $log, $repo, $confirm) ->
|
|||
event.preventDefault()
|
||||
submit()
|
||||
|
||||
$el.on "click", "form a.button-green", (event) ->
|
||||
$el.on "click", ".default-values a.button-green", (event) ->
|
||||
event.preventDefault()
|
||||
submit()
|
||||
target = angular.element(event.currentTarget)
|
||||
submit(target)
|
||||
|
||||
$el.on "click", ".project-details a.button-green", (event) ->
|
||||
event.preventDefault()
|
||||
target = angular.element(event.currentTarget)
|
||||
submit(target)
|
||||
|
||||
return {link:link}
|
||||
|
||||
module.directive("tgProjectProfile", ["$rootScope", "$log", "$tgRepo", "$tgConfirm", ProjectProfileDirective])
|
||||
module.directive("tgProjectProfile", ["$rootScope", "$log", "$tgRepo", "$tgConfirm", "$tgLoading", ProjectProfileDirective])
|
||||
|
||||
|
||||
#############################################################################
|
||||
## Project Features Directive
|
||||
#############################################################################
|
||||
|
||||
ProjectFeaturesDirective = ($rootscope, $log, $repo, $confirm) ->
|
||||
ProjectFeaturesDirective = ($rootscope, $log, $repo, $confirm, $loading) ->
|
||||
link = ($scope, $el, $attrs) ->
|
||||
form = $el.find("form").checksley()
|
||||
submit = =>
|
||||
return if not form.validate()
|
||||
target = angular.element(".admin-functionalities a.button-green")
|
||||
$loading.start(target)
|
||||
|
||||
promise = $repo.save($scope.project)
|
||||
promise.then ->
|
||||
$loading.finish(target)
|
||||
$confirm.notify("success")
|
||||
$scope.$emit("project:loaded", $scope.project)
|
||||
|
||||
promise.then null, (data) ->
|
||||
$loading.finish(target)
|
||||
$confirm.notify("error", data._error_message)
|
||||
|
||||
$el.on "submit", "form", (event) ->
|
||||
|
@ -163,4 +177,4 @@ ProjectFeaturesDirective = ($rootscope, $log, $repo, $confirm) ->
|
|||
|
||||
return {link:link}
|
||||
|
||||
module.directive("tgProjectFeatures", ["$rootScope", "$log", "$tgRepo", "$tgConfirm", ProjectFeaturesDirective])
|
||||
module.directive("tgProjectFeatures", ["$rootScope", "$log", "$tgRepo", "$tgConfirm", "$tgLoading", ProjectFeaturesDirective])
|
||||
|
|
|
@ -157,7 +157,7 @@ module.controller("IssueDetailController", IssueDetailController)
|
|||
## Issue Main Directive
|
||||
#############################################################################
|
||||
|
||||
IssueDirective = ($tgrepo, $log, $location, $confirm, $navUrls) ->
|
||||
IssueDirective = ($tgrepo, $log, $location, $confirm, $navUrls, $loading) ->
|
||||
linkSidebar = ($scope, $el, $attrs, $ctrl) ->
|
||||
|
||||
link = ($scope, $el, $attrs) ->
|
||||
|
@ -172,6 +172,7 @@ IssueDirective = ($tgrepo, $log, $location, $confirm, $navUrls) ->
|
|||
return
|
||||
|
||||
onSuccess = ->
|
||||
$loading.finish(target)
|
||||
$confirm.notify("success")
|
||||
ctx = {
|
||||
project: $scope.project.slug
|
||||
|
@ -180,8 +181,11 @@ IssueDirective = ($tgrepo, $log, $location, $confirm, $navUrls) ->
|
|||
$location.path($navUrls.resolve("project-issues-detail", ctx))
|
||||
|
||||
onError = ->
|
||||
$loading.finish(target)
|
||||
$confirm.notify("error")
|
||||
|
||||
target = angular.element(event.currentTarget)
|
||||
$loading.start(target)
|
||||
$tgrepo.save($scope.issue).then(onSuccess, onError)
|
||||
|
||||
$el.on "click", ".add-comment a.button-green", (event) ->
|
||||
|
@ -207,7 +211,7 @@ IssueDirective = ($tgrepo, $log, $location, $confirm, $navUrls) ->
|
|||
return {link:link}
|
||||
|
||||
module.directive("tgIssueDetail", ["$tgRepo", "$log", "$tgLocation", "$tgConfirm", "$tgNavUrls",
|
||||
IssueDirective])
|
||||
"$tgLoading", IssueDirective])
|
||||
|
||||
|
||||
#############################################################################
|
||||
|
|
|
@ -150,7 +150,7 @@ module.controller("TaskDetailController", TaskDetailController)
|
|||
## Task Main Directive
|
||||
#############################################################################
|
||||
|
||||
TaskDirective = ($tgrepo, $log, $location, $confirm, $navUrls) ->
|
||||
TaskDirective = ($tgrepo, $log, $location, $confirm, $navUrls, $loading) ->
|
||||
linkSidebar = ($scope, $el, $attrs, $ctrl) ->
|
||||
|
||||
link = ($scope, $el, $attrs) ->
|
||||
|
@ -165,6 +165,7 @@ TaskDirective = ($tgrepo, $log, $location, $confirm, $navUrls) ->
|
|||
return
|
||||
|
||||
onSuccess = ->
|
||||
$loading.finish(target)
|
||||
$confirm.notify("success")
|
||||
ctx = {
|
||||
project: $scope.project.slug
|
||||
|
@ -173,8 +174,11 @@ TaskDirective = ($tgrepo, $log, $location, $confirm, $navUrls) ->
|
|||
$location.path($navUrls.resolve("project-tasks-detail", ctx))
|
||||
|
||||
onError = ->
|
||||
$loading.finish(target)
|
||||
$confirm.notify("error")
|
||||
|
||||
target = angular.element(event.currentTarget)
|
||||
$loading.start(target)
|
||||
$tgrepo.save($scope.task).then(onSuccess, onError)
|
||||
|
||||
$el.on "click", ".add-comment a.button-green", (event) ->
|
||||
|
@ -200,7 +204,7 @@ TaskDirective = ($tgrepo, $log, $location, $confirm, $navUrls) ->
|
|||
return {link:link}
|
||||
|
||||
module.directive("tgTaskDetail", ["$tgRepo", "$log", "$tgLocation", "$tgConfirm", "$tgNavUrls",
|
||||
TaskDirective])
|
||||
"$tgLoading", TaskDirective])
|
||||
|
||||
|
||||
#############################################################################
|
||||
|
|
|
@ -167,7 +167,7 @@ module.controller("UserStoryDetailController", UserStoryDetailController)
|
|||
## User story Main Directive
|
||||
#############################################################################
|
||||
|
||||
UsDirective = ($tgrepo, $log, $location, $confirm, $navUrls) ->
|
||||
UsDirective = ($tgrepo, $log, $location, $confirm, $navUrls, $loading) ->
|
||||
linkSidebar = ($scope, $el, $attrs, $ctrl) ->
|
||||
|
||||
link = ($scope, $el, $attrs) ->
|
||||
|
@ -182,6 +182,7 @@ UsDirective = ($tgrepo, $log, $location, $confirm, $navUrls) ->
|
|||
return
|
||||
|
||||
onSuccess = ->
|
||||
$loading.finish(target)
|
||||
$confirm.notify("success")
|
||||
ctx = {
|
||||
project: $scope.project.slug
|
||||
|
@ -190,8 +191,11 @@ UsDirective = ($tgrepo, $log, $location, $confirm, $navUrls) ->
|
|||
$location.path($navUrls.resolve("project-userstories-detail", ctx))
|
||||
|
||||
onError = ->
|
||||
$loading.finish(target)
|
||||
$confirm.notify("error")
|
||||
|
||||
target = angular.element(event.currentTarget)
|
||||
$loading.start(target)
|
||||
$tgrepo.save($scope.us).then(onSuccess, onError)
|
||||
|
||||
$el.on "click", ".add-comment a.button-green", (event) ->
|
||||
|
@ -216,7 +220,7 @@ UsDirective = ($tgrepo, $log, $location, $confirm, $navUrls) ->
|
|||
|
||||
return {link:link}
|
||||
|
||||
module.directive("tgUsDetail", ["$tgRepo", "$log", "$tgLocation", "$tgConfirm", "$tgNavUrls", UsDirective])
|
||||
module.directive("tgUsDetail", ["$tgRepo", "$log", "$tgLocation", "$tgConfirm", "$tgNavUrls", "$tgLoading", UsDirective])
|
||||
|
||||
|
||||
#############################################################################
|
||||
|
|
Loading…
Reference in New Issue