Skip to content

Commit

Permalink
#17 - Added support for language version creation logic for new items.
Browse files Browse the repository at this point in the history
  • Loading branch information
afaniuolo committed May 6, 2020
1 parent e31584d commit 5edfd63
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/WFFM.ConversionTool.Library/Factories/ItemFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ private List<SCField> CreateFields(Guid itemId, SCItem parentItem)
IEnumerable<Tuple<string, int>> langVersions = parentItem.Fields.Where(f => f.Version != null && f.Language != null).Select(f => new Tuple<string, int>(f.Language, (int)f.Version)).Distinct();
var languages = parentItem.Fields.Where(f => f.Language != null).Select(f => f.Language).Distinct();

var fieldLangVersions = _itemMetadataTemplate?.fields?.newFields?.Where(f => f.values != null).SelectMany(f => f.values.Select(v => v.Key).Distinct()).Distinct();

if (fieldLangVersions != null && fieldLangVersions.Any())
{
langVersions = fieldLangVersions;
languages = fieldLangVersions.Select(lv => lv.Item1).Distinct();
}

foreach (var newField in _itemMetadataTemplate.fields.newFields)
{
destFields.AddRange(_fieldFactory.CreateFields(newField, itemId, langVersions, languages));
Expand Down

0 comments on commit 5edfd63

Please sign in to comment.