Only update variant info if it is dirty

This commit is contained in:
Shannon
2018-08-06 18:05:04 +10:00
parent 7aaf024397
commit a0f7dbbc60
5 changed files with 29 additions and 3 deletions

View File

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

View File

@@ -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;

View File

@@ -368,7 +368,8 @@
name: v.name,
properties: getContentProperties(v.tabs),
culture: v.language.culture,
publish: v.publish
publish: v.publish,
save: v.save
};
})
};

View File

@@ -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())
{

View File

@@ -26,9 +26,21 @@ namespace Umbraco.Web.Models.ContentEditing
[DataMember(Name = "culture")]
public string Culture { get; set; }
/// <summary>
/// Indicates if the variant should be updated
/// </summary>
/// <remarks>
/// If this is false, this variant data will not be updated at all
/// </remarks>
[DataMember(Name = "save")]
public bool Save { get; set; }
/// <summary>
/// Indicates if the variant should be published or unpublished
/// </summary>
/// <remarks>
/// This option will have no affect if <see cref="Save"/> is false
/// </remarks>
[DataMember(Name = "publish")]
public bool Publish { get; set; }