Variant names, availability, etc

This commit is contained in:
Stephan
2018-04-18 11:14:08 +02:00
parent 58e4e2398a
commit 46487fa466
14 changed files with 294 additions and 150 deletions

View File

@@ -445,7 +445,7 @@ namespace Umbraco.Web.Editors
{
var permissions = Services.UserService
.GetPermissions(Security.CurrentUser, nodeIds);
var permissionsDictionary = new Dictionary<int, string[]>();
foreach (var nodeId in nodeIds)
{
@@ -557,7 +557,7 @@ namespace Umbraco.Web.Editors
}
return contentItemDisplay;
}
private ContentItemDisplay PostSaveInternal(ContentItemSave contentItem, Func<IContent, OperationResult> saveMethod)
{
//If we've reached here it means:
@@ -618,7 +618,7 @@ namespace Umbraco.Web.Editors
{
//publish the item and check if it worked, if not we will show a diff msg below
contentItem.PersistedContent.PublishValues(contentItem.LanguageId); //we are not checking for a return value here because we've alraedy pre-validated the property values
//check if we are publishing other variants and validate them
var allLangs = Services.LocalizationService.GetAllLanguages().ToList();
var variantsToValidate = contentItem.PublishVariations.Where(x => x.LanguageId != contentItem.LanguageId).ToList();
@@ -651,7 +651,7 @@ namespace Umbraco.Web.Editors
//get the updated model
var display = MapToDisplay(contentItem.PersistedContent, contentItem.LanguageId);
//lasty, if it is not valid, add the modelstate to the outgoing object and throw a 403
HandleInvalidModelState(display);
@@ -1150,7 +1150,7 @@ namespace Umbraco.Web.Editors
//a languageId must exist in the mapping context if this content item has any property type that can be varied by language
//otherwise the property validation will fail since it's expecting to be get/set with a language ID. If a languageId is not explicitly
//sent up, then it means that the user is editing the default variant language.
if (!languageId.HasValue && content.HasLanguageVariantPropertyType())
if (!languageId.HasValue && content.HasPropertyTypeVaryingByCulture())
{
languageId = Services.LocalizationService.GetDefaultVariantLanguage().Id;
}
@@ -1160,6 +1160,6 @@ namespace Umbraco.Web.Editors
return display;
}
}
}

View File

@@ -11,30 +11,6 @@ namespace Umbraco.Web.Models
{
public static class ContentExtensions
{
/// <summary>
/// Returns true if the content has any property type that allows language variants
/// </summary>
/// <param name="content"></param>
/// <returns></returns>
public static bool HasLanguageVariantPropertyType(this IContent content)
{
return content.PropertyTypes.Any(x => x.Variations == ContentVariation.CultureNeutral);
}
/// <summary>
/// Returns true if the content has a variation for the language/segment combination
/// </summary>
/// <param name="content"></param>
/// <param name="langId"></param>
/// <param name="segment"></param>
/// <returns></returns>
public static bool HasVariation(this IContent content, int langId, string segment = null)
{
//TODO: Wire up with new APIs
return false;
//return content.Languages.FirstOrDefault(x => x == langId);
}
/// <summary>
/// Gets the culture that would be selected to render a specified content,
/// within the context of a specified current request.

View File

@@ -29,9 +29,8 @@ namespace Umbraco.Web.Models.Mapping
{
Language = x,
Mandatory = x.Mandatory,
//fixme these all need to the variant values but we need to wait for the db/service changes
Name = source.GetName(x.IsoCode),
Exists = source.HasVariation(x.Id), //TODO: This needs to be wired up with new APIs when they are ready
Name = source.GetName(x.Id),
Exists = source.HasVariation(x.Id), // fixme - what's the purpose? "exists" or "published"? exists is a new thing?
PublishedState = source.PublishedState.ToString(),
//Segment = ?? We'll need to populate this one day when we support segments
}).ToList();