From e3791d9b8535f572407e0e0291383c23c7fc354c Mon Sep 17 00:00:00 2001 From: Juanfran Date: Thu, 5 May 2016 08:18:01 +0200 Subject: [PATCH] confirm close edit mode with ESC --- CHANGELOG.md | 9 ++++++++ app/coffee/modules/common/components.coffee | 25 +++++++++++++++------ app/coffee/modules/common/confirm.coffee | 6 ++--- app/coffee/modules/wiki/main.coffee | 16 ++++++++----- app/locales/taiga/locale-ca.json | 2 ++ app/locales/taiga/locale-de.json | 2 ++ app/locales/taiga/locale-en.json | 2 ++ app/locales/taiga/locale-es.json | 2 ++ app/locales/taiga/locale-fi.json | 2 ++ app/locales/taiga/locale-fr.json | 2 ++ app/locales/taiga/locale-it.json | 2 ++ app/locales/taiga/locale-nl.json | 2 ++ app/locales/taiga/locale-pl.json | 2 ++ app/locales/taiga/locale-pt-br.json | 2 ++ app/locales/taiga/locale-ru.json | 2 ++ app/locales/taiga/locale-sv.json | 2 ++ app/locales/taiga/locale-tr.json | 2 ++ app/locales/taiga/locale-zh-hant.json | 2 ++ 18 files changed, 68 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36b6173e..ad2e8f5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/app/coffee/modules/common/components.coffee b/app/coffee/modules/common/components.coffee index 325c2524..f6598fa8 100644 --- a/app/coffee/modules/common/components.coffee +++ b/app/coffee/modules/common/components.coffee @@ -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]) diff --git a/app/coffee/modules/common/confirm.coffee b/app/coffee/modules/common/confirm.coffee index 4d55b4e8..04e80a62 100644 --- a/app/coffee/modules/common/confirm.coffee +++ b/app/coffee/modules/common/confirm.coffee @@ -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) => diff --git a/app/coffee/modules/wiki/main.coffee b/app/coffee/modules/wiki/main.coffee index 3713d232..de4b3a0c 100644 --- a/app/coffee/modules/wiki/main.coffee +++ b/app/coffee/modules/wiki/main.coffee @@ -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]) diff --git a/app/locales/taiga/locale-ca.json b/app/locales/taiga/locale-ca.json index ddfea7e1..5645a9b8 100644 --- a/app/locales/taiga/locale-ca.json +++ b/app/locales/taiga/locale-ca.json @@ -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.", diff --git a/app/locales/taiga/locale-de.json b/app/locales/taiga/locale-de.json index 3f22beae..a4e87b4b 100644 --- a/app/locales/taiga/locale-de.json +++ b/app/locales/taiga/locale-de.json @@ -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.", diff --git a/app/locales/taiga/locale-en.json b/app/locales/taiga/locale-en.json index 194cf93e..c727005f 100644 --- a/app/locales/taiga/locale-en.json +++ b/app/locales/taiga/locale-en.json @@ -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.", diff --git a/app/locales/taiga/locale-es.json b/app/locales/taiga/locale-es.json index c18c59f7..08b5a14a 100644 --- a/app/locales/taiga/locale-es.json +++ b/app/locales/taiga/locale-es.json @@ -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.", diff --git a/app/locales/taiga/locale-fi.json b/app/locales/taiga/locale-fi.json index bf1968ec..319aa4e4 100644 --- a/app/locales/taiga/locale-fi.json +++ b/app/locales/taiga/locale-fi.json @@ -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.", diff --git a/app/locales/taiga/locale-fr.json b/app/locales/taiga/locale-fr.json index 6fcb67b6..114da4b1 100644 --- a/app/locales/taiga/locale-fr.json +++ b/app/locales/taiga/locale-fr.json @@ -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.", diff --git a/app/locales/taiga/locale-it.json b/app/locales/taiga/locale-it.json index 66036eed..11b45bd6 100644 --- a/app/locales/taiga/locale-it.json +++ b/app/locales/taiga/locale-it.json @@ -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", diff --git a/app/locales/taiga/locale-nl.json b/app/locales/taiga/locale-nl.json index bb90d8c7..750107c5 100644 --- a/app/locales/taiga/locale-nl.json +++ b/app/locales/taiga/locale-nl.json @@ -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", diff --git a/app/locales/taiga/locale-pl.json b/app/locales/taiga/locale-pl.json index aa4db039..377fc4db 100644 --- a/app/locales/taiga/locale-pl.json +++ b/app/locales/taiga/locale-pl.json @@ -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.", diff --git a/app/locales/taiga/locale-pt-br.json b/app/locales/taiga/locale-pt-br.json index d14cea26..b888bba8 100644 --- a/app/locales/taiga/locale-pt-br.json +++ b/app/locales/taiga/locale-pt-br.json @@ -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.", diff --git a/app/locales/taiga/locale-ru.json b/app/locales/taiga/locale-ru.json index 54988c7d..89e9c995 100644 --- a/app/locales/taiga/locale-ru.json +++ b/app/locales/taiga/locale-ru.json @@ -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-адресом.", diff --git a/app/locales/taiga/locale-sv.json b/app/locales/taiga/locale-sv.json index 71624c10..1d63b9da 100644 --- a/app/locales/taiga/locale-sv.json +++ b/app/locales/taiga/locale-sv.json @@ -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", diff --git a/app/locales/taiga/locale-tr.json b/app/locales/taiga/locale-tr.json index e0c2b4f0..97ce06a5 100644 --- a/app/locales/taiga/locale-tr.json +++ b/app/locales/taiga/locale-tr.json @@ -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ı.", diff --git a/app/locales/taiga/locale-zh-hant.json b/app/locales/taiga/locale-zh-hant.json index e992257e..2abcfee7 100644 --- a/app/locales/taiga/locale-zh-hant.json +++ b/app/locales/taiga/locale-zh-hant.json @@ -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": "該電子郵件應為有效地址",