From c73fb6144b681c7ca17a30a54360f04694453961 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Thu, 23 Mar 2017 16:31:50 +0100 Subject: [PATCH] fixes: U4-9647 7.6.0-beta: New template editor not set $dirty on code change --- .../partialviewmacros/edit.controller.js | 6 +++++ .../src/views/partialviews/edit.controller.js | 6 +++++ .../src/views/scripts/edit.controller.js | 22 ++++++++++++++++++- .../src/views/templates/edit.controller.js | 5 +++++ 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/partialviewmacros/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/partialviewmacros/edit.controller.js index 30cb02092c..83ad251e17 100644 --- a/src/Umbraco.Web.UI.Client/src/views/partialviewmacros/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/partialviewmacros/edit.controller.js @@ -291,6 +291,8 @@ //change on blur, focus vm.editor.on("blur", persistCurrentLocation); vm.editor.on("focus", persistCurrentLocation); + vm.editor.on("change", changeAceEditor); + } } @@ -309,6 +311,10 @@ vm.currentPosition = vm.editor.getCursorPosition(); } + function changeAceEditor() { + setFormState("dirty"); + } + function setFormState(state) { // get the current form diff --git a/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.controller.js index a886b3c59d..1b9ed2e1e0 100644 --- a/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.controller.js @@ -367,6 +367,8 @@ //change on blur, focus vm.editor.on("blur", persistCurrentLocation); vm.editor.on("focus", persistCurrentLocation); + vm.editor.on("change", changeAceEditor); + } } @@ -385,6 +387,10 @@ vm.currentPosition = vm.editor.getCursorPosition(); } + function changeAceEditor() { + setFormState("dirty"); + } + function setFormState(state) { // get the current form diff --git a/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js index a54fa58097..c284100cb2 100644 --- a/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js @@ -1,7 +1,7 @@ (function () { "use strict"; - function ScriptsEditController($scope, $routeParams, $timeout, appState, editorState, navigationService, assetsService, codefileResource, contentEditingHelper, notificationsService, localizationService, templateHelper) { + function ScriptsEditController($scope, $routeParams, $timeout, appState, editorState, navigationService, assetsService, codefileResource, contentEditingHelper, notificationsService, localizationService, templateHelper, angularHelper) { var vm = this; var currentPosition = null; @@ -169,9 +169,29 @@ }); } + vm.editor.on("change", changeAceEditor); + } } + function changeAceEditor() { + setFormState("dirty"); + } + + function setFormState(state) { + + // get the current form + var currentForm = angularHelper.getCurrentForm($scope); + + // set state + if(state === "dirty") { + currentForm.$setDirty(); + } else if(state === "pristine") { + currentForm.$setPristine(); + } + } + + } init(); diff --git a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js index 9edb659d09..4f6c3422e3 100644 --- a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js @@ -264,6 +264,7 @@ //change on blur, focus vm.editor.on("blur", persistCurrentLocation); vm.editor.on("focus", persistCurrentLocation); + vm.editor.on("change", changeAceEditor); } } @@ -632,6 +633,10 @@ vm.currentPosition = vm.editor.getCursorPosition(); } + function changeAceEditor() { + setFormState("dirty"); + } + function setFormState(state) { // get the current form