Skip to content
This repository was archived by the owner on Feb 10, 2024. It is now read-only.

Commit 0c54b21

Browse files
authored
Fix for unsaved changes dialog on new pages
When a DTGE-editor is added to a new created page and the serverside validation fails, the dialog for unsaved changes pops up. This fix captures the $routeParams.create values, resets it and sets it back after saving.
1 parent 768622a commit 0c54b21

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/Our.Umbraco.DocTypeGridEditor/Web/UI/App_Plugins/DocTypeGridEditor/Js/doctypegrideditor.controllers.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
angular.module("umbraco").controller("Our.Umbraco.DocTypeGridEditor.GridEditors.DocTypeGridEditor", [
1+
angular.module("umbraco").controller("Our.Umbraco.DocTypeGridEditor.GridEditors.DocTypeGridEditor", [
22

33
"$scope",
44
"$rootScope",
@@ -239,8 +239,9 @@ angular.module("umbraco").controller("Our.Umbraco.DocTypeGridEditor.Dialogs.DocT
239239
"blueprintConfig",
240240
"contentEditingHelper",
241241
"serverValidationManager",
242+
"$routeParams",
242243

243-
function ($scope, $interpolate, formHelper, contentResource, dtgeResources, dtgeUtilityService, blueprintConfig, contentEditingHelper, serverValidationManager) {
244+
function ($scope, $interpolate, formHelper, contentResource, dtgeResources, dtgeUtilityService, blueprintConfig, contentEditingHelper, serverValidationManager, $routeParams) {
244245

245246
var vm = this;
246247
vm.submit = submit;
@@ -269,6 +270,10 @@ angular.module("umbraco").controller("Our.Umbraco.DocTypeGridEditor.Dialogs.DocT
269270
$scope.model.node.variants[0].name = $scope.model.node.name
270271
$scope.model.node.variants[0].save = true;
271272

273+
// Reset route create to prevent showing up the changed content dialog
274+
var routeParamsCreate = $routeParams.create;
275+
$routeParams.create = undefined;
276+
272277
// save the content as a blueprint, to trigger validation
273278
var args = {
274279
saveMethod: contentResource.saveBlueprint,
@@ -282,10 +287,14 @@ angular.module("umbraco").controller("Our.Umbraco.DocTypeGridEditor.Dialogs.DocT
282287

283288
contentEditingHelper.contentEditorPerformSave(args).then(function (data) {
284289
$scope.model.submit($scope.model);
290+
// Reset original value of $routeParams.create
291+
$routeParams.create = routeParamsCreate;
285292
},
286-
function (err) {
287-
// cleanup the blueprint immediately
288-
cleanup();
293+
function (err) {
294+
// Set original value of $routeParams.create
295+
$routeParams.create = routeParamsCreate;
296+
// cleanup the blueprint immediately
297+
cleanup();
289298
});
290299
}
291300
}

0 commit comments

Comments
 (0)