On delete choices set correctly a new choice value for all objects
parent
615ff374f9
commit
0c3995a622
|
@ -219,16 +219,23 @@ ProjectValuesDirective = ($log, $repo, $confirm, $location) ->
|
|||
event.preventDefault()
|
||||
target = angular.element(event.currentTarget)
|
||||
value = target.scope().value
|
||||
choices = {}
|
||||
_.each $scope.values, (option) ->
|
||||
if value.id != option.id
|
||||
choices[option.id] = option.name
|
||||
|
||||
#TODO: i18n
|
||||
title = "Delete"
|
||||
subtitle = value.name
|
||||
$confirm.ask(title, subtitle).then =>
|
||||
if _.keys(choices).length == 0
|
||||
return $confirm.error("You can't delete all values.")
|
||||
else
|
||||
return $confirm.askChoice(title, subtitle, choices).then (selected) =>
|
||||
onSucces = ->
|
||||
$ctrl.loadValues()
|
||||
onError = ->
|
||||
$confirm.notify("error")
|
||||
$repo.remove(value).then(onSucces, onError)
|
||||
$repo.remove(value, {"moveTo": selected}).then(onSucces, onError)
|
||||
|
||||
link = ($scope, $el, $attrs) ->
|
||||
linkDragAndDrop($scope, $el, $attrs)
|
||||
|
|
|
@ -72,6 +72,33 @@ class ConfirmService extends taiga.Service
|
|||
|
||||
return defered.promise
|
||||
|
||||
askChoice: (title, subtitle, choices, lightboxSelector=".lightbox-ask-choice") ->
|
||||
@.el = angular.element(lightboxSelector)
|
||||
|
||||
# Render content
|
||||
@.el.find("h2.title").html(title)
|
||||
@.el.find("span.subtitle").html(subtitle)
|
||||
choicesField = @.el.find("select.choices")
|
||||
choicesField.html('')
|
||||
_.each choices, (value, key) ->
|
||||
choicesField.append(angular.element("<option value='#{key}'>#{value}</option>"))
|
||||
defered = @q.defer()
|
||||
|
||||
# Assign event handlers
|
||||
@.el.on "click.confirm-dialog", "a.button-green", (event) =>
|
||||
event.preventDefault()
|
||||
defered.resolve(choicesField.val())
|
||||
@.hide()
|
||||
|
||||
@.el.on "click.confirm-dialog", "a.button-red", (event) =>
|
||||
event.preventDefault()
|
||||
defered.reject()
|
||||
@.hide()
|
||||
|
||||
@lightboxService.open(@.el)
|
||||
|
||||
return defered.promise
|
||||
|
||||
error: (message) ->
|
||||
@.el = angular.element(".lightbox-generic-error")
|
||||
|
||||
|
|
|
@ -44,11 +44,11 @@ class RepositoryService extends taiga.Service
|
|||
|
||||
return defered.promise
|
||||
|
||||
remove: (model) ->
|
||||
remove: (model, params={}) ->
|
||||
defered = @q.defer()
|
||||
url = @.resolveUrlForModel(model)
|
||||
|
||||
promise = @http.delete(url)
|
||||
promise = @http.delete(url, {}, params)
|
||||
promise.success (data, status) ->
|
||||
defered.resolve(model)
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ html(lang="en", ng-app="taiga")
|
|||
|
||||
div.hidden.lightbox.lightbox_confirm-delete
|
||||
include partials/views/modules/lightbox_confirm-delete
|
||||
div.hidden.lightbox.lightbox-ask-choice
|
||||
include partials/views/modules/lightbox-ask-choice
|
||||
div.hidden.lightbox.lightbox-generic-success
|
||||
include partials/views/modules/lightbox-generic-success
|
||||
div.hidden.lightbox.lightbox-generic-error
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
a.close(href="", title="close")
|
||||
span.icon.icon-delete
|
||||
form
|
||||
h2.title Delete User Story
|
||||
p
|
||||
span.delete-question Are you sure you want to delete?
|
||||
span.subtitle #125 Crear el perfil de usuario senior en el admin
|
||||
span.replacement What value do you want to use as replacement?
|
||||
select.choices
|
||||
div.delete-options
|
||||
a.button.button-green(href="", title="Accept")
|
||||
span Accept
|
||||
a.button.button-red(href="", title="Delete")
|
||||
span Cancel
|
|
@ -277,6 +277,37 @@
|
|||
}
|
||||
}
|
||||
|
||||
.lightbox-ask-choice {
|
||||
form {
|
||||
@include table-flex-child(0, 420px, 0, 420px);
|
||||
}
|
||||
.delete-question,
|
||||
.subtitle {
|
||||
display: block;
|
||||
line-height: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
.subtitle {
|
||||
@extend %large;
|
||||
@extend %title;
|
||||
}
|
||||
.replacement {
|
||||
display: block;
|
||||
text-align: center;
|
||||
}
|
||||
.delete-options {
|
||||
@include table-flex();
|
||||
a {
|
||||
@include table-flex-child(1, 0, 0);
|
||||
padding: 8px 0;
|
||||
text-align: center;
|
||||
&:first-child {
|
||||
margin-right: .5rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.lightbox_confirm-use-gravatar {
|
||||
form {
|
||||
@include table-flex-child(0, 420px, 0, 420px);
|
||||
|
|
Loading…
Reference in New Issue