From 88aebd20cf7e262cbe5e371c7a17a095f092e9e7 Mon Sep 17 00:00:00 2001 From: Kevin Jump Date: Thu, 20 Aug 2020 15:52:21 +0100 Subject: [PATCH] #139 make sure we serialize the settingsData too --- .../Mapping/Mappers/BlockListMapper.cs | 48 +++++++++++-------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/uSync8.ContentEdition/Mapping/Mappers/BlockListMapper.cs b/uSync8.ContentEdition/Mapping/Mappers/BlockListMapper.cs index 06644a24..83116e81 100644 --- a/uSync8.ContentEdition/Mapping/Mappers/BlockListMapper.cs +++ b/uSync8.ContentEdition/Mapping/Mappers/BlockListMapper.cs @@ -22,6 +22,10 @@ namespace uSync8.ContentEdition.Mapping.Mappers public class BlockListMapper : SyncNestedValueMapperBase, ISyncMapper { private readonly string docTypeKeyAlias = "contentTypeKey"; + private readonly string[] contentBlocks = new string[] + { + "contentData", "settingsData" + }; public BlockListMapper(IEntityService entityService, IContentTypeService contentTypeService, @@ -43,22 +47,25 @@ public override string GetExportValue(object value, string editorAlias) var jsonValue = GetJsonValue(value); if (jsonValue == null) return value.ToString(); - if (jsonValue.ContainsKey("contentData")) + foreach (var block in contentBlocks) { - var contentData = jsonValue.Value("contentData"); - if (contentData == null) return value.ToString(); - - foreach (var item in contentData.Cast()) + if (jsonValue.ContainsKey(block)) { - var doctype = GetDocTypeByKey(item, docTypeKeyAlias); - if (doctype == null) continue; + var contentData = jsonValue.Value(block); + if (contentData == null) return value.ToString(); - GetExportProperties(item, doctype); - } + foreach (var item in contentData.Cast()) + { + var doctype = GetDocTypeByKey(item, docTypeKeyAlias); + if (doctype == null) continue; + GetExportProperties(item, doctype); + } + + } return JsonConvert.SerializeObject(jsonValue, Formatting.Indented); } - + return value.ToString(); } @@ -74,19 +81,22 @@ public override IEnumerable GetDependencies(object value, strin // format of block data. // { "layout" : {}, "contentData": {}, "settingsData": {} } - // contentData is the thing we need to inspect. - if (jsonValue.ContainsKey("contentData")) + foreach (var block in contentBlocks) { - var contentData = jsonValue.Value("contentData"); - if (contentData != null) + // contentData is the thing we need to inspect. + if (jsonValue.ContainsKey(block)) { - foreach (var contentItem in contentData.Cast()) + var contentData = jsonValue.Value(block); + if (contentData != null) { - var contentType = GetDocTypeByKey(contentItem, "contentTypeKey"); - if (contentType != null) + foreach (var contentItem in contentData.Cast()) { - dependencies.AddNotNull(CreateDocTypeDependency(contentType, flags)); - dependencies.AddRange(this.GetPropertyDependencies(contentItem, contentType, flags)); + var contentType = GetDocTypeByKey(contentItem, this.docTypeKeyAlias); + if (contentType != null) + { + dependencies.AddNotNull(CreateDocTypeDependency(contentType, flags)); + dependencies.AddRange(this.GetPropertyDependencies(contentItem, contentType, flags)); + } } } }