Fixes #5224: Confirm before close edit lightboxes
parent
9e9b86c4bc
commit
7d5984e39b
|
@ -371,6 +371,8 @@ CreateEditUserstoryDirective = ($repo, $model, $rs, $rootScope, lightboxService,
|
||||||
status: status
|
status: status
|
||||||
is_archived: false
|
is_archived: false
|
||||||
tags: []
|
tags: []
|
||||||
|
subject: ""
|
||||||
|
description: ""
|
||||||
})
|
})
|
||||||
|
|
||||||
# Update texts for creation
|
# Update texts for creation
|
||||||
|
@ -478,24 +480,32 @@ CreateEditUserstoryDirective = ($repo, $model, $rs, $rootScope, lightboxService,
|
||||||
|
|
||||||
submitButton = $el.find(".submit-button")
|
submitButton = $el.find(".submit-button")
|
||||||
|
|
||||||
$el.on "submit", "form", submit
|
close = () =>
|
||||||
|
if !$scope.us.isModified()
|
||||||
$el.on "click", ".close", (event) ->
|
|
||||||
event.preventDefault()
|
|
||||||
|
|
||||||
$scope.$apply ->
|
|
||||||
$scope.us.revert()
|
|
||||||
|
|
||||||
lightboxService.close($el)
|
|
||||||
|
|
||||||
$el.keydown (event) ->
|
|
||||||
code = if event.keyCode then event.keyCode else event.which
|
|
||||||
if code == 27
|
|
||||||
lightboxService.close($el)
|
lightboxService.close($el)
|
||||||
$scope.$apply ->
|
$scope.$apply ->
|
||||||
$scope.us.revert()
|
$scope.us.revert()
|
||||||
|
else
|
||||||
|
$confirm.ask($translate.instant("LIGHTBOX.CREATE_EDIT_US.CONFIRM_CLOSE")).then (result) ->
|
||||||
|
lightboxService.close($el)
|
||||||
|
$scope.us.revert()
|
||||||
|
result.finish()
|
||||||
|
|
||||||
|
$el.on "submit", "form", submit
|
||||||
|
|
||||||
|
$el.find('.close').on "click", (event) ->
|
||||||
|
event.preventDefault()
|
||||||
|
event.stopPropagation()
|
||||||
|
close()
|
||||||
|
|
||||||
|
$el.keydown (event) ->
|
||||||
|
event.stopPropagation()
|
||||||
|
code = if event.keyCode then event.keyCode else event.which
|
||||||
|
if code == 27
|
||||||
|
close()
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
|
$el.find('.close').off()
|
||||||
$el.off()
|
$el.off()
|
||||||
|
|
||||||
return {link: link}
|
return {link: link}
|
||||||
|
|
|
@ -27,7 +27,7 @@ bindOnce = @.taiga.bindOnce
|
||||||
debounce = @.taiga.debounce
|
debounce = @.taiga.debounce
|
||||||
trim = @.taiga.trim
|
trim = @.taiga.trim
|
||||||
|
|
||||||
CreateEditTaskDirective = ($repo, $model, $rs, $rootscope, $loading, lightboxService, $translate, $q, attachmentsService) ->
|
CreateEditTaskDirective = ($repo, $model, $rs, $rootscope, $loading, lightboxService, $translate, $q, $confirm, attachmentsService) ->
|
||||||
link = ($scope, $el, attrs) ->
|
link = ($scope, $el, attrs) ->
|
||||||
$scope.isNew = true
|
$scope.isNew = true
|
||||||
|
|
||||||
|
@ -100,15 +100,17 @@ CreateEditTaskDirective = ($repo, $model, $rs, $rootscope, $loading, lightboxSer
|
||||||
_.pull($scope.task.tags, value)
|
_.pull($scope.task.tags, value)
|
||||||
|
|
||||||
$scope.$on "taskform:new", (ctx, sprintId, usId) ->
|
$scope.$on "taskform:new", (ctx, sprintId, usId) ->
|
||||||
$scope.task = {
|
$scope.task = $model.make_model('tasks', {
|
||||||
project: $scope.projectId
|
project: $scope.projectId
|
||||||
milestone: sprintId
|
milestone: sprintId
|
||||||
user_story: usId
|
user_story: usId
|
||||||
is_archived: false
|
is_archived: false
|
||||||
status: $scope.project.default_task_status
|
status: $scope.project.default_task_status
|
||||||
assigned_to: null
|
assigned_to: null
|
||||||
tags: []
|
tags: [],
|
||||||
}
|
subject: "",
|
||||||
|
description: "",
|
||||||
|
})
|
||||||
$scope.isNew = true
|
$scope.isNew = true
|
||||||
$scope.attachments = Immutable.List()
|
$scope.attachments = Immutable.List()
|
||||||
|
|
||||||
|
@ -187,7 +189,30 @@ CreateEditTaskDirective = ($repo, $model, $rs, $rootscope, $loading, lightboxSer
|
||||||
|
|
||||||
$el.on "submit", "form", submit
|
$el.on "submit", "form", submit
|
||||||
|
|
||||||
|
close = () =>
|
||||||
|
if !$scope.task.isModified()
|
||||||
|
lightboxService.close($el)
|
||||||
|
$scope.$apply ->
|
||||||
|
$scope.task.revert()
|
||||||
|
else
|
||||||
|
$confirm.ask($translate.instant("LIGHTBOX.CREATE_EDIT_TASK.CONFIRM_CLOSE")).then (result) ->
|
||||||
|
lightboxService.close($el)
|
||||||
|
$scope.task.revert()
|
||||||
|
result.finish()
|
||||||
|
|
||||||
|
$el.find('.close').on "click", (event) ->
|
||||||
|
event.preventDefault()
|
||||||
|
event.stopPropagation()
|
||||||
|
close()
|
||||||
|
|
||||||
|
$el.keydown (event) ->
|
||||||
|
event.stopPropagation()
|
||||||
|
code = if event.keyCode then event.keyCode else event.which
|
||||||
|
if code == 27
|
||||||
|
close()
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
|
$el.find('.close').off()
|
||||||
$el.off()
|
$el.off()
|
||||||
|
|
||||||
return {link: link}
|
return {link: link}
|
||||||
|
@ -250,6 +275,7 @@ module.directive("tgLbCreateEditTask", [
|
||||||
"lightboxService",
|
"lightboxService",
|
||||||
"$translate",
|
"$translate",
|
||||||
"$q",
|
"$q",
|
||||||
|
"$tgConfirm",
|
||||||
"tgAttachmentsService",
|
"tgAttachmentsService",
|
||||||
CreateEditTaskDirective
|
CreateEditTaskDirective
|
||||||
])
|
])
|
||||||
|
|
|
@ -1066,13 +1066,15 @@
|
||||||
"PLACEHOLDER_STATUS": "Task status",
|
"PLACEHOLDER_STATUS": "Task status",
|
||||||
"OPTION_UNASSIGNED": "Unassigned",
|
"OPTION_UNASSIGNED": "Unassigned",
|
||||||
"PLACEHOLDER_SHORT_DESCRIPTION": "Type a short description",
|
"PLACEHOLDER_SHORT_DESCRIPTION": "Type a short description",
|
||||||
"ACTION_EDIT": "Edit task"
|
"ACTION_EDIT": "Edit task",
|
||||||
|
"CONFIRM_CLOSE": "You have not saved changes.\nAre you sure you want to close the form?"
|
||||||
},
|
},
|
||||||
"CREATE_EDIT_US": {
|
"CREATE_EDIT_US": {
|
||||||
"TITLE": "New US",
|
"TITLE": "New US",
|
||||||
"PLACEHOLDER_DESCRIPTION": "Please add descriptive text to help others better understand this US",
|
"PLACEHOLDER_DESCRIPTION": "Please add descriptive text to help others better understand this US",
|
||||||
"NEW_US": "New user story",
|
"NEW_US": "New user story",
|
||||||
"EDIT_US": "Edit user story"
|
"EDIT_US": "Edit user story",
|
||||||
|
"CONFIRM_CLOSE": "You have not saved changes.\nAre you sure you want to close the form?"
|
||||||
},
|
},
|
||||||
"DELETE_SPRINT": {
|
"DELETE_SPRINT": {
|
||||||
"TITLE": "Delete sprint"
|
"TITLE": "Delete sprint"
|
||||||
|
|
Loading…
Reference in New Issue