Merge pull request #675 from taigaio/us/3253/delete-estimation

Show a confirm alert when disable estimations to any role
stable
Alejandro 2015-10-23 08:51:19 +02:00
commit 7c5332db7e
9 changed files with 57 additions and 27 deletions

View File

@ -359,7 +359,7 @@ class CsvExporterController extends taiga.Controller
setCsvUuid: =>
@scope.csvUuid = @scope.project["#{@.type}_csv_uuid"]
_generateUuid: (finish) =>
_generateUuid: (response=null) =>
promise = @rs.projects["regenerate_#{@.type}_csv_uuid"](@scope.projectId)
promise.then (data) =>
@ -369,7 +369,7 @@ class CsvExporterController extends taiga.Controller
@confirm.notify("error")
promise.finally ->
finish()
response.finish() if response
return promise
regenerateUuid: ->
@ -379,7 +379,7 @@ class CsvExporterController extends taiga.Controller
@confirm.ask(title, subtitle).then @._generateUuid
else
@._generateUuid(_.identity)
@._generateUuid()
class CsvExporterUserstoriesController extends CsvExporterController

View File

@ -653,13 +653,11 @@ ProjectCustomAttributesDirective = ($log, $confirm, animationFrame, $translate)
title = $translate.instant("COMMON.CUSTOM_ATTRIBUTES.DELETE")
text = $translate.instant("COMMON.CUSTOM_ATTRIBUTES.CONFIRM_DELETE")
$confirm.ask(title, text, message).then (finish) ->
$confirm.ask(title, text, message).then (response) ->
onSucces = ->
$ctrl.loadCustomAttributes().finally ->
finish()
$ctrl.loadCustomAttributes().finally -> response.finish()
onError = ->
finish(false)
$confirm.notify("error", null, "We have not been able to delete '#{message}'.")
$ctrl.deleteCustomAttribute(attr).then(onSucces, onError)

View File

@ -129,7 +129,7 @@ class RolesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fil
return @repo.remove(@scope.role, {moveTo: response.selected}).then onSuccess, onError
setComputable: debounce 2000, ->
_enableComputable: =>
onSuccess = =>
@confirm.notify("success")
@.loadProject()
@ -140,9 +140,37 @@ class RolesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fil
@repo.save(@scope.role).then onSuccess, onError
_disableComputable: =>
askOnSuccess = (response) =>
onSuccess = =>
response.finish()
@confirm.notify("success")
@.loadProject()
onError = =>
response.finish()
@confirm.notify("error")
@scope.role.revert()
@repo.save(@scope.role).then onSuccess, onError
askOnError = (response) =>
@scope.role.revert()
title = @translate.instant("ADMIN.ROLES.DISABLE_COMPUTABLE_ALERT_TITLE")
subtitle = @translate.instant("ADMIN.ROLES.DISABLE_COMPUTABLE_ALERT_SUBTITLE", {
roleName: @scope.role.name
})
message = @translate.instant("ADMIN.ROLES.DISABLE_COMPUTABLE_ALERT_MESSAGE")
return @confirm.ask(title, subtitle, message).then askOnSuccess, askOnError
toggleComputable: debounce 2000, ->
if not @scope.role.computable
@._disableComputable()
else
@._enableComputable()
module.controller("RolesController", RolesController)
EditRoleDirective = ($repo, $confirm) ->
link = ($scope, $el, $attrs) ->
toggleView = ->

View File

@ -326,8 +326,8 @@ AssignedToDirective = ($rootscope, $confirm, $repo, $loading, $qqueue, $template
return if not isEditable()
title = $translate.instant("COMMON.ASSIGNED_TO.CONFIRM_UNASSIGNED")
$confirm.ask(title).then (finish) =>
finish()
$confirm.ask(title).then (response) =>
response.finish()
$model.$modelValue.assigned_to = null
save(null)

View File

@ -67,11 +67,12 @@ class ConfirmService extends taiga.Service
currentLoading = @loading()
.target(target)
.start()
defered.resolve (ok=true) =>
currentLoading.finish()
if ok
@.hide(el)
defered.resolve {
finish: (ok=true) =>
currentLoading.finish()
if ok
@.hide(el)
}
el.on "click.confirm-dialog", "a.button-red", (event) =>
event.preventDefault()
@ -118,9 +119,10 @@ class ConfirmService extends taiga.Service
.start()
defered.resolve {
selected: choicesField.val()
finish: =>
finish: (ok=true) =>
currentLoading.finish()
@.hide(el)
if ok
@.hide(el)
}
el.on "click.confirm-dialog", "a.button-red", (event) =>

View File

@ -553,7 +553,7 @@ module.directive("tgIssuePriorityButton", ["$rootScope", "$tgRepo", "$tgConfirm"
PromoteIssueToUsButtonDirective = ($rootScope, $repo, $confirm, $qqueue, $translate) ->
link = ($scope, $el, $attrs, $model) ->
save = $qqueue.bindAdd (issue, finish) =>
save = $qqueue.bindAdd (issue, askResponse) =>
data = {
generated_from_issue: issue.id
project: issue.project,
@ -565,12 +565,12 @@ PromoteIssueToUsButtonDirective = ($rootScope, $repo, $confirm, $qqueue, $transl
}
onSuccess = ->
finish()
askResponse.finish()
$confirm.notify("success")
$rootScope.$broadcast("promote-issue-to-us:success")
onError = ->
finish(false)
askResponse.finish()
$confirm.notify("error")
$repo.create("userstories", data).then(onSuccess, onError)
@ -584,9 +584,8 @@ PromoteIssueToUsButtonDirective = ($rootScope, $repo, $confirm, $qqueue, $transl
message = $translate.instant("ISSUES.CONFIRM_PROMOTE.MESSAGE")
subtitle = issue.subject
$confirm.ask(title, subtitle, message).then (finish) =>
save(issue, finish)
$confirm.ask(title, subtitle, message).then (response) =>
save(issue, response)
$scope.$on "$destroy", ->
$el.off()

View File

@ -217,16 +217,16 @@ LeaveProjectDirective = ($repo, $confirm, $location, $rs, $navurls, $translate)
leave_project_text = $translate.instant("TEAM.ACTION_LEAVE_PROJECT")
confirm_leave_project_text = $translate.instant("TEAM.CONFIRM_LEAVE_PROJECT")
$confirm.ask(leave_project_text, confirm_leave_project_text).then (finish) =>
$confirm.ask(leave_project_text, confirm_leave_project_text).then (response) =>
promise = $rs.projects.leave($attrs.projectid)
promise.then =>
finish()
response.finish()
$confirm.notify("success")
$location.path($navurls.resolve("home"))
promise.then null, (response) ->
finish()
response.finish()
$confirm.notify('error', response.data._error_message)
return {

View File

@ -500,6 +500,9 @@
"PAGE_TITLE": "Roles - {{projectName}}",
"WARNING_NO_ROLE": "Be careful, no role in your project will be able to estimate the point value for user stories",
"HELP_ROLE_ENABLED": "When enabled, members assigned to this role will be able to estimate the point value for user stories",
"DISABLE_COMPUTABLE_ALERT_TITLE": "Disable estimation for this role",
"DISABLE_COMPUTABLE_ALERT_SUBTITLE": "If you disable estimation permissions for role {{roleName}} all previous estimations made by this role will be removed",
"DISABLE_COMPUTABLE_ALERT_MESSAGE": "<strong>Are you sure you want to disable this role estimations?</strong>",
"COUNT_MEMBERS": "{{ role.members_count }} members with this role",
"TITLE_DELETE_ROLE": "Delete Role",
"REPLACEMENT_ROLE": "All the users with this role will be moved to",

View File

@ -33,7 +33,7 @@ div.wrapper.roles(ng-controller="RolesController as ctrl",
div.general-category
span(translate="ADMIN.ROLES.HELP_ROLE_ENABLED")
div.check
input(type="checkbox", ng-model="role.computable", ng-change="ctrl.setComputable()")
input(type="checkbox", ng-model="role.computable", ng-change="ctrl.toggleComputable()")
div
span.check-text.check-yes(translate="COMMON.YES")
span.check-text.check-no(translate="COMMON.NO")