[Backport] confirm close edit mode with ESC

stable
Juanfran 2016-05-05 08:18:01 +02:00 committed by David Barragán Merino
parent ff03d84607
commit 7e1ddb3b32
18 changed files with 68 additions and 16 deletions

View File

@ -1,6 +1,15 @@
# Changelog #
## 2.2.0 ???? (Unreleased)
### Features
- Show a confirmation notice when you exit edit mode by pressing ESC in the markdown inputs.
### Misc
- Lots of small and not so small bugfixes.
## 2.1.0 Ursus Americanus (2016-05-03)
### Features

View File

@ -529,7 +529,7 @@ module.directive("tgEditableSubject", ["$rootScope", "$tgRepo", "$tgConfirm", "$
## Editable description directive
#############################################################################
EditableDescriptionDirective = ($rootscope, $repo, $confirm, $compile, $loading, $selectedText, $qqueue, $template) ->
EditableDescriptionDirective = ($rootscope, $repo, $confirm, $compile, $loading, $selectedText, $qqueue, $template, $translate) ->
template = $template.get("common/components/editable-description.html")
noDescriptionMegEditMode = $template.get("common/components/editable-description-msg-edit-mode.html")
noDescriptionMegReadMode = $template.get("common/components/editable-description-msg-read-mode.html")
@ -563,6 +563,11 @@ EditableDescriptionDirective = ($rootscope, $repo, $confirm, $compile, $loading,
promise.finally ->
currentLoading.finish()
cancelEdition = () ->
$scope.item.revert()
$el.find('.edit-description').hide()
$el.find('.view-description').show()
$el.on "mouseup", ".view-description", (event) ->
# We want to dettect the a inside the div so we use the target and
# not the currentTarget
@ -589,15 +594,19 @@ EditableDescriptionDirective = ($rootscope, $repo, $confirm, $compile, $loading,
save(description)
$el.on "keydown", "textarea", (event) ->
if event.keyCode == 27
$scope.$apply () => $scope.item.revert()
$el.find('.edit-description').hide()
$el.find('.view-description').show()
return if event.keyCode != 27
$scope.$applyAsync () ->
title = $translate.instant("COMMON.CONFIRM_CLOSE_EDIT_MODE_TITLE")
message = $translate.instant("COMMON.CONFIRM_CLOSE_EDIT_MODE_MESSAGE")
$confirm.ask(title, null, message).then (askResponse) ->
cancelEdition()
askResponse.finish()
$scope.$watch $attrs.ngModel, (value) ->
return if not value
$scope.item = value
$scope.item = value
if isEditable()
$el.find('.view-description .edit').show()
$el.find('.view-description .us-content').addClass('editable')
@ -623,7 +632,9 @@ module.directive("tgEditableDescription", [
"$tgLoading",
"$selectedText",
"$tgQqueue",
"$tgTemplate", EditableDescriptionDirective])
"$tgTemplate",
"$translate",
EditableDescriptionDirective])

View File

@ -59,9 +59,9 @@ class ConfirmService extends taiga.Service
el = angular.element(lightboxSelector)
# Render content
el.find(".title").text(title)
el.find(".subtitle").text(subtitle)
el.find(".message").text(message)
el.find(".title").text(title) if title
el.find(".subtitle").text(subtitle) if subtitle
el.find(".message").text(message) if message
# Assign event handlers
el.on "click.confirm-dialog", ".button-green", debounce 2000, (event) =>

View File

@ -206,7 +206,7 @@ module.directive("tgWikiSummary", ["$log", "$tgTemplate", "$compile", "$translat
## Editable Wiki Content Directive
#############################################################################
EditableWikiContentDirective = ($window, $document, $repo, $confirm, $loading, $analytics, $qqueue) ->
EditableWikiContentDirective = ($window, $document, $repo, $confirm, $loading, $analytics, $qqueue, $translate) ->
link = ($scope, $el, $attrs, $model) ->
isEditable = ->
return $scope.project.my_permissions.indexOf("modify_wiki_page") != -1
@ -227,8 +227,8 @@ EditableWikiContentDirective = ($window, $document, $repo, $confirm, $loading, $
cancelEdition = ->
return if not $model.$modelValue.id
$scope.$apply () =>
$model.$modelValue.revert()
$model.$modelValue.revert()
switchToReadMode()
getSelectedText = ->
@ -290,11 +290,15 @@ EditableWikiContentDirective = ($window, $document, $repo, $confirm, $loading, $
save($scope.wiki)
$el.on "click", ".cancel", ->
cancelEdition()
$scope.$apply(cancelEdition)
$el.on "keydown", "textarea", (event) ->
if event.keyCode == 27
cancelEdition()
$scope.$applyAsync () ->
confirmTitle = $translate.instant("COMMON.CONFIRM_CLOSE_EDIT_MODE")
$confirm.ask(confirmTitle).then (askResponse) ->
cancelEdition()
askResponse.finish()
$scope.$watch $attrs.ngModel, (wikiPage) ->
return if not wikiPage
@ -317,4 +321,4 @@ EditableWikiContentDirective = ($window, $document, $repo, $confirm, $loading, $
}
module.directive("tgEditableWikiContent", ["$window", "$document", "$tgRepo", "$tgConfirm", "$tgLoading",
"$tgAnalytics", "$tgQqueue", EditableWikiContentDirective])
"$tgAnalytics", "$tgQqueue", "$translate", EditableWikiContentDirective])

View File

@ -43,6 +43,8 @@
"TEAM_REQUIREMENT": "Team requirement is a requirement that must exist in the project but should have no cost for the client",
"OWNER": "Project Owner",
"CAPSLOCK_WARNING": "Be careful! You are using capital letters in an input field that is case sensitive.",
"CONFIRM_CLOSE_EDIT_MODE_TITLE": "Are you sure you want to close the edit mode?",
"CONFIRM_CLOSE_EDIT_MODE_MESSAGE": "Remember that if you close the edit mode without saving all the changes will be lost",
"FORM_ERRORS": {
"DEFAULT_MESSAGE": "Aquest valor pareix invàlid.",
"TYPE_EMAIL": "Deu ser un correu vàlid.",

View File

@ -43,6 +43,8 @@
"TEAM_REQUIREMENT": "Team requirement is a requirement that must exist in the project but should have no cost for the client",
"OWNER": "Projekteigentümer",
"CAPSLOCK_WARNING": "Achtung! Sie verwenden Großbuchstaben in einem Eingabefeld, dass Groß- und Kleinschreibung berücksichtigt.",
"CONFIRM_CLOSE_EDIT_MODE_TITLE": "Are you sure you want to close the edit mode?",
"CONFIRM_CLOSE_EDIT_MODE_MESSAGE": "Remember that if you close the edit mode without saving all the changes will be lost",
"FORM_ERRORS": {
"DEFAULT_MESSAGE": "Dieser Wert scheint ungültig zu sein.",
"TYPE_EMAIL": "Dieser Wert sollte eine gültige E-Mail Adresse enthalten.",

View File

@ -43,6 +43,8 @@
"TEAM_REQUIREMENT": "Team requirement is a requirement that must exist in the project but should have no cost for the client",
"OWNER": "Project Owner",
"CAPSLOCK_WARNING": "Be careful! You are using capital letters in an input field that is case sensitive.",
"CONFIRM_CLOSE_EDIT_MODE_TITLE": "Are you sure you want to close the edit mode?",
"CONFIRM_CLOSE_EDIT_MODE_MESSAGE": "Remember that if you close the edit mode without saving all the changes will be lost",
"FORM_ERRORS": {
"DEFAULT_MESSAGE": "This value seems to be invalid.",
"TYPE_EMAIL": "This value should be a valid email.",

View File

@ -43,6 +43,8 @@
"TEAM_REQUIREMENT": "Requerimiento del equipo es un nuevo requisito que debe existir en el proyecto pero que no conllevará ningún coste para el cliente.",
"OWNER": "Project Owner",
"CAPSLOCK_WARNING": "Be careful! You are using capital letters in an input field that is case sensitive.",
"CONFIRM_CLOSE_EDIT_MODE_TITLE": "Are you sure you want to close the edit mode?",
"CONFIRM_CLOSE_EDIT_MODE_MESSAGE": "Remember that if you close the edit mode without saving all the changes will be lost",
"FORM_ERRORS": {
"DEFAULT_MESSAGE": "Este valor parece inválido.",
"TYPE_EMAIL": "El valor debe ser un email.",

View File

@ -43,6 +43,8 @@
"TEAM_REQUIREMENT": "Team requirement is a requirement that must exist in the project but should have no cost for the client",
"OWNER": "Project Owner",
"CAPSLOCK_WARNING": "Be careful! You are using capital letters in an input field that is case sensitive.",
"CONFIRM_CLOSE_EDIT_MODE_TITLE": "Are you sure you want to close the edit mode?",
"CONFIRM_CLOSE_EDIT_MODE_MESSAGE": "Remember that if you close the edit mode without saving all the changes will be lost",
"FORM_ERRORS": {
"DEFAULT_MESSAGE": "Tämä arvo vaikuttaa virheelliseltä.",
"TYPE_EMAIL": "Tämän pitäisi olla toimiva sähköpostiosoite.",

View File

@ -43,6 +43,8 @@
"TEAM_REQUIREMENT": "Un besoin projet est un besoin qui est nécessaire au projet mais qui ne doit avoir aucun impact pour le client",
"OWNER": "Propriétaire du Projet",
"CAPSLOCK_WARNING": "Attention ! Vous utilisez des majuscules dans un champ qui est sensible à la casse.",
"CONFIRM_CLOSE_EDIT_MODE_TITLE": "Are you sure you want to close the edit mode?",
"CONFIRM_CLOSE_EDIT_MODE_MESSAGE": "Remember that if you close the edit mode without saving all the changes will be lost",
"FORM_ERRORS": {
"DEFAULT_MESSAGE": "Cette valeur semble être invalide.",
"TYPE_EMAIL": "Cette valeur devrait être une adresse courriel valide.",

View File

@ -43,6 +43,8 @@
"TEAM_REQUIREMENT": "Requisito del Team è un requisito che deve esistere nel progetto ma non deve avere costi per il cliente",
"OWNER": "Project Owner",
"CAPSLOCK_WARNING": "Be careful! You are using capital letters in an input field that is case sensitive.",
"CONFIRM_CLOSE_EDIT_MODE_TITLE": "Are you sure you want to close the edit mode?",
"CONFIRM_CLOSE_EDIT_MODE_MESSAGE": "Remember that if you close the edit mode without saving all the changes will be lost",
"FORM_ERRORS": {
"DEFAULT_MESSAGE": "Questo valore non è valido.",
"TYPE_EMAIL": "Questo valore dovrebbe corrispondere ad una mail valida",

View File

@ -43,6 +43,8 @@
"TEAM_REQUIREMENT": "Team requirement is a requirement that must exist in the project but should have no cost for the client",
"OWNER": "Project Owner",
"CAPSLOCK_WARNING": "Be careful! You are using capital letters in an input field that is case sensitive.",
"CONFIRM_CLOSE_EDIT_MODE_TITLE": "Are you sure you want to close the edit mode?",
"CONFIRM_CLOSE_EDIT_MODE_MESSAGE": "Remember that if you close the edit mode without saving all the changes will be lost",
"FORM_ERRORS": {
"DEFAULT_MESSAGE": "Deze waarde lijkt ongeldig te zijn",
"TYPE_EMAIL": "Deze waarde moet een geldig emailadres bevatten",

View File

@ -43,6 +43,8 @@
"TEAM_REQUIREMENT": "Team requirement is a requirement that must exist in the project but should have no cost for the client",
"OWNER": "Project Owner",
"CAPSLOCK_WARNING": "Be careful! You are using capital letters in an input field that is case sensitive.",
"CONFIRM_CLOSE_EDIT_MODE_TITLE": "Are you sure you want to close the edit mode?",
"CONFIRM_CLOSE_EDIT_MODE_MESSAGE": "Remember that if you close the edit mode without saving all the changes will be lost",
"FORM_ERRORS": {
"DEFAULT_MESSAGE": "Nieprawidłowa wartość",
"TYPE_EMAIL": "Podaj prawidłowy adres email.",

View File

@ -43,6 +43,8 @@
"TEAM_REQUIREMENT": "Requisito de time é um requisito que deve existir no projeto, mas que não deve ter nenhum custo para o cliente.",
"OWNER": "Dono do Projeto",
"CAPSLOCK_WARNING": "Seja cuidadoso! Você está escrevendo em letras maiúsculas e esse campo é case sensitive, ou seja, trata com distinção as letras maiúsculas das minúsculas.",
"CONFIRM_CLOSE_EDIT_MODE_TITLE": "Are you sure you want to close the edit mode?",
"CONFIRM_CLOSE_EDIT_MODE_MESSAGE": "Remember that if you close the edit mode without saving all the changes will be lost",
"FORM_ERRORS": {
"DEFAULT_MESSAGE": "Este valor parece ser inválido.",
"TYPE_EMAIL": "Este valor deve ser um e-mail válido.",

View File

@ -43,6 +43,8 @@
"TEAM_REQUIREMENT": "Team requirement is a requirement that must exist in the project but should have no cost for the client",
"OWNER": "Project Owner",
"CAPSLOCK_WARNING": "Be careful! You are using capital letters in an input field that is case sensitive.",
"CONFIRM_CLOSE_EDIT_MODE_TITLE": "Are you sure you want to close the edit mode?",
"CONFIRM_CLOSE_EDIT_MODE_MESSAGE": "Remember that if you close the edit mode without saving all the changes will be lost",
"FORM_ERRORS": {
"DEFAULT_MESSAGE": "Кажется, это значение некорректно.",
"TYPE_EMAIL": "Это значение должно быть корректным email-адресом.",

View File

@ -43,6 +43,8 @@
"TEAM_REQUIREMENT": "Team requirement is a requirement that must exist in the project but should have no cost for the client",
"OWNER": "Project Owner",
"CAPSLOCK_WARNING": "Be careful! You are using capital letters in an input field that is case sensitive.",
"CONFIRM_CLOSE_EDIT_MODE_TITLE": "Are you sure you want to close the edit mode?",
"CONFIRM_CLOSE_EDIT_MODE_MESSAGE": "Remember that if you close the edit mode without saving all the changes will be lost",
"FORM_ERRORS": {
"DEFAULT_MESSAGE": "Det här värdet är felaktigt. ",
"TYPE_EMAIL": "Värdet måste vara en giltig e-postadress",

View File

@ -43,6 +43,8 @@
"TEAM_REQUIREMENT": "Takım gereksinimi, müsteriyi ilgilendirmeyen, ama projede yer alması zorunlu olan bir gereksinimdir.",
"OWNER": "Project Owner",
"CAPSLOCK_WARNING": "Be careful! You are using capital letters in an input field that is case sensitive.",
"CONFIRM_CLOSE_EDIT_MODE_TITLE": "Are you sure you want to close the edit mode?",
"CONFIRM_CLOSE_EDIT_MODE_MESSAGE": "Remember that if you close the edit mode without saving all the changes will be lost",
"FORM_ERRORS": {
"DEFAULT_MESSAGE": "Bu değer geçersiz gözüküyor",
"TYPE_EMAIL": "Bu değer geçerli bir e-posta adresi olmalı.",

View File

@ -43,6 +43,8 @@
"TEAM_REQUIREMENT": "Team requirement is a requirement that must exist in the project but should have no cost for the client",
"OWNER": "Project Owner",
"CAPSLOCK_WARNING": "Be careful! You are using capital letters in an input field that is case sensitive.",
"CONFIRM_CLOSE_EDIT_MODE_TITLE": "Are you sure you want to close the edit mode?",
"CONFIRM_CLOSE_EDIT_MODE_MESSAGE": "Remember that if you close the edit mode without saving all the changes will be lost",
"FORM_ERRORS": {
"DEFAULT_MESSAGE": "該數值似乎為無效",
"TYPE_EMAIL": "該電子郵件應為有效地址",