diff --git a/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs b/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs index 33dabe1b24..92d397520e 100644 --- a/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs +++ b/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs @@ -134,15 +134,16 @@ namespace Umbraco.Core.Persistence.Factories // publishing = deal with edit and published values foreach (var propertyValue in property.Values) { - var isInvariantValue = propertyValue.Culture == null; - var isCultureValue = propertyValue.Culture != null && propertyValue.Segment == null; + var isInvariantValue = propertyValue.Culture == null && propertyValue.Segment == null; + var isCultureValue = propertyValue.Culture != null; + var isSegmentValue = propertyValue.Segment != null; // deal with published value - if (propertyValue.PublishedValue != null && publishedVersionId > 0) + if ((propertyValue.PublishedValue != null || isSegmentValue) && publishedVersionId > 0) propertyDataDtos.Add(BuildDto(publishedVersionId, property, languageRepository.GetIdByIsoCode(propertyValue.Culture), propertyValue.Segment, propertyValue.PublishedValue)); // deal with edit value - if (propertyValue.EditedValue != null) + if (propertyValue.EditedValue != null || isSegmentValue) propertyDataDtos.Add(BuildDto(currentVersionId, property, languageRepository.GetIdByIsoCode(propertyValue.Culture), propertyValue.Segment, propertyValue.EditedValue)); // property.Values will contain ALL of it's values, both variant and invariant which will be populated if the diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontenteditors.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontenteditors.directive.js index 697e980823..15df67def3 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontenteditors.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontenteditors.directive.js @@ -172,12 +172,14 @@ function requestSplitView(args) { var culture = args.culture; var segment = args.segment; - _.each(vm.content.variants, function (v) { - if ((!v.language || v.language.culture === culture) && v.segment === segment) { - openSplitView(v); - return; - } + + var variant = _.find(vm.content.variants, function (v) { + return (!v.language || v.language.culture === culture) && v.segment === segment; }); + + if (variant != null) { + openSplitView(variant); + } } /** Closes the split view */ diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs index 0e8787a99c..74240bbf6c 100644 --- a/src/Umbraco.Web/Editors/ContentController.cs +++ b/src/Umbraco.Web/Editors/ContentController.cs @@ -897,7 +897,13 @@ namespace Umbraco.Web.Editors if (variantCount > 1) { var cultureErrors = ModelState.GetCulturesWithErrors(Services.LocalizationService, cultureForInvariantErrors); - foreach (var c in contentItem.Variants.Where(x => x.Save && !cultureErrors.Contains(x.Culture)).Select(x => x.Culture).ToArray()) + + var savedWithoutErrors = contentItem.Variants + .Where(x => x.Save && !cultureErrors.Contains(x.Culture) && x.Culture != null) + .Select(x => x.Culture) + .ToArray(); + + foreach (var c in savedWithoutErrors) { AddSuccessNotification(notifications, c, Services.TextService.Localize("speechBubbles/editContentSavedHeader"), diff --git a/src/Umbraco.Web/Models/Mapping/ContentVariantMapper.cs b/src/Umbraco.Web/Models/Mapping/ContentVariantMapper.cs index c5f7e1a37a..0ed8ffb80e 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentVariantMapper.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentVariantMapper.cs @@ -117,21 +117,15 @@ namespace Umbraco.Web.Models.Mapping /// private IEnumerable GetSegments(IContent content) { - // The current segments of a content item are determined - // entirely on the current property values of the content. - var segments = content.Properties - .SelectMany(p => p.Values.Select(v => v.Segment)) - .Distinct() - .ToList(); + // The default segment (null) is always there, + // even when there is no property data at all yet + var segments = new List { null }; - if(segments.Count == 0) - { - // The default segment is always there, - // even when there is no property data at all yet - segments.Add(null); - } + // Add actual segments based on the property values + segments.AddRange(content.Properties.SelectMany(p => p.Values.Select(v => v.Segment))); - return segments; + // Do not return a segment more than once + return segments.Distinct(); } private ContentVariantDisplay CreateVariantDisplay(MapperContext context, IContent content, Language language, string segment)