From a0f7dbbc607c56fa497dbd595497948f1c01b005 Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 6 Aug 2018 18:05:04 +1000 Subject: [PATCH] Only update variant info if it is dirty --- .../directives/components/content/edit.controller.js | 9 +++++++++ .../common/services/contenteditinghelper.service.js | 5 +++-- .../src/common/services/umbdataformatter.service.js | 3 ++- src/Umbraco.Web/Editors/ContentController.cs | 3 +++ .../Models/ContentEditing/ContentVariantSave.cs | 12 ++++++++++++ 5 files changed, 29 insertions(+), 3 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 cf1485be34..8af09e3c00 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 @@ -283,6 +283,15 @@ // This is a helper method to reduce the amount of code repitition for actions: Save, Publish, SendToPublish function performSave(args) { + //update the 'save' boolean of each variant if they are flagged as being dirty + //TODO: This is also where we'd set this flag when we have the save dialog + for (var i = 0; i < $scope.content.variants.length; i++) { + var v = $scope.content.variants[i]; + if (v.isDirty) { + v.save = true; + } + } + $scope.page.buttonGroupState = "busy"; eventsService.emit("content.saving", { content: $scope.content, action: args.action }); diff --git a/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js b/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js index fe2a539019..42190535b4 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js @@ -518,8 +518,9 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, notifica //check for changed properties of the content for (var p in allOrigProps) { - var newProp = getNewProp(allOrigProps[p].alias, allOrigProps); - if (newProp && !_.isEqual(allOrigProps[p].value, newProp.value)) { + var alias = allOrigProps[p].alias; + var newProp = getNewProp(alias, allNewProps); + if (newProp && !_.isEqual(alias, newProp.value)) { //they have changed so set the origContent prop to the new one var origVal = allOrigProps[p].value; diff --git a/src/Umbraco.Web.UI.Client/src/common/services/umbdataformatter.service.js b/src/Umbraco.Web.UI.Client/src/common/services/umbdataformatter.service.js index a93cdf93d8..09b17b273f 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/umbdataformatter.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/umbdataformatter.service.js @@ -368,7 +368,8 @@ name: v.name, properties: getContentProperties(v.tabs), culture: v.language.culture, - publish: v.publish + publish: v.publish, + save: v.save }; }) }; diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs index 822b375217..ae33e3c261 100644 --- a/src/Umbraco.Web/Editors/ContentController.cs +++ b/src/Umbraco.Web/Editors/ContentController.cs @@ -1246,6 +1246,9 @@ namespace Umbraco.Web.Editors //loop through each variant, set the correct name and property values foreach (var variant in contentSave.Variants) { + //Don't update anything for this variant if Save is not true + if (!variant.Save) continue; + //Don't update the name if it is empty if (!variant.Name.IsNullOrWhiteSpace()) { diff --git a/src/Umbraco.Web/Models/ContentEditing/ContentVariantSave.cs b/src/Umbraco.Web/Models/ContentEditing/ContentVariantSave.cs index dc50129b37..18d1e037b6 100644 --- a/src/Umbraco.Web/Models/ContentEditing/ContentVariantSave.cs +++ b/src/Umbraco.Web/Models/ContentEditing/ContentVariantSave.cs @@ -26,9 +26,21 @@ namespace Umbraco.Web.Models.ContentEditing [DataMember(Name = "culture")] public string Culture { get; set; } + /// + /// Indicates if the variant should be updated + /// + /// + /// If this is false, this variant data will not be updated at all + /// + [DataMember(Name = "save")] + public bool Save { get; set; } + /// /// Indicates if the variant should be published or unpublished /// + /// + /// This option will have no affect if is false + /// [DataMember(Name = "publish")] public bool Publish { get; set; }