< 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{
 5812    protected virtual bool RefreshOnChange => false;
 13
 14    /// <inheritdoc />
 15    public override async ValueTask<IDictionary<string, object>> GetUIPropertiesAsync(PropertyInfo propertyInfo, object?
 16    {
 5817        var items = await GetItemsAsync(propertyInfo, context, cancellationToken);
 5818        var props = new CheckListProps
 5819        {
 5820            CheckList = new()
 5821            {
 5822                Items = items.ToList()
 5823            }
 5824        };
 25
 5826        var options = new Dictionary<string, object>
 5827        {
 5828            [InputUIHints.CheckList] = props
 5829        };
 30
 5831        options.AddRange(GetUIPropertyAdditionalOptions());
 32
 5833        return options;
 5834    }
 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    {
 5843        var options = new Dictionary<string, object>();
 5844        if (RefreshOnChange) options["Refresh"] = true;
 5845        return options;
 46    }
 47}