From 47203f71117f1572031d4fe97977b8684a5f0cdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Fri, 31 Jul 2020 14:05:07 +0200 Subject: [PATCH 1/2] discard changes dialog --- .../blockeditor/blockeditor.controller.js | 25 ++++++++++++++++++- src/Umbraco.Web.UI/Umbraco/config/lang/da.xml | 2 ++ src/Umbraco.Web.UI/Umbraco/config/lang/en.xml | 2 ++ .../Umbraco/config/lang/en_us.xml | 2 ++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/blockeditor/blockeditor.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/blockeditor/blockeditor.controller.js index f515cbb4ba..4d79ecb7b4 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/blockeditor/blockeditor.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/blockeditor/blockeditor.controller.js @@ -1,6 +1,6 @@ angular.module("umbraco") .controller("Umbraco.Editors.BlockEditorController", - function ($scope, localizationService, formHelper) { + function ($scope, localizationService, formHelper, overlayService) { var vm = this; vm.model = $scope.model; @@ -67,6 +67,29 @@ angular.module("umbraco") // * It would have a 'commit' method to commit the removed errors - which we would call in the formHelper.submitForm when it's successful // * It would have a 'rollback' method to reset the removed errors - which we would call here + + if (vm.blockForm.$dirty === true) { + localizationService.localizeMany(["prompt_discardChanges", "blockEditor_blockHasChanges"]).then(function (localizations) { + const confirm = { + title: localizations[0], + view: "default", + content: localizations[1], + submitButtonLabelKey: "general_discard", + submitButtonStyle: "danger", + closeButtonLabelKey: "general_cancel", + submit: function () { + overlayService.close(); + vm.model.close(vm.model); + }, + close: function () { + overlayService.close(); + } + }; + overlayService.open(confirm); + }); + + return; + } // TODO: check if content/settings has changed and ask user if they are sure. vm.model.close(vm.model); } diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml index e3d456dea7..a7957c5afd 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml @@ -647,6 +647,7 @@ Design Ordbog Dimensioner + Discard Ned Hent Rediger @@ -1851,6 +1852,7 @@ Mange hilsner fra Umbraco robotten Indstillinger Avanceret Skjuld indholds editoren + Du har lavet ændringer til dette indhold. Er du sikker på at du vil kassere dem? diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml index 8355c36bd1..d72ee33d6c 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml @@ -675,6 +675,7 @@ Design Dictionary Dimensions + Discard Down Download Edit @@ -2467,6 +2468,7 @@ To manage your website, simply open the Umbraco back office and start adding con Settings Advanced Force hide content editor + You have made changes to this content. Are you sure you want to discard them? What are Content Templates? diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml index fccd11a5aa..cb31695268 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml @@ -682,6 +682,7 @@ Design Dictionary Dimensions + Discard Down Download Edit @@ -2487,6 +2488,7 @@ To manage your website, simply open the Umbraco back office and start adding con Settings Advanced Force hide content editor + You have made changes to this content. Are you sure you want to discard them? What are Content Templates? From d06c1e01a7e36eedfdd2bb34119b90afa7ab9f9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Mon, 3 Aug 2020 11:27:32 +0200 Subject: [PATCH 2/2] Update da.xml translate to danish --- src/Umbraco.Web.UI/Umbraco/config/lang/da.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml index a7957c5afd..997fa577b7 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml @@ -647,7 +647,7 @@ Design Ordbog Dimensioner - Discard + Kassér Ned Hent Rediger