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

Update the logic for repetable strings. #508

Merged
merged 1 commit into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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