Skip to content

Commit

Permalink
Update the logic for repetable strings. (#508)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJump authored Jul 19, 2023
1 parent 676da8f commit b1ad552
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
21 changes: 19 additions & 2 deletions uSync.Core/Mapping/Mappers/RepeatableValueMapper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using Umbraco.Cms.Core;
using Newtonsoft.Json;

using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Services;
using Umbraco.Extensions;

namespace uSync.Core.Mapping
{
Expand All @@ -14,12 +17,26 @@ public RepeatableValueMapper(IEntityService entityService)

public override string Name => "Repeatable Text Mapper";

public override string[] Editors => new string[] {
public override string[] Editors => new string[] {
Constants.PropertyEditors.Aliases.MultipleTextstring
};

public override string GetImportValue(string value, string editorAlias)
{
if (value.DetectIsJson())
{
try
{
var result = JsonConvert.SerializeObject(JsonConvert.DeserializeObject<object>(value));
return result;
}
catch
{
return value;
}
}


if (!value.Contains('\r'))
{
return value.Replace("\n", "\r\n");
Expand Down
3 changes: 2 additions & 1 deletion uSync.Core/Mapping/SyncNestedValueMapperBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ protected JObject GetImportProperties(JObject item, IContentType docType)
if (value != null)
{
var mappedVal = mapperCollection.Value.GetImportValue(value.ToString(), property.PropertyEditorAlias);
item[property.Alias] = mappedVal?.ToString() ?? null; // .GetJsonTokenValue();
item[property.Alias] = // mappedVal?.ToString() ?? null;
mappedVal?.ToString().GetJsonTokenValue() ?? null;
}
}
}
Expand Down

0 comments on commit b1ad552

Please sign in to comment.