Comments (2)
To address the issue of nullable enum types not displaying options in the dropdown, you can modify the StaticDropDownOptionsProvider
class to handle nullable enums by checking if the property type is nullable and extracting the underlying enum type if it is. Then, you can add a blank item to the dropdown list to represent the null option.
Here's a code snippet that demonstrates how you might implement this:
public class StaticDropDownOptionsProvider : IActivityPropertyOptionsProvider
{
public ValueTask<IEnumerable<SelectListItem>> GetOptionsAsync(ActivityPropertyOptionsContext context)
{
var propertyType = context.Property.PropertyType;
var underlyingType = Nullable.GetUnderlyingType(propertyType);
var enumType = underlyingType ?? propertyType;
if (!enumType.IsEnum)
throw new ArgumentException("The specified property type is not an enum type.");
var enumValues = Enum.GetValues(enumType).Cast<object>()
.Select(x => new SelectListItem(x.ToString(), x.ToString()))
.ToList();
// If the enum is nullable, add a blank option to represent null.
if (underlyingType != null)
{
enumValues.Insert(0, new SelectListItem(string.Empty, null));
}
return new ValueTask<IEnumerable<SelectListItem>>(enumValues);
}
}
In this code, underlyingType
is used to determine if the property type is a nullable enum. If it is, a blank SelectListItem
is inserted at the beginning of the list to represent the null option.
Regarding the enhancement request, it seems like you've already identified a solution and are considering submitting a pull request. If you believe your solution is robust and doesn't negatively impact other parts of the system, I would encourage you to contribute to the project by submitting a pull request. Make sure to include unit tests that cover the new functionality and document the changes in the PR description.
Before submitting the PR, you may also want to discuss your proposed changes with the Elsa community or maintainers to get feedback and ensure that it aligns with the project's goals and coding standards.
If you need further assistance or have additional questions, please let me know.
This comment was generated by Glime.
from elsa-core.
Related Issues (20)
- How to make the activity execute automatically after the process is restored? HOT 1
- [BUG] toJson() incorrectly decodes encoded characters HOT 1
- [CHORE] Update packages to latest version
- Migrate Elsa 2 to use AutoMapper 13.0.1 to avoid conflicts HOT 2
- Elsa.WriteLine expression and memory reference HOT 1
- [BUG] WorkflowInput does not persist in Bookmark Callback HOT 1
- Next Activity Found But Not Scheduled After Resume [Elsa 3.1.2] HOT 5
- Could you please help me solve this problem as soon as possible? Thank you! HOT 2
- Read event inputs in next activity? HOT 1
- [BUG] Timer Trigger not respecting SingletoneStrategy HOT 3
- Elsa 3.1 oracle migration support HOT 1
- [BUG] Default CRON causes extremely high memory usage until Out of Memory exception HOT 7
- [BUG] Race Condition in WorkflowDefinitionActivity Causing Execution Failures HOT 1
- [BUG] ResumeWorkflowAsync at ActivityNodeId losing Input values between activities HOT 3
- Unable to Open Workflow Instance View Screen in Customized Elsa UI HOT 3
- Workflow instance viewer activity badges don't update after resuming workflow for a suspended HttpEndpoint activity HOT 1
- [BUG] InvalidOperationException: No service for type 'Elsa.Api.Client.Resources.Package.Contracts.IPackageApi' has been registered. HOT 2
- [DOC] Blocking activities has incorrect code examples HOT 2
- Elsa 3.1.3 Http end point using dispatch workflow not waiting for child workflow completion even though 'Wait for completion' set true HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elsa-core.