diff --git a/app/coffee/modules/admin/project-profile.coffee b/app/coffee/modules/admin/project-profile.coffee index 4705fb45..0bc4c006 100644 --- a/app/coffee/modules/admin/project-profile.coffee +++ b/app/coffee/modules/admin/project-profile.coffee @@ -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 diff --git a/app/coffee/modules/admin/project-values.coffee b/app/coffee/modules/admin/project-values.coffee index 25c9098a..7a19c49f 100644 --- a/app/coffee/modules/admin/project-values.coffee +++ b/app/coffee/modules/admin/project-values.coffee @@ -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) diff --git a/app/coffee/modules/admin/roles.coffee b/app/coffee/modules/admin/roles.coffee index b965e559..e8176c0f 100644 --- a/app/coffee/modules/admin/roles.coffee +++ b/app/coffee/modules/admin/roles.coffee @@ -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 = -> diff --git a/app/coffee/modules/common/components.coffee b/app/coffee/modules/common/components.coffee index 321b8ae5..4fd9db57 100644 --- a/app/coffee/modules/common/components.coffee +++ b/app/coffee/modules/common/components.coffee @@ -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) diff --git a/app/coffee/modules/common/confirm.coffee b/app/coffee/modules/common/confirm.coffee index aa0bbed2..df160d3d 100644 --- a/app/coffee/modules/common/confirm.coffee +++ b/app/coffee/modules/common/confirm.coffee @@ -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) => diff --git a/app/coffee/modules/issues/detail.coffee b/app/coffee/modules/issues/detail.coffee index a00c133e..ec70b2c5 100644 --- a/app/coffee/modules/issues/detail.coffee +++ b/app/coffee/modules/issues/detail.coffee @@ -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() diff --git a/app/coffee/modules/team/main.coffee b/app/coffee/modules/team/main.coffee index f4985c3a..8591e645 100644 --- a/app/coffee/modules/team/main.coffee +++ b/app/coffee/modules/team/main.coffee @@ -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 { diff --git a/app/locales/locale-en.json b/app/locales/locale-en.json index 4550dae3..3582eb97 100644 --- a/app/locales/locale-en.json +++ b/app/locales/locale-en.json @@ -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": "Are you sure you want to disable this role estimations?", "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", diff --git a/app/partials/admin/admin-roles.jade b/app/partials/admin/admin-roles.jade index 520a6eb9..1f9e68f2 100644 --- a/app/partials/admin/admin-roles.jade +++ b/app/partials/admin/admin-roles.jade @@ -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")