Skip to content

Commit

Permalink
Fix floating version issue requering minimum 7.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronny Birkeli committed May 15, 2023
1 parent d7bcd60 commit 247aafb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/Altinn.Codelists/Altinn.Codelists.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Altinn.App.Core" Version="7.*-*" />
<PackageReference Include="Altinn.App.Core" Version="7.8.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="7.0.0" />
<PackageReference Include="Scrutor" Version="4.2.2" />
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
Expand Down
38 changes: 8 additions & 30 deletions src/Altinn.Codelists/SSB/ClassificationCodelistProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,40 +60,18 @@ public async Task<AppOptions> GetAppOptionsAsync(string language, Dictionary<str

private AppOptions GetAppOptions(Clients.ClassificationCodes classificationCode, string parentCode)
{
AppOptions appOptions;
// From Altinn.App.Core version 7.8.0 we can add description to AppOptions.
// This is not supported in older versions, and we need to check if the property exists.
if (AppOptionsSupportsDescription())
AppOptions appOptions = new AppOptions
{
appOptions = new AppOptions
{
// The api we use doesn't support filtering on partentCode,
// hence we need to filter afterwards.
Options = string.IsNullOrEmpty(parentCode)
? classificationCode.Codes.Select(x => new AppOption() { Value = x.Code, Label = x.Name, Description = _options.GetDescription(x), HelpText = _options.GetHelpText(x)}).ToList()
: classificationCode.Codes.Where(c => c.ParentCode == parentCode).Select(x => new AppOption() { Value = x.Code, Label = x.Name, Description = _options.GetDescription(x), HelpText = _options.GetHelpText(x) }).ToList()
};
}
else
{
appOptions = new AppOptions
{
// The api we use doesn't support filtering on partentCode,
// hence we need to filter afterwards.
Options = string.IsNullOrEmpty(parentCode)
? classificationCode.Codes.Select(x => new AppOption() { Value = x.Code, Label = x.Name }).ToList()
: classificationCode.Codes.Where(c => c.ParentCode == parentCode).Select(x => new AppOption() { Value = x.Code, Label = x.Name }).ToList()
};
}

// The api we use doesn't support filtering on partentCode,
// hence we need to filter afterwards.
Options = string.IsNullOrEmpty(parentCode)
? classificationCode.Codes.Select(x => new AppOption() { Value = x.Code, Label = x.Name, Description = _options.GetDescription(x), HelpText = _options.GetHelpText(x)}).ToList()
: classificationCode.Codes.Where(c => c.ParentCode == parentCode).Select(x => new AppOption() { Value = x.Code, Label = x.Name, Description = _options.GetDescription(x), HelpText = _options.GetHelpText(x) }).ToList()
};

return appOptions;
}

private static bool AppOptionsSupportsDescription()
{
return typeof(AppOption).GetProperties().Any(x => x.Name == "Description");
}

private static Dictionary<string, string> MergeDictionaries(Dictionary<string, string> defaultValues, Dictionary<string, string> overridingValues)
{
var mergedDictionary = new Dictionary<string, string>(defaultValues);
Expand Down

0 comments on commit 247aafb

Please sign in to comment.