Improved confirm/ask method.
It now wait results before close, and add a spinner.stable
parent
db34a5c39c
commit
5b17f5bda9
|
@ -430,15 +430,16 @@ MembershipsRowActionsDirective = ($log, $repo, $rs, $confirm) ->
|
||||||
title = "Delete member" # TODO: i18n
|
title = "Delete member" # TODO: i18n
|
||||||
subtitle = if member.user then member.full_name else "the invitation to #{member.email}" # TODO: i18n
|
subtitle = if member.user then member.full_name else "the invitation to #{member.email}" # TODO: i18n
|
||||||
|
|
||||||
onSuccess = ->
|
$confirm.ask(title, subtitle).then (finish) ->
|
||||||
$ctrl.loadMembers()
|
onSuccess = ->
|
||||||
$confirm.notify("success", null, "We've deleted #{subtitle}.") # TODO: i18n
|
finish()
|
||||||
|
$ctrl.loadMembers()
|
||||||
|
$confirm.notify("success", null, "We've deleted #{subtitle}.") # TODO: i18n
|
||||||
|
|
||||||
onError = ->
|
onError = ->
|
||||||
# TODO: i18in
|
# TODO: i18in
|
||||||
$confirm.notify("error", null, "We have not been able to delete #{subtitle}.")
|
$confirm.notify("error", null, "We have not been able to delete #{subtitle}.")
|
||||||
|
|
||||||
$confirm.ask(title, subtitle).then ->
|
|
||||||
$repo.remove(member).then(onSuccess, onError)
|
$repo.remove(member).then(onSuccess, onError)
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
|
|
|
@ -267,12 +267,13 @@ ProjectValuesDirective = ($log, $repo, $confirm, $location, animationFrame) ->
|
||||||
if _.keys(choices).length == 0
|
if _.keys(choices).length == 0
|
||||||
return $confirm.error("You can't delete all values.")
|
return $confirm.error("You can't delete all values.")
|
||||||
|
|
||||||
return $confirm.askChoice(title, subtitle, choices).then (selected) =>
|
return $confirm.askChoice(title, subtitle, choices).then (response) ->
|
||||||
onSucces = ->
|
onSucces = ->
|
||||||
$ctrl.loadValues()
|
$ctrl.loadValues().finally ->
|
||||||
|
response.finish()
|
||||||
onError = ->
|
onError = ->
|
||||||
$confirm.notify("error")
|
$confirm.notify("error")
|
||||||
$repo.remove(value, {"moveTo": selected}).then(onSucces, onError)
|
$repo.remove(value, {"moveTo": response.selected}).then(onSucces, onError)
|
||||||
|
|
||||||
link = ($scope, $el, $attrs) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
linkDragAndDrop($scope, $el, $attrs)
|
linkDragAndDrop($scope, $el, $attrs)
|
||||||
|
|
|
@ -100,11 +100,11 @@ class RolesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fil
|
||||||
if _.keys(choices).length == 0
|
if _.keys(choices).length == 0
|
||||||
return @confirm.error("You can't delete all values.")
|
return @confirm.error("You can't delete all values.")
|
||||||
|
|
||||||
return @confirm.askChoice(title, subtitle, choices).then (selected) =>
|
return @confirm.askChoice(title, subtitle, choices).then (response) =>
|
||||||
promise = @repo.remove(@scope.role, {moveTo: selected})
|
promise = @repo.remove(@scope.role, {moveTo: response.selected})
|
||||||
promise.then =>
|
promise.then =>
|
||||||
@confirm.notify('success')
|
@.loadRoles().finally ->
|
||||||
@.loadRoles()
|
response.finish()
|
||||||
promise.then null, =>
|
promise.then null, =>
|
||||||
@confirm.notify('error')
|
@confirm.notify('error')
|
||||||
|
|
||||||
|
|
|
@ -80,11 +80,13 @@ CreateEditSprint = ($repo, $confirm, $rs, $rootscope, lightboxService, $loading)
|
||||||
title = "Delete sprint"
|
title = "Delete sprint"
|
||||||
subtitle = $scope.sprint.name
|
subtitle = $scope.sprint.name
|
||||||
|
|
||||||
$confirm.ask(title, subtitle).then =>
|
$confirm.ask(title, subtitle).then (finish) =>
|
||||||
onSuccess = ->
|
onSuccess = ->
|
||||||
|
finish()
|
||||||
$scope.milestonesCounter -= 1
|
$scope.milestonesCounter -= 1
|
||||||
lightboxService.close($el)
|
lightboxService.close($el)
|
||||||
$rootscope.$broadcast("sprintform:remove:success")
|
$rootscope.$broadcast("sprintform:remove:success")
|
||||||
|
|
||||||
onError = ->
|
onError = ->
|
||||||
$confirm.notify("error")
|
$confirm.notify("error")
|
||||||
$repo.remove($scope.sprint).then(onSuccess, onError)
|
$repo.remove($scope.sprint).then(onSuccess, onError)
|
||||||
|
|
|
@ -411,12 +411,16 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
|
||||||
title = "Delete User Story"
|
title = "Delete User Story"
|
||||||
subtitle = us.subject
|
subtitle = us.subject
|
||||||
|
|
||||||
@confirm.ask(title, subtitle).then =>
|
@confirm.ask(title, subtitle).then (finish) =>
|
||||||
# We modify the userstories in scope so the user doesn't see the removed US for a while
|
# We modify the userstories in scope so the user doesn't see the removed US for a while
|
||||||
@scope.userstories = _.without(@scope.userstories, us)
|
@scope.userstories = _.without(@scope.userstories, us)
|
||||||
@filterVisibleUserstories()
|
@filterVisibleUserstories()
|
||||||
@.repo.remove(us).then =>
|
promise = @.repo.remove(us)
|
||||||
|
promise.then =>
|
||||||
|
finish()
|
||||||
@.loadBacklog()
|
@.loadBacklog()
|
||||||
|
promise.then null, =>
|
||||||
|
@confirm.notify("error")
|
||||||
|
|
||||||
addNewUs: (type) ->
|
addNewUs: (type) ->
|
||||||
switch type
|
switch type
|
||||||
|
|
|
@ -38,9 +38,9 @@ NOTIFICATION_MSG = {
|
||||||
|
|
||||||
|
|
||||||
class ConfirmService extends taiga.Service
|
class ConfirmService extends taiga.Service
|
||||||
@.$inject = ["$q", "lightboxService"]
|
@.$inject = ["$q", "lightboxService", "$tgLoading"]
|
||||||
|
|
||||||
constructor: (@q, @lightboxService) ->
|
constructor: (@q, @lightboxService, @loading) ->
|
||||||
_.bindAll(@)
|
_.bindAll(@)
|
||||||
|
|
||||||
hide: ->
|
hide: ->
|
||||||
|
@ -61,8 +61,11 @@ class ConfirmService extends taiga.Service
|
||||||
# Assign event handlers
|
# Assign event handlers
|
||||||
@.el.on "click.confirm-dialog", "a.button-green", (event) =>
|
@.el.on "click.confirm-dialog", "a.button-green", (event) =>
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
defered.resolve()
|
target = angular.element(event.currentTarget)
|
||||||
@.hide()
|
@loading.start(target)
|
||||||
|
defered.resolve =>
|
||||||
|
@loading.finish(target)
|
||||||
|
@.hide()
|
||||||
|
|
||||||
@.el.on "click.confirm-dialog", "a.button-red", (event) =>
|
@.el.on "click.confirm-dialog", "a.button-red", (event) =>
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
@ -88,8 +91,14 @@ class ConfirmService extends taiga.Service
|
||||||
# Assign event handlers
|
# Assign event handlers
|
||||||
@.el.on "click.confirm-dialog", "a.button-green", (event) =>
|
@.el.on "click.confirm-dialog", "a.button-green", (event) =>
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
defered.resolve(choicesField.val())
|
target = angular.element(event.currentTarget)
|
||||||
@.hide()
|
@loading.start(target)
|
||||||
|
defered.resolve {
|
||||||
|
selected: choicesField.val()
|
||||||
|
finish: =>
|
||||||
|
@loading.finish(target)
|
||||||
|
@.hide()
|
||||||
|
}
|
||||||
|
|
||||||
@.el.on "click.confirm-dialog", "a.button-red", (event) =>
|
@.el.on "click.confirm-dialog", "a.button-red", (event) =>
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
@ -190,4 +199,4 @@ class ConfirmService extends taiga.Service
|
||||||
|
|
||||||
|
|
||||||
module = angular.module("taigaBase")
|
module = angular.module("taigaBase")
|
||||||
module.service("$tgConfirm", ["$q", "lightboxService", ConfirmService])
|
module.service("$tgConfirm", ConfirmService)
|
||||||
|
|
|
@ -129,17 +129,18 @@ class AttachmentsController extends taiga.Controller
|
||||||
title = "Delete attachment" #TODO: i18in
|
title = "Delete attachment" #TODO: i18in
|
||||||
subtitle = "the attachment '#{attachment.name}'" #TODO: i18in
|
subtitle = "the attachment '#{attachment.name}'" #TODO: i18in
|
||||||
|
|
||||||
onSuccess = =>
|
return @confirm.ask(title, subtitle).then (finish) =>
|
||||||
index = @.attachments.indexOf(attachment)
|
onSuccess = =>
|
||||||
@.attachments.splice(index, 1)
|
finish()
|
||||||
@.updateCounters()
|
index = @.attachments.indexOf(attachment)
|
||||||
@rootscope.$broadcast("attachment:delete")
|
@.attachments.splice(index, 1)
|
||||||
|
@.updateCounters()
|
||||||
|
@rootscope.$broadcast("attachment:delete")
|
||||||
|
|
||||||
onError = =>
|
onError = =>
|
||||||
@confirm.notify("error", null, "We have not been able to delete #{subtitle}.")
|
@confirm.notify("error", null, "We have not been able to delete #{subtitle}.")
|
||||||
return @q.reject()
|
return @q.reject()
|
||||||
|
|
||||||
return @confirm.ask(title, subtitle).then =>
|
|
||||||
return @repo.remove(attachment).then(onSuccess, onError)
|
return @repo.remove(attachment).then(onSuccess, onError)
|
||||||
|
|
||||||
# Function used in template for filter visible attachments
|
# Function used in template for filter visible attachments
|
||||||
|
|
|
@ -177,7 +177,8 @@ WatchersDirective = ($rootscope, $confirm) ->
|
||||||
title = "Remove watcher"
|
title = "Remove watcher"
|
||||||
subtitle = $scope.usersById[watcherId].full_name_display
|
subtitle = $scope.usersById[watcherId].full_name_display
|
||||||
|
|
||||||
$confirm.ask(title, subtitle).then =>
|
$confirm.ask(title, subtitle).then (finish) =>
|
||||||
|
finish()
|
||||||
watcherIds = _.clone($model.$modelValue.watchers, false)
|
watcherIds = _.clone($model.$modelValue.watchers, false)
|
||||||
watcherIds = _.pull(watcherIds, watcherId)
|
watcherIds = _.pull(watcherIds, watcherId)
|
||||||
|
|
||||||
|
@ -260,7 +261,8 @@ AssignedToDirective = ($rootscope, $confirm) ->
|
||||||
title = "Remove assigned to"
|
title = "Remove assigned to"
|
||||||
subtitle = ""
|
subtitle = ""
|
||||||
|
|
||||||
$confirm.ask(title, subtitle).then =>
|
$confirm.ask(title, subtitle).then (finish) =>
|
||||||
|
finish()
|
||||||
$model.$modelValue.assigned_to = null
|
$model.$modelValue.assigned_to = null
|
||||||
renderAssignedTo($model.$modelValue)
|
renderAssignedTo($model.$modelValue)
|
||||||
|
|
||||||
|
|
|
@ -129,9 +129,13 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
title = "Delete Issue"
|
title = "Delete Issue"
|
||||||
subtitle = @scope.issue.subject
|
subtitle = @scope.issue.subject
|
||||||
|
|
||||||
@confirm.ask(title, subtitle).then =>
|
@confirm.ask(title, subtitle).then (finish) =>
|
||||||
@.repo.remove(@scope.issue).then =>
|
promise = @.repo.remove(@scope.issue)
|
||||||
|
promise.then =>
|
||||||
|
finish()
|
||||||
@location.path(@navUrls.resolve("project-issues", {project: @scope.project.slug}))
|
@location.path(@navUrls.resolve("project-issues", {project: @scope.project.slug}))
|
||||||
|
promise.then null, =>
|
||||||
|
@confirm.notify("error")
|
||||||
|
|
||||||
module.controller("IssueDetailController", IssueDetailController)
|
module.controller("IssueDetailController", IssueDetailController)
|
||||||
|
|
||||||
|
|
|
@ -621,11 +621,18 @@ IssuesFiltersDirective = ($log, $location, $rs, $confirm) ->
|
||||||
title = "Delete custom filter" # TODO: i18n
|
title = "Delete custom filter" # TODO: i18n
|
||||||
subtitle = "the custom filter '#{customFilterName}'" # TODO: i18n
|
subtitle = "the custom filter '#{customFilterName}'" # TODO: i18n
|
||||||
|
|
||||||
$confirm.ask(title, subtitle).then ->
|
$confirm.ask(title, subtitle).then (finish) ->
|
||||||
$ctrl.deleteMyFilter(customFilterName).then ->
|
promise = $ctrl.deleteMyFilter(customFilterName)
|
||||||
|
promise.then ->
|
||||||
$ctrl.loadMyFilters().then (filters) ->
|
$ctrl.loadMyFilters().then (filters) ->
|
||||||
|
finish()
|
||||||
$scope.filters.myFilters = filters
|
$scope.filters.myFilters = filters
|
||||||
renderFilters($scope.filters.myFilters)
|
renderFilters($scope.filters.myFilters)
|
||||||
|
$ctrl.loadMyFilters().then null, ->
|
||||||
|
finish()
|
||||||
|
promise.then null, ->
|
||||||
|
$confirm.notify("error")
|
||||||
|
|
||||||
|
|
||||||
$el.on "click", ".save-filters", (event) ->
|
$el.on "click", ".save-filters", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
|
@ -133,11 +133,16 @@ RelatedTaskRowDirective = ($repo, $compile, $confirm, $rootscope) ->
|
||||||
title = "Delete Task"
|
title = "Delete Task"
|
||||||
subtitle = task.subject
|
subtitle = task.subject
|
||||||
|
|
||||||
$confirm.ask(title, subtitle).then ->
|
$confirm.ask(title, subtitle).then (finish) ->
|
||||||
$repo.remove(task).then ->
|
promise = $repo.remove(task)
|
||||||
|
promise.then ->
|
||||||
|
finish()
|
||||||
$confirm.notify("success")
|
$confirm.notify("success")
|
||||||
$scope.$emit("related-tasks:delete")
|
$scope.$emit("related-tasks:delete")
|
||||||
|
|
||||||
|
promise.then null, ->
|
||||||
|
$confirm.notify("error")
|
||||||
|
|
||||||
$scope.$watch $attrs.ngModel, (val) ->
|
$scope.$watch $attrs.ngModel, (val) ->
|
||||||
return if not val
|
return if not val
|
||||||
renderView(val)
|
renderView(val)
|
||||||
|
|
|
@ -130,9 +130,13 @@ class TaskDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
title = "Delete Task"
|
title = "Delete Task"
|
||||||
subtitle = @scope.task.subject
|
subtitle = @scope.task.subject
|
||||||
|
|
||||||
@confirm.ask(title, subtitle).then =>
|
@confirm.ask(title, subtitle).then (finish) =>
|
||||||
@.repo.remove(@scope.task).then =>
|
promise = @.repo.remove(@scope.task)
|
||||||
|
promise.then =>
|
||||||
|
finish()
|
||||||
@location.path(@navUrls.resolve("project-backlog", {project: @scope.project.slug}))
|
@location.path(@navUrls.resolve("project-backlog", {project: @scope.project.slug}))
|
||||||
|
promise.then null, =>
|
||||||
|
@confirm.notify("error")
|
||||||
|
|
||||||
module.controller("TaskDetailController", TaskDetailController)
|
module.controller("TaskDetailController", TaskDetailController)
|
||||||
|
|
||||||
|
|
|
@ -139,9 +139,13 @@ class UserStoryDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
title = "Delete User Story"
|
title = "Delete User Story"
|
||||||
subtitle = @scope.us.subject
|
subtitle = @scope.us.subject
|
||||||
|
|
||||||
@confirm.ask(title, subtitle).then =>
|
@confirm.ask(title, subtitle).then (finish) =>
|
||||||
@.repo.remove(@scope.us).then =>
|
promise = @.repo.remove(@scope.us)
|
||||||
|
promise.then =>
|
||||||
|
finish()
|
||||||
@location.path(@navUrls.resolve("project-backlog", {project: @scope.project.slug}))
|
@location.path(@navUrls.resolve("project-backlog", {project: @scope.project.slug}))
|
||||||
|
promise.then null, =>
|
||||||
|
$confirm.notify("error")
|
||||||
|
|
||||||
module.controller("UserStoryDetailController", UserStoryDetailController)
|
module.controller("UserStoryDetailController", UserStoryDetailController)
|
||||||
|
|
||||||
|
|
|
@ -134,19 +134,20 @@ class WikiDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
@location.path(@navUrls.resolve("project-wiki-page", ctx))
|
@location.path(@navUrls.resolve("project-wiki-page", ctx))
|
||||||
|
|
||||||
delete: ->
|
delete: ->
|
||||||
onSuccess = =>
|
|
||||||
ctx = {project: @scope.projectSlug}
|
|
||||||
@location.path(@navUrls.resolve("project-wiki", ctx))
|
|
||||||
@confirm.notify("success")
|
|
||||||
|
|
||||||
onError = =>
|
|
||||||
@confirm.notify("error")
|
|
||||||
|
|
||||||
# TODO: i18n
|
# TODO: i18n
|
||||||
title = "Delete Wiki Page"
|
title = "Delete Wiki Page"
|
||||||
subtitle = unslugify(@scope.wiki.slug)
|
subtitle = unslugify(@scope.wiki.slug)
|
||||||
|
|
||||||
@confirm.ask(title, subtitle).then =>
|
@confirm.ask(title, subtitle).then (finish) =>
|
||||||
|
onSuccess = =>
|
||||||
|
finish()
|
||||||
|
ctx = {project: @scope.projectSlug}
|
||||||
|
@location.path(@navUrls.resolve("project-wiki", ctx))
|
||||||
|
@confirm.notify("success")
|
||||||
|
|
||||||
|
onError = =>
|
||||||
|
@confirm.notify("error")
|
||||||
|
|
||||||
@repo.remove(@scope.wiki).then onSuccess, onError
|
@repo.remove(@scope.wiki).then onSuccess, onError
|
||||||
|
|
||||||
module.controller("WikiDetailController", WikiDetailController)
|
module.controller("WikiDetailController", WikiDetailController)
|
||||||
|
|
|
@ -109,10 +109,16 @@ WikiNavDirective = ($tgrepo, $log, $location, $confirm, $navUrls) ->
|
||||||
title = "Delete Wiki Link"
|
title = "Delete Wiki Link"
|
||||||
subtitle = $scope.wikiLinks[linkId].title
|
subtitle = $scope.wikiLinks[linkId].title
|
||||||
|
|
||||||
$confirm.ask(title, subtitle).then =>
|
$confirm.ask(title, subtitle).then (finish) =>
|
||||||
$tgrepo.remove($scope.wikiLinks[linkId]).then ->
|
promise = $tgrepo.remove($scope.wikiLinks[linkId])
|
||||||
|
promise.then ->
|
||||||
$ctrl.loadWikiLinks().then ->
|
$ctrl.loadWikiLinks().then ->
|
||||||
|
finish()
|
||||||
render($scope.wikiLinks)
|
render($scope.wikiLinks)
|
||||||
|
$ctrl.loadWikiLinks().then null, ->
|
||||||
|
finish()
|
||||||
|
promise.then null, ->
|
||||||
|
$confirm.notify("error")
|
||||||
|
|
||||||
$el.on "keyup", ".new input", (event) ->
|
$el.on "keyup", ".new input", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
Loading…
Reference in New Issue