Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V8/feature/ab4550 segments ui variant picker #7676

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
7d312cf
Fixes incorrect property inheritance logic
PerplexDaniel Feb 6, 2020
0a2ecf3
Fixes crash in canVariantPublish when variant.language is null
PerplexDaniel Feb 6, 2020
956a963
Adds variant display name in dropdown
PerplexDaniel Feb 6, 2020
e9262dc
Logic for invariant properties updated to also support segment invari…
PerplexDaniel Feb 7, 2020
c463376
Logic for disabling property editors moved to function and corrected …
PerplexDaniel Feb 7, 2020
0d242b7
Properties varied by segment only now properly saved when multiple va…
PerplexDaniel Feb 7, 2020
60a576e
Merge branch 'v8/feature/AB4550-segments-ui-variant-picker' of https:…
PerplexDaniel Feb 7, 2020
cc91186
Fixes syntax error in less file
PerplexDaniel Feb 7, 2020
f71d95d
Merge branch 'v8/feature/AB4550-segments-ui-variant-picker' of https:…
PerplexDaniel Feb 10, 2020
8cb5376
Merge branch 'v8/feature/AB4550-segments-ui-variant-picker' of https:…
PerplexDaniel Feb 13, 2020
d5707ca
Fixes empty variants returned from GetEmpty() for a ContentType set t…
PerplexDaniel Feb 13, 2020
901b6ba
Merge branch 'v8/feature/AB4550-segments-ui-variant-picker' of https:…
PerplexDaniel Feb 14, 2020
a70c48f
Replaced _.each with _.find to prevent having to loop through all var…
PerplexDaniel Feb 14, 2020
27e3db8
Added a null check on Culture prop which is now possibly null due to …
PerplexDaniel Feb 14, 2020
5e246b7
Makes sure segments are not completely removed when their value is null.
PerplexDaniel Feb 14, 2020
2752a3d
GetSegments() updated to always return the default segment, not only …
PerplexDaniel Feb 14, 2020
5039a7a
Merge branch 'v8/feature/AB4550-segments-ui-variant-picker' of https:…
PerplexDaniel Feb 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,16 @@ public static IEnumerable<PropertyDataDto> BuildDtos(ContentVariation contentVar
// 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
8 changes: 7 additions & 1 deletion src/Umbraco.Web/Editors/ContentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,13 @@ private void SaveAndNotify(ContentItemSave contentItem, Func<IContent, Operation
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"),
Expand Down
20 changes: 7 additions & 13 deletions src/Umbraco.Web/Models/Mapping/ContentVariantMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,15 @@ private IEnumerable<Language> GetLanguages(MapperContext context)
/// </returns>
private IEnumerable<string> 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<string> { 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)
Expand Down