< Summary

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

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_RefreshOnChange()100%11100%
GetUIPropertiesAsync()100%11100%
GetUIPropertyAdditionalOptions()50%22100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/UIHints/CheckList/CheckListOptionsProviderBase.cs

#LineLine coverage
 1using System.Reflection;
 2using Elsa.Extensions;
 3
 4namespace Elsa.Workflows.UIHints.CheckList;
 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 checklist data logic by overriding the `GetItemsAsync` method.
 9/// </summary>
 10public abstract class CheckListOptionsProviderBase : PropertyUIHandlerBase
 11{
 2212    protected virtual bool RefreshOnChange => false;
 13
 14    /// <inheritdoc />
 15    public override async ValueTask<IDictionary<string, object>> GetUIPropertiesAsync(PropertyInfo propertyInfo, object?
 16    {
 2217        var items = await GetItemsAsync(propertyInfo, context, cancellationToken);
 2218        var props = new CheckListProps
 2219        {
 2220            CheckList = new()
 2221            {
 2222                Items = items.ToList()
 2223            }
 2224        };
 25
 2226        var options = new Dictionary<string, object>
 2227        {
 2228            [InputUIHints.CheckList] = props
 2229        };
 30
 2231        options.AddRange(GetUIPropertyAdditionalOptions());
 32
 2233        return options;
 2234    }
 35
 36    /// <summary>
 37    /// Implement this to provide items to the dropdown list.
 38    /// </summary>
 39    protected abstract ValueTask<ICollection<CheckListItem>> GetItemsAsync(PropertyInfo propertyInfo, object? context, C
 40
 41    protected virtual IDictionary<string, object> GetUIPropertyAdditionalOptions()
 42    {
 2243        var options = new Dictionary<string, object>();
 2244        if (RefreshOnChange) options["Refresh"] = true;
 2245        return options;
 46    }
 47}