From fee968b94eb64801301ce7d64bee9d372922cb1d Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Mon, 26 Nov 2018 08:19:49 +0100 Subject: [PATCH 1/4] Make MoveOperationStatusType of underlying type byte to fix move and copy YSODs --- src/Umbraco.Core/Services/MoveOperationStatusType.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From 88e6797cac433251261f99845b97ff47630e4c21 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Tue, 27 Nov 2018 11:49:51 +0100 Subject: [PATCH 2/4] Refresh content when doc type is changed in infinite editing --- .../directives/components/content/edit.controller.js | 7 ------- .../components/content/umbcontentnodeinfo.directive.js | 2 ++ 2 files changed, 2 insertions(+), 7 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 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 78efc8f789..7cd10f78ff 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 @@ -87,6 +87,8 @@ var editor = { id: documentType.id, submit: function(model) { + const args = { node: scope.node }; + eventsService.emit('editors.content.reload', args); editorService.close(); }, close: function() { From 900c8355cc3f5c3fb411b74ee24750140d2a9093 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Tue, 27 Nov 2018 14:04:05 +0100 Subject: [PATCH 3/4] show prompt if node is dirty before opening the doc type editor in infinite editing --- .../content/umbcontentnodeinfo.directive.js | 41 +++++++++++++++++-- .../Umbraco/config/lang/en_us.xml | 1 + 2 files changed, 38 insertions(+), 4 deletions(-) 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 7cd10f78ff..d6e25f972c 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, $routeParams, logResource, eventsService, userService, localizationService, dateHelper, editorService, redirectUrlsResource) { + function ContentNodeInfoDirective($timeout, $routeParams, logResource, eventsService, userService, localizationService, dateHelper, editorService, redirectUrlsResource, overlayService) { function link(scope, element, attrs, umbVariantContentCtrl) { @@ -32,7 +32,9 @@ "content_unpublished", "content_published", "content_publishedPendingChanges", - "content_notCreated" + "content_notCreated", + "prompt_unsavedChanges", + "prompt_doctypeChangeWarning" ]; localizationService.localizeMany(keys) @@ -42,6 +44,8 @@ labels.published = data[2]; labels.publishedPendingChanges = data[3]; labels.notCreated = data[4]; + labels.unsavedChanges = data[5]; + labels.doctypeChangeWarning = data[6]; setNodePublishStatus(scope.node); @@ -84,7 +88,36 @@ }; 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 }; @@ -96,7 +129,7 @@ } }; editorService.documentTypeEditor(editor); - }; + } scope.openTemplate = function () { var templateEditor = { 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 From 7032f1424d9b2f763d1e0a8af160e92b28edb7ab Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Wed, 28 Nov 2018 10:13:48 +0100 Subject: [PATCH 4/4] add overlay to tree when infinite editing is open --- .../src/controllers/main.controller.js | 10 +++++----- .../src/controllers/navigation.controller.js | 9 +++++++++ .../views/components/application/umb-navigation.html | 5 ++++- src/Umbraco.Web.UI/Umbraco/Views/Default.cshtml | 2 +- 4 files changed, 19 insertions(+), 7 deletions(-) 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 @@
-
+