From 89b5984794b5f065b0114ba7c0c86fb180a13402 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Tue, 8 Jan 2019 10:59:14 +0100 Subject: [PATCH] #3695 - force the form to be dirty if any variant is still dirty --- .../components/content/edit.controller.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js index 8564cf2c43..22e10b0f92 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js @@ -4,7 +4,7 @@ function ContentEditController($rootScope, $scope, $routeParams, $q, $window, appState, contentResource, entityResource, navigationService, notificationsService, serverValidationManager, contentEditingHelper, treeService, formHelper, umbRequestHelper, - editorState, $http, eventsService, relationResource, overlayService) { + editorState, $http, eventsService, relationResource, overlayService, angularHelper) { var evts = []; var infiniteMode = $scope.infiniteModel && $scope.infiniteModel.infiniteMode; @@ -109,7 +109,7 @@ }); } })); - + } /** @@ -308,6 +308,19 @@ } } + function ensureDirtyIsSetIfAnyVariantIsDirty() { + var currentForm = angularHelper.getCurrentForm($scope); + + currentForm.$dirty = false; + + for (var i = 0; i < $scope.content.variants.length; i++) { + if($scope.content.variants[i].isDirty){ + currentForm.$dirty = true; + return; + } + } + } + // This is a helper method to reduce the amount of code repitition for actions: Save, Publish, SendToPublish function performSave(args) { @@ -331,6 +344,7 @@ eventsService.emit("content.saved", { content: $scope.content, action: args.action }); resetNestedFieldValiation(fieldsToRollback); + ensureDirtyIsSetIfAnyVariantIsDirty(); return $q.when(data); },