forked from elsa-workflows/elsa-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor code by renaming and moving classes
Renamed 'VehiculeActivity', 'VehiculeUIHandler' to 'VehicleActivity', 'VehicleUIHandler' and moved them to their separate files. A debouncer was added to InputsTab in the WorkflowDefinitionEditor to limit the rate of firing refresh requests. Optimized codes by reducing unnecessary lines and improved consistency in the 'Program.cs' file.
- Loading branch information
1 parent
cfb3d03
commit d635226
Showing
5 changed files
with
76 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/samples/aspnet/Elsa.Samples.AspNet.CustomUIHandler/RefreshUIHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Reflection; | ||
using Elsa.Workflows.Contracts; | ||
|
||
namespace Elsa.Samples.AspNet.CustomUIHandler; | ||
|
||
/// <summary> | ||
/// Configures the specified property to refresh the UI when the property value changes. | ||
/// </summary> | ||
public class RefreshUIHandler : IPropertyUIHandler | ||
{ | ||
public ValueTask<IDictionary<string, object>> GetUIPropertiesAsync(PropertyInfo propertyInfo, object? context, CancellationToken cancellationToken = default) | ||
{ | ||
IDictionary<string, object> result = new Dictionary<string, object> | ||
{ | ||
{ "Refresh", true } | ||
}; | ||
return ValueTask.FromResult(result); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/samples/aspnet/Elsa.Samples.AspNet.CustomUIHandler/VehicleActivity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Elsa.Workflows; | ||
using Elsa.Workflows.Attributes; | ||
using Elsa.Workflows.Models; | ||
using Elsa.Workflows.UIHints; | ||
|
||
namespace Elsa.Samples.AspNet.CustomUIHandler; | ||
|
||
/// <summary> | ||
/// A sample activity that let's you select a car brand. | ||
/// </summary> | ||
public class VehicleActivity : Activity<string> | ||
{ | ||
[Input( | ||
Description = "The content type to use when sending the request.", | ||
UIHint = InputUIHints.DropDown, | ||
UIHandlers = [typeof(VehicleUIHandler), typeof(RefreshUIHandler)] | ||
)] | ||
public Input<string> Brand { get; set; } = default!; | ||
} |
25 changes: 25 additions & 0 deletions
25
src/samples/aspnet/Elsa.Samples.AspNet.CustomUIHandler/VehicleUIHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.Reflection; | ||
using Elsa.Workflows.UIHints.Dropdown; | ||
|
||
namespace Elsa.Samples.AspNet.CustomUIHandler; | ||
|
||
/// <summary> | ||
/// A custom dropdown options provider to provide vehicle options for the Brand property of <see cref="VehicleActivity"/>. | ||
/// </summary> | ||
public class VehicleUIHandler : DropDownOptionsProviderBase | ||
{ | ||
private readonly Random _random = new(); | ||
|
||
protected override ValueTask<ICollection<SelectListItem>> GetItemsAsync(PropertyInfo propertyInfo, object? context, CancellationToken cancellationToken) | ||
{ | ||
var items = new List<SelectListItem> | ||
{ | ||
new("BMW", "1"), | ||
new("Tesla", "2"), | ||
new("Peugeot", "3"), | ||
new(_random.Next(100).ToString(), "4") | ||
}; | ||
|
||
return new(items); | ||
} | ||
} |
61 changes: 0 additions & 61 deletions
61
src/samples/aspnet/Elsa.Samples.AspNet.CustomUIHandler/VehiculeActivity.cs
This file was deleted.
Oops, something went wrong.