Add UI hints to input fields in workflow core modules
Changed a number of instances in both activities and UI Hints classes across multiple modules in the workflow core to utilize UIHints. The UI hint "DropDown" has been added to relevant input fields to improve the user interface. Special handling for Enum properties in the drop-down options provider has also been created.
This commit is contained in:
parent
0bf562f72c
commit
fac292a9e3
|
|
@ -27,7 +27,11 @@ public class WriteHttpResponse : Activity
|
|||
/// <summary>
|
||||
/// The status code to return.
|
||||
/// </summary>
|
||||
[Input(DefaultValue = HttpStatusCode.OK, Description = "The status code to return.")]
|
||||
[Input(
|
||||
DefaultValue = HttpStatusCode.OK,
|
||||
Description = "The status code to return.",
|
||||
UIHint = InputUIHints.DropDown
|
||||
)]
|
||||
public Input<HttpStatusCode> StatusCode { get; set; } = new(HttpStatusCode.OK);
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using Elsa.Extensions;
|
|||
using Elsa.Workflows.Activities.Flowchart.Attributes;
|
||||
using Elsa.Workflows.Attributes;
|
||||
using Elsa.Workflows.Models;
|
||||
using Elsa.Workflows.UIHints;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Elsa.Workflows.Activities.Flowchart.Activities;
|
||||
|
|
@ -36,7 +37,7 @@ public class FlowDecision : Activity
|
|||
/// <summary>
|
||||
/// The condition to evaluate.
|
||||
/// </summary>
|
||||
[Input(UIHint = "single-line")]
|
||||
[Input(UIHint = InputUIHints.SingleLine)]
|
||||
public Input<bool> Condition { get; set; } = new(new Literal<bool>(false));
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using Elsa.Workflows.Activities.Flowchart.Attributes;
|
|||
using Elsa.Workflows.Activities.Flowchart.Models;
|
||||
using Elsa.Workflows.Attributes;
|
||||
using Elsa.Workflows.Models;
|
||||
using Elsa.Workflows.UIHints;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Elsa.Workflows.Activities.Flowchart.Activities;
|
||||
|
|
@ -23,12 +24,19 @@ public class FlowSwitch : Activity
|
|||
{
|
||||
}
|
||||
|
||||
[Input(UIHint = "flow-switch-editor")] public ICollection<FlowSwitchCase> Cases { get; set; } = new List<FlowSwitchCase>();
|
||||
/// <summary>
|
||||
/// The possible cases to evaluate.
|
||||
/// </summary>
|
||||
[Input(UIHint = "flow-switch-editor")]
|
||||
public ICollection<FlowSwitchCase> Cases { get; set; } = new List<FlowSwitchCase>();
|
||||
|
||||
/// <summary>
|
||||
/// The switch mode determines whether the first match should be scheduled, or all matches.
|
||||
/// </summary>
|
||||
[Input(Description = "The switch mode determines whether the first match should be scheduled, or all matches.")]
|
||||
[Input(
|
||||
Description = "The switch mode determines whether the first match should be scheduled, or all matches.",
|
||||
UIHint = InputUIHints.DropDown
|
||||
)]
|
||||
public Input<SwitchMode> Mode { get; set; } = new(SwitchMode.MatchFirst);
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
@ -37,8 +45,8 @@ public class FlowSwitch : Activity
|
|||
var matchingCases = (await FindMatchingCasesAsync(context.ExpressionExecutionContext)).ToList();
|
||||
var hasAnyMatches = matchingCases.Any();
|
||||
var mode = context.Get(Mode);
|
||||
var results = mode == SwitchMode.MatchFirst ? hasAnyMatches ? new[] { matchingCases.First() } : Array.Empty<FlowSwitchCase>() : matchingCases.ToArray();
|
||||
var outcomes = hasAnyMatches ? results.Select(r => r.Label).ToArray() : new[] { "Default" };
|
||||
var results = mode == SwitchMode.MatchFirst ? hasAnyMatches ? [matchingCases.First()] : Array.Empty<FlowSwitchCase>() : matchingCases.ToArray();
|
||||
var outcomes = hasAnyMatches ? results.Select(r => r.Label).ToArray() : ["Default"];
|
||||
|
||||
await context.CompleteActivityAsync(new Outcomes(outcomes));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using Elsa.Extensions;
|
|||
using Elsa.Workflows.Attributes;
|
||||
using Elsa.Workflows.Contracts;
|
||||
using Elsa.Workflows.Signals;
|
||||
using Elsa.Workflows.UIHints;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Elsa.Workflows.Activities;
|
||||
|
|
@ -27,7 +28,10 @@ public class Fork : Activity
|
|||
/// <summary>
|
||||
/// Controls when this activity yields control back to its parent activity.
|
||||
/// </summary>
|
||||
[Input(Description = "Controls when this activity yields control back to its parent activity.")]
|
||||
[Input(
|
||||
Description = "Controls when this activity yields control back to its parent activity.",
|
||||
UIHint = InputUIHints.DropDown
|
||||
)]
|
||||
public ForkJoinMode JoinMode { get; set; } = ForkJoinMode.WaitAll;
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using Elsa.Extensions;
|
|||
using Elsa.Workflows.Attributes;
|
||||
using Elsa.Workflows.Contracts;
|
||||
using Elsa.Workflows.Models;
|
||||
using Elsa.Workflows.UIHints;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Elsa.Workflows.Activities;
|
||||
|
|
@ -41,7 +42,7 @@ public class If : Activity<bool>
|
|||
/// <summary>
|
||||
/// The condition to evaluate.
|
||||
/// </summary>
|
||||
[Input(UIHint = "single-line")]
|
||||
[Input(UIHint = InputUIHints.SingleLine)]
|
||||
public Input<bool> Condition { get; set; } = new(new Literal<bool>(false));
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using Elsa.Extensions;
|
|||
using Elsa.Workflows.Attributes;
|
||||
using Elsa.Workflows.Contracts;
|
||||
using Elsa.Workflows.Models;
|
||||
using Elsa.Workflows.UIHints;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Elsa.Workflows.Activities;
|
||||
|
|
@ -40,7 +41,10 @@ public class Switch : Activity
|
|||
/// <summary>
|
||||
/// The switch mode determines whether the first match should be scheduled, or all matches.
|
||||
/// </summary>
|
||||
[Input(Description = "The switch mode determines whether the first match should be scheduled, or all matches.")]
|
||||
[Input(
|
||||
Description = "The switch mode determines whether the first match should be scheduled, or all matches.",
|
||||
UIHint = InputUIHints.DropDown
|
||||
)]
|
||||
public Input<SwitchMode> Mode { get; set; } = new(SwitchMode.MatchFirst);
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System.Reflection;
|
||||
using Elsa.Workflows.Attributes;
|
||||
using Elsa.Workflows.Contracts;
|
||||
using Elsa.Workflows.Models;
|
||||
|
||||
namespace Elsa.Workflows.UIHints.Dropdown;
|
||||
|
||||
|
|
@ -17,8 +18,27 @@ public class StaticDropDownOptionsProvider : IPropertyUIHandler
|
|||
var dictionary = new Dictionary<string, object>();
|
||||
|
||||
if (inputOptions == null)
|
||||
{
|
||||
// Is the property an enum?
|
||||
var wrappedPropertyType = propertyInfo.PropertyType.IsGenericType && propertyInfo.PropertyType.GetGenericTypeDefinition() == typeof(Input<>)
|
||||
? propertyInfo.PropertyType.GetGenericArguments()[0]
|
||||
: propertyInfo.PropertyType;
|
||||
|
||||
if (!wrappedPropertyType.IsEnum)
|
||||
return new(dictionary);
|
||||
|
||||
var enumValues = Enum.GetValues(wrappedPropertyType).Cast<object>().ToList();
|
||||
var enumSelectListItems = enumValues.Select(x => new SelectListItem(x.ToString()!, x.ToString()!)).ToList();
|
||||
var enumProps = new DropDownProps
|
||||
{
|
||||
SelectList = new SelectList(enumSelectListItems)
|
||||
};
|
||||
|
||||
dictionary[InputUIHints.DropDown] = enumProps;
|
||||
return new(dictionary);
|
||||
|
||||
}
|
||||
|
||||
var selectListItems = (inputOptions as ICollection<string>)?.Select(x => new SelectListItem(x, x)).ToList();
|
||||
|
||||
if (selectListItems == null)
|
||||
|
|
|
|||
Loading…
Reference in a new issue