diff --git a/src/Umbraco.Core/Services/MoveOperationStatusType.cs b/src/Umbraco.Core/Services/MoveOperationStatusType.cs index 95ccce93ca..b4b4c2b42e 100644 --- a/src/Umbraco.Core/Services/MoveOperationStatusType.cs +++ b/src/Umbraco.Core/Services/MoveOperationStatusType.cs @@ -7,7 +7,7 @@ /// /// Anything less than 10 = Success! /// - public enum MoveOperationStatusType + public enum MoveOperationStatusType : byte { /// /// The move was successful. 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 422c02c87c..407416f2a1 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 @@ -97,13 +97,6 @@ eventsService.unsubscribe(evts[e]); } - evts.push(eventsService.on("editors.documentType.saved", function (name, args) { - // if this content item uses the updated doc type we need to reload the content item - if (args && args.documentType && args.documentType.key === $scope.content.documentType.key) { - loadContent(); - } - })); - evts.push(eventsService.on("editors.content.reload", function (name, args) { // if this content item uses the updated doc type we need to reload the content item if(args && args.node && args.node.key === $scope.content.key) { diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbcontentnodeinfo.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbcontentnodeinfo.directive.js index d2a429f813..31e847f0f6 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbcontentnodeinfo.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbcontentnodeinfo.directive.js @@ -1,7 +1,7 @@ (function () { 'use strict'; - function ContentNodeInfoDirective($timeout, logResource, eventsService, userService, localizationService, dateHelper, editorService, redirectUrlsResource) { + function ContentNodeInfoDirective($timeout, logResource, eventsService, userService, localizationService, dateHelper, editorService, redirectUrlsResource, overlayService) { function link(scope, element, attrs, umbVariantContentCtrl) { @@ -35,7 +35,9 @@ "content_unpublished", "content_published", "content_publishedPendingChanges", - "content_notCreated" + "content_notCreated", + "prompt_unsavedChanges", + "prompt_doctypeChangeWarning" ]; localizationService.localizeMany(keys) @@ -45,6 +47,8 @@ labels.published = data[2]; labels.publishedPendingChanges = data[3]; labels.notCreated = data[4]; + labels.unsavedChanges = data[5]; + labels.doctypeChangeWarning = data[6]; setNodePublishStatus(scope.node); @@ -87,9 +91,40 @@ }; scope.openDocumentType = function (documentType) { - var editor = { + + const variantIsDirty = _.some(scope.node.variants, function(variant) { + return variant.isDirty; + }); + + // add confirmation dialog before opening the doc type editor + if(variantIsDirty) { + const confirm = { + title: labels.unsavedChanges, + view: "default", + content: labels.doctypeChangeWarning, + submitButtonLabelKey: "general_continue", + closeButtonLabelKey: "general_cancel", + submit: function() { + openDocTypeEditor(documentType); + overlayService.close(); + }, + close: function() { + overlayService.close(); + } + }; + overlayService.open(confirm); + } else { + openDocTypeEditor(documentType); + } + + }; + + function openDocTypeEditor(documentType) { + const editor = { id: documentType.id, submit: function(model) { + const args = { node: scope.node }; + eventsService.emit('editors.content.reload', args); editorService.close(); }, close: function() { @@ -97,7 +132,7 @@ } }; editorService.documentTypeEditor(editor); - }; + } scope.openTemplate = function () { var templateEditor = { diff --git a/src/Umbraco.Web.UI.Client/src/controllers/main.controller.js b/src/Umbraco.Web.UI.Client/src/controllers/main.controller.js index 6f3f0bff52..30a7e2ac7d 100644 --- a/src/Umbraco.Web.UI.Client/src/controllers/main.controller.js +++ b/src/Umbraco.Web.UI.Client/src/controllers/main.controller.js @@ -13,7 +13,7 @@ function MainController($scope, $location, appState, treeService, notificationsS //the null is important because we do an explicit bool check on this in the view $scope.authenticated = null; $scope.touchDevice = appState.getGlobalState("touchDevice"); - $scope.editors = []; + $scope.infiniteMode = false; $scope.overlay = {}; $scope.drawer = {}; $scope.search = {}; @@ -160,12 +160,12 @@ function MainController($scope, $location, appState, treeService, notificationsS })); // event for infinite editors - evts.push(eventsService.on("appState.editors.add", function (name, args) { - $scope.editors = args.editors; + evts.push(eventsService.on("appState.editors.open", function (name, args) { + $scope.infiniteMode = args && args.editors.length > 0 ? true : false; })); - evts.push(eventsService.on("appState.editors.remove", function (name, args) { - $scope.editors = args.editors; + evts.push(eventsService.on("appState.editors.close", function (name, args) { + $scope.infiniteMode = args && args.editors.length > 0 ? true : false; })); //ensure to unregister from all events! diff --git a/src/Umbraco.Web.UI.Client/src/controllers/navigation.controller.js b/src/Umbraco.Web.UI.Client/src/controllers/navigation.controller.js index 8c521ca35e..06b82d6eab 100644 --- a/src/Umbraco.Web.UI.Client/src/controllers/navigation.controller.js +++ b/src/Umbraco.Web.UI.Client/src/controllers/navigation.controller.js @@ -241,6 +241,15 @@ function NavigationController($scope, $rootScope, $location, $log, $q, $routePar init(); })); + // event for infinite editors + evts.push(eventsService.on("appState.editors.open", function (name, args) { + $scope.infiniteMode = args && args.editors.length > 0 ? true : false; + })); + + evts.push(eventsService.on("appState.editors.close", function (name, args) { + $scope.infiniteMode = args && args.editors.length > 0 ? true : false; + })); + /** * Based on the current state of the application, this configures the scope variables that control the main tree and language drop down */ diff --git a/src/Umbraco.Web.UI.Client/src/views/components/application/umb-navigation.html b/src/Umbraco.Web.UI.Client/src/views/components/application/umb-navigation.html index 9d1da590ab..c5b4f69cef 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/application/umb-navigation.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/application/umb-navigation.html @@ -19,7 +19,7 @@
+ on-init="onTreeInit()">
@@ -44,6 +44,9 @@ + +
+ diff --git a/src/Umbraco.Web.UI/Umbraco/Views/Default.cshtml b/src/Umbraco.Web.UI/Umbraco/Views/Default.cshtml index 0d0c39aba7..4659674c59 100644 --- a/src/Umbraco.Web.UI/Umbraco/Views/Default.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/Views/Default.cshtml @@ -67,7 +67,7 @@
-
+
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 5b39f3d25f..fade57e934 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml @@ -340,6 +340,7 @@ Publishing will make the selected items visible on the site. Unpublishing will remove the selected items and all their descendants from the site. Unpublishing will remove this page and all its descendants from the site. + You have unsaved changes. Making changes to the Document Type will discard the changes. Done