< Summary

Information
Class: Elsa.Workflows.UIHints.RadioList.RadioListOptionsProviderBase
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/UIHints/RadioList/RadioListOptionsProviderBase.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 19
Coverable lines: 19
Total lines: 47
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_RefreshOnChange()100%210%
GetUIPropertiesAsync()100%210%
GetUIPropertyAdditionalOptions()0%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/UIHints/RadioList/RadioListOptionsProviderBase.cs

#LineLine coverage
 1using System.Reflection;
 2using Elsa.Extensions;
 3
 4namespace Elsa.Workflows.UIHints.RadioList;
 5
 6/// <summary>
 7/// A base class for providing options to populate a checklist UI component. This class is intended to be inherited to i
 8/// custom radiolist data logic by overriding the `GetItemsAsync` method.
 9/// </summary>
 10public abstract class RadioListOptionsProviderBase : PropertyUIHandlerBase
 11{
 012    protected virtual bool RefreshOnChange => false;
 13
 14    /// <inheritdoc />
 15    public override async ValueTask<IDictionary<string, object>> GetUIPropertiesAsync(PropertyInfo propertyInfo, object?
 16    {
 017        var items = await GetItemsAsync(propertyInfo, context, cancellationToken);
 018        var props = new RadioListProps
 019        {
 020            RadioList = new()
 021            {
 022                Items = items.ToList()
 023            }
 024        };
 25
 026        var options = new Dictionary<string, object>
 027        {
 028            [InputUIHints.RadioList] = props
 029        };
 30
 031        options.AddRange(GetUIPropertyAdditionalOptions());
 32
 033        return options;
 034    }
 35
 36    /// <summary>
 37    /// Implement this to provide items to the radio list.
 38    /// </summary>
 39    protected abstract ValueTask<ICollection<RadioListItem>> GetItemsAsync(PropertyInfo propertyInfo, object? context, C
 40
 41    protected virtual IDictionary<string, object> GetUIPropertyAdditionalOptions()
 42    {
 043        var options = new Dictionary<string, object>();
 044        if (RefreshOnChange) options["Refresh"] = true;
 045        return options;
 46    }
 47}