< 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{
 3412    protected virtual bool RefreshOnChange => false;
 13
 14    /// <inheritdoc />
 15    public override async ValueTask<IDictionary<string, object>> GetUIPropertiesAsync(PropertyInfo propertyInfo, object?
 16    {
 3417        var items = await GetItemsAsync(propertyInfo, context, cancellationToken);
 3418        var props = new CheckListProps
 3419        {
 3420            CheckList = new()
 3421            {
 3422                Items = items.ToList()
 3423            }
 3424        };
 25
 3426        var options = new Dictionary<string, object>
 3427        {
 3428            [InputUIHints.CheckList] = props
 3429        };
 30
 3431        options.AddRange(GetUIPropertyAdditionalOptions());
 32
 3433        return options;
 3434    }
 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    {
 3443        var options = new Dictionary<string, object>();
 3444        if (RefreshOnChange) options["Refresh"] = true;
 3445        return options;
 46    }
 47}