Project values lightbox refactor

stable
Xavier Julián 2014-10-23 12:39:02 +02:00
parent ebb000ea4b
commit 5614f763a7
5 changed files with 37 additions and 19 deletions

View File

@ -260,12 +260,13 @@ ProjectValuesDirective = ($log, $repo, $confirm, $location, animationFrame) ->
choices[option.id] = option.name choices[option.id] = option.name
#TODO: i18n #TODO: i18n
title = "Delete" title = "Delete value"
subtitle = value.name subtitle = value.name
replacement = "All items with this value will be changed to"
if _.keys(choices).length == 0 if _.keys(choices).length == 0
return $confirm.error("You can't delete all values.") return $confirm.error("You can't delete all values.")
return $confirm.askChoice(title, subtitle, choices).then (response) -> return $confirm.askChoice(title, subtitle, choices, replacement).then (response) ->
onSucces = -> onSucces = ->
$ctrl.loadValues().finally -> $ctrl.loadValues().finally ->
response.finish() response.finish()

View File

@ -89,8 +89,10 @@ class RolesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fil
delete: -> delete: ->
# TODO: i18n # TODO: i18n
title = "Delete Role" title = "Delete Role" # TODO: i18n
subtitle = @scope.role.name subtitle = @scope.role.name
replacement = "All the users with this role will be moved to" # TODO: i18n
warning = "<strong>Be careful, all role estimations will be removed</strong>" # TODO: i18n
choices = {} choices = {}
for role in @scope.roles for role in @scope.roles
@ -98,9 +100,9 @@ class RolesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fil
choices[role.id] = role.name choices[role.id] = role.name
if _.keys(choices).length == 0 if _.keys(choices).length == 0
return @confirm.error("You can't delete all values.") return @confirm.error("You can't delete all values.") # TODO: i18n
return @confirm.askChoice(title, subtitle, choices).then (response) => return @confirm.askChoice(title, subtitle, choices, replacement, warning).then (response) =>
promise = @repo.remove(@scope.role, {moveTo: response.selected}) promise = @repo.remove(@scope.role, {moveTo: response.selected})
promise.then => promise.then =>
@.loadProject() @.loadProject()

View File

@ -82,13 +82,24 @@ class ConfirmService extends taiga.Service
askOnDelete: (title, message) -> askOnDelete: (title, message) ->
return @.ask(title, "Are you sure you want to delete?", message) #TODO: i18n return @.ask(title, "Are you sure you want to delete?", message) #TODO: i18n
askChoice: (title, subtitle, choices, lightboxSelector=".lightbox-ask-choice") -> askChoice: (title, subtitle, choices, replacement, warning, lightboxSelector=".lightbox-ask-choice") ->
el = angular.element(lightboxSelector) el = angular.element(lightboxSelector)
# Render content # Render content
el.find("h2.title").html(title) el.find(".title").html(title)
el.find("span.subtitle").html(subtitle) el.find(".subtitle").html(subtitle)
choicesField = el.find("select.choices")
if replacement
el.find(".replacement").html(replacement)
else
el.find(".replacement").remove()
if warning
el.find(".warning").html(warning)
else
el.find(".warning").remove()
choicesField = el.find(".choices")
choicesField.html('') choicesField.html('')
_.each choices, (value, key) -> _.each choices, (value, key) ->
choicesField.append(angular.element("<option value='#{key}'>#{value}</option>")) choicesField.append(angular.element("<option value='#{key}'>#{value}</option>"))

View File

@ -1,12 +1,13 @@
a.close(href="", title="close") a.close(href="", title="close")
span.icon.icon-delete span.icon.icon-delete
form form
h2.title Delete User Story h2.title
p.question Are you sure you want to delete? p.question
p.subtitle #125 Crear el perfil de usuario senior en el admin p.subtitle
p.replacement What value do you want to use as replacement? p.replacement
select.choices select.choices
p if the role is deleted all role estimates will be deleted p.warning
div.options div.options
a.button.button-green(href="", title="Accept") a.button.button-green(href="", title="Accept")
span Accept span Accept

View File

@ -311,13 +311,14 @@
} }
.lightbox-ask-choice { .lightbox-ask-choice {
text-align: center;
form { form {
@include table-flex-child(0, 420px, 0, 420px); @include table-flex-child(0, 420px, 0);
} }
.question, .question,
.subtitle { .subtitle {
display: block; display: block;
line-height: 2rem; line-height: 1.5rem;
text-align: center; text-align: center;
} }
.subtitle { .subtitle {
@ -326,7 +327,9 @@
} }
.replacement { .replacement {
display: block; display: block;
text-align: center; span {
display: block;
}
} }
.options { .options {
@include table-flex(); @include table-flex();