#3695 - force the form to be dirty if any variant is still dirty

This commit is contained in:
Bjarke Berg
2019-01-08 10:59:14 +01:00
parent cf631e60dd
commit 89b5984794

View File

@@ -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);
},