From 77833cc49f5cb441362e619a4d3148e28d44d485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Hermida?= Date: Thu, 2 Aug 2018 16:01:35 +0200 Subject: [PATCH] Issue sprint change confirmation from TaskBoard --- app/coffee/modules/common/lightboxes.coffee | 39 +++++++++++++++++++-- app/locales/taiga/locale-en.json | 4 +++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/app/coffee/modules/common/lightboxes.coffee b/app/coffee/modules/common/lightboxes.coffee index c3b50b00..ee09af76 100644 --- a/app/coffee/modules/common/lightboxes.coffee +++ b/app/coffee/modules/common/lightboxes.coffee @@ -824,6 +824,7 @@ $confirm, $q, attachmentsService, $template, $compile) -> severityList: _.sortBy(project.severities, "order") priorityById: groupBy(project.priorities, (x) -> x.id) priorityList: _.sortBy(project.priorities, "order") + milestonesById: groupBy(project.milestones, (x) -> x.id) } initialData: (data) -> return { @@ -948,11 +949,43 @@ $confirm, $q, attachmentsService, $template, $compile) -> addExisting = (item) -> currentLoading = $loading().target($el.find(".add-existing-button")).start() - item.setAttr($scope.relatedField, $scope.relatedObjectId) - $repo.save(item, true).then (data) -> + + if item.milestone currentLoading.finish() lightboxService.close($el) - $rootScope.$broadcast("#{$scope.objType}form:add:success", item) + sprintChangeConfirmAndSave(item) + else + onSuccess = -> + currentLoading.finish() + lightboxService.close($el) + $rootScope.$broadcast("#{$scope.objType}form:add:success", item) + onError = -> + currentLoading.finish() + lightboxService.close($el) + saveItem(item, onSuccess, onError) + + sprintChangeConfirmAndSave = (item) -> + oldSprintName = $scope.milestonesById[item.milestone].name + newSprintName = $scope.milestonesById[$scope.relatedObjectId].name + title = $translate.instant("ISSUES.CONFIRM_CHANGE_FROM_SPRINT.TITLE") + message = $translate.instant("ISSUES.CONFIRM_CHANGE_FROM_SPRINT.MESSAGE", + {oldSprintName: oldSprintName, newSprintName: newSprintName}) + + $confirm.ask(title, null, message).then (askResponse) -> + onSuccess = -> + askResponse.finish() + lightboxService.close($el) + $rootScope.$broadcast("#{$scope.objType}form:add:success", item) + + onError = -> + askResponse.finish(false) + $confirm.notify("error") + saveItem(item, onSuccess, onError) + + saveItem = (item, onSuccess, onError) -> + item.setAttr($scope.relatedField, $scope.relatedObjectId) + $repo.save(item, true).then(onSuccess, onError) + isDisabledExisting = (item) -> return item && item[$scope.relatedField] == $scope.relatedObjectId diff --git a/app/locales/taiga/locale-en.json b/app/locales/taiga/locale-en.json index a60dd5b4..098efd77 100644 --- a/app/locales/taiga/locale-en.json +++ b/app/locales/taiga/locale-en.json @@ -1447,6 +1447,10 @@ "TITLE": "Detach issue from Sprint", "MESSAGE": "You are about to detach the issue from the sprint" }, + "CONFIRM_CHANGE_FROM_SPRINT": { + "TITLE": "Change issue from Sprint", + "MESSAGE": "Are you sure you want to change the issue sprint from {{ oldSprintName }} to {{ newSprintName }}" + }, "CONFIRM_PROMOTE": { "TITLE": "Promote this issue to a new user story", "MESSAGE": "Are you sure you want to create a new US from this Issue?"