diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/validation/valpropertymsg.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/validation/valpropertymsg.directive.js index ccb8e2e6aa..d54c843c33 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/validation/valpropertymsg.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/validation/valpropertymsg.directive.js @@ -89,7 +89,6 @@ function valPropertyMsg(serverValidationManager, localizationService, angularHel var errCount = angularHelper.countAllFormErrors(formCtrl); if (errCount === 0) { - resetError(); return true; } diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blocklist/umbBlockListPropertyEditor.component.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blocklist/umbBlockListPropertyEditor.component.js index ce3d632f84..b4304747c9 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blocklist/umbBlockListPropertyEditor.component.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blocklist/umbBlockListPropertyEditor.component.js @@ -176,6 +176,19 @@ if (block === null) return null; + // ensure that the containing content variant language/culture is transfered along + // to the scaffolded content object representing this block. This is required for validation + // along with ensuring that the umb-property inheritance is constently maintained. + if (vm.umbVariantContent.editor.content.language) { + block.content.language = vm.umbVariantContent.editor.content.language; + // currently we only ever deal with invariant content for blocks so there's only one + block.content.variants[0].tabs.forEach(tab => { + tab.properties.forEach(prop => { + prop.culture = vm.umbVariantContent.editor.content.language.culture; + }); + }); + } + block.view = (block.config.view ? "/" + block.config.view : getDefaultViewForBlock(block)); block.hideContentInOverlay = block.config.forceHideContentEditorInOverlay === true || inlineEditing === true; diff --git a/src/Umbraco.Web/ModelStateExtensions.cs b/src/Umbraco.Web/ModelStateExtensions.cs index 6bbf58fbec..d03472ef5e 100644 --- a/src/Umbraco.Web/ModelStateExtensions.cs +++ b/src/Umbraco.Web/ModelStateExtensions.cs @@ -53,7 +53,7 @@ namespace Umbraco.Web internal static void AddPropertyError(this System.Web.Http.ModelBinding.ModelStateDictionary modelState, ValidationResult result, string propertyAlias, string culture = "", string segment = "") { - modelState.AddPropertyValidationError(new ContentPropertyValidationResult(result), propertyAlias, culture, segment); + modelState.AddPropertyValidationError(new ContentPropertyValidationResult(result, culture, segment), propertyAlias, culture, segment); } /// diff --git a/src/Umbraco.Web/PropertyEditors/Validation/ContentPropertyValidationResult.cs b/src/Umbraco.Web/PropertyEditors/Validation/ContentPropertyValidationResult.cs index 2f1fe010f0..e161e277ac 100644 --- a/src/Umbraco.Web/PropertyEditors/Validation/ContentPropertyValidationResult.cs +++ b/src/Umbraco.Web/PropertyEditors/Validation/ContentPropertyValidationResult.cs @@ -11,10 +11,15 @@ namespace Umbraco.Web.PropertyEditors.Validation /// public class ContentPropertyValidationResult : ValidationResult { - public ContentPropertyValidationResult(ValidationResult nested) + private readonly string _culture; + private readonly string _segment; + + public ContentPropertyValidationResult(ValidationResult nested, string culture, string segment) : base(nested.ErrorMessage, nested.MemberNames) { ComplexEditorResults = nested as ComplexEditorValidationResult; + _culture = culture; + _segment = segment; } /// @@ -35,7 +40,7 @@ namespace Umbraco.Web.PropertyEditors.Validation if (ComplexEditorResults == null) return base.ToString(); - var json = JsonConvert.SerializeObject(this, new ValidationResultConverter()); + var json = JsonConvert.SerializeObject(this, new ValidationResultConverter(_culture, _segment)); return json; } } diff --git a/src/Umbraco.Web/PropertyEditors/Validation/ValidationResultConverter.cs b/src/Umbraco.Web/PropertyEditors/Validation/ValidationResultConverter.cs index 890b9f5f6f..c527ce9766 100644 --- a/src/Umbraco.Web/PropertyEditors/Validation/ValidationResultConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/Validation/ValidationResultConverter.cs @@ -18,6 +18,20 @@ namespace Umbraco.Web.PropertyEditors.Validation /// internal class ValidationResultConverter : JsonConverter { + private readonly string _culture; + private readonly string _segment; + + /// + /// Constructor + /// + /// The culture of the containing property which will be transfered to all child model state + /// The segment of the containing property which will be transfered to all child model state + public ValidationResultConverter(string culture = "", string segment = "") + { + _culture = culture; + _segment = segment; + } + public override bool CanConvert(Type objectType) => typeof(ValidationResult).IsAssignableFrom(objectType); public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) @@ -88,14 +102,14 @@ namespace Umbraco.Web.PropertyEditors.Validation // "errors/propertyHasErrors" message, however I think that leaves for less flexibility since it could/should be // up to the front-end validator to show whatever message it wants (if any) for an error indicating a nested property error. // Will leave blank. - modelState.AddPropertyValidationError(new ValidationResult(string.Empty), propTypeResult.PropertyTypeAlias); + modelState.AddPropertyValidationError(new ValidationResult(string.Empty), propTypeResult.PropertyTypeAlias, _culture, _segment); } } else { foreach (var v in result) { - modelState.AddPropertyValidationError(v, propTypeResult.PropertyTypeAlias); + modelState.AddPropertyValidationError(v, propTypeResult.PropertyTypeAlias, _culture, _segment); } } }