Skip to content

Commit

Permalink
Review Perplex change for Segments (#7659)
Browse files Browse the repository at this point in the history
* Fixes incorrect property inheritance logic

* Fixes crash in canVariantPublish when variant.language is null

* Adds variant display name in dropdown

* Logic for invariant properties updated to also support segment invariance

* Properties varied by segment only now properly saved when multiple variants are saved/published

* Logic for disabling property editors moved to function and corrected for all cases of culture/segment properties

* Fixes syntax error in less file

* Fixes empty variants returned from GetEmpty() for a ContentType set to vary by segment
  • Loading branch information
PerplexDaniel authored Feb 14, 2020
1 parent cac07aa commit 1a4e6e5
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/Umbraco.Web/Models/Mapping/ContentVariantMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,25 @@ private IEnumerable<Language> GetLanguages(MapperContext context)
/// </summary>
/// <param name="content"></param>
/// <returns>
/// Returns all segments assigned to the content including 'null' values
/// Returns all segments assigned to the content including the default `null` segment.
/// </returns>
private IEnumerable<string> GetSegments(IContent content)
{
return content.Properties.SelectMany(p => p.Values.Select(v => v.Segment)).Distinct();
// 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();

if(segments.Count == 0)
{
// The default segment is always there,
// even when there is no property data at all yet
segments.Add(null);
}

return segments;
}

private ContentVariantDisplay CreateVariantDisplay(MapperContext context, IContent content, Language language, string segment)
Expand Down

0 comments on commit 1a4e6e5

Please sign in to comment.