diff --git a/src/apps/Elsa.Server.Web/Activities/CheckedActivity.cs b/src/apps/Elsa.Server.Web/Activities/CheckedActivity.cs new file mode 100644 index 000000000..0f2d58288 --- /dev/null +++ b/src/apps/Elsa.Server.Web/Activities/CheckedActivity.cs @@ -0,0 +1,19 @@ +using Elsa.Extensions; +using Elsa.Workflows; +using Elsa.Workflows.Attributes; +using Elsa.Workflows.Models; +using Elsa.Workflows.UIHints; +using Elsa.Workflows.UIHints.CheckList; + +namespace Elsa.Server.Web.Activities; + +public class CheckedActivity : CodeActivity +{ + [Input(UIHint = InputUIHints.CheckList, UIHandler = typeof(StaticCheckListOptionsProvider), Options = new[]{"A", "B", "C"})] + public Input CheckedItems { get; set; } + + protected override void Execute(ActivityExecutionContext context) + { + context.SetResult(CheckedItems.GetOrDefault(context)); + } +} \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Core/UIHints/CheckList/DropDownOptionsProviderBase.cs b/src/modules/Elsa.Workflows.Core/UIHints/CheckList/CheckListOptionsProviderBase.cs similarity index 100% rename from src/modules/Elsa.Workflows.Core/UIHints/CheckList/DropDownOptionsProviderBase.cs rename to src/modules/Elsa.Workflows.Core/UIHints/CheckList/CheckListOptionsProviderBase.cs diff --git a/src/modules/Elsa.Workflows.Core/UIHints/CheckList/StaticCheckListOptionsProvider.cs b/src/modules/Elsa.Workflows.Core/UIHints/CheckList/StaticCheckListOptionsProvider.cs index 52ede3106..ada8c26db 100644 --- a/src/modules/Elsa.Workflows.Core/UIHints/CheckList/StaticCheckListOptionsProvider.cs +++ b/src/modules/Elsa.Workflows.Core/UIHints/CheckList/StaticCheckListOptionsProvider.cs @@ -6,32 +6,22 @@ namespace Elsa.Workflows.UIHints.CheckList; /// /// Provides static drop-down options for a given property. /// -public class StaticCheckListOptionsProvider : IPropertyUIHandler +public class StaticCheckListOptionsProvider : CheckListOptionsProviderBase { /// - public ValueTask> GetUIPropertiesAsync(PropertyInfo propertyInfo, object? context, CancellationToken cancellationToken = default) + protected override ValueTask> GetItemsAsync(PropertyInfo propertyInfo, object? context, CancellationToken cancellationToken) { var inputAttribute = propertyInfo.GetCustomAttribute(); var inputOptions = inputAttribute?.Options; - var dictionary = new Dictionary(); if (inputOptions == null) - return new(dictionary); + return new([]); var selectListItems = (inputOptions as ICollection)?.Select(x => new CheckListItem(x, x)).ToList(); if (selectListItems == null) - return new(dictionary); - - var props = new CheckListProps - { - CheckList = new() - { - Items = selectListItems.ToList() - } - }; - - dictionary[InputUIHints.CheckList] = props; - return new(dictionary); + return new([]); + + return new(selectListItems); } } \ No newline at end of file