elsa-core/src/modules/Elsa.Workflows.Management/Models/InputUIHints.cs
Sipke Schoorstra fccf4737e2
V3 modular configuration (#3070)
* Restructuring (WIP)

* Fix warnings

* Move DSL to modules

* Update namespaces

* Make design factory base reusable

* Update service registrations

* Remove unused namespaces and rename ElsaDbContext

* Incremental work on migrations

* Generate WorkflowsDbContext SQLite migrations

* Rename ServiceCollectionExtensions

* Update DbContextOptionsBuilderExtensions.cs

* Restructure

* Configuration refactorings (WIP)

* Incremental work on configurator API

* Incremental work on configuration API

* Incremental work on configuration API

* Fix workflow runtime options

* Move standard stream providers

* Implement configurator dependencies

* Cleanup configurator API

* Update configurator dependencies

* Cleanup

* Update Label API endpoints

* Fix eager configuration issue
2022-05-26 12:47:31 +02:00

42 lines
1.4 KiB
C#

using System.Collections;
using Elsa.Workflows.Core.Attributes;
using Elsa.Workflows.Management.Extensions;
namespace Elsa.Workflows.Management.Models;
public static class InputUIHints
{
public const string SingleLine = "single-line";
public const string MultiLine = "multi-line";
public const string Checkbox = "checkbox";
public const string CheckList = "check-list";
public const string RadioList = "radio-list";
public const string Dropdown = "dropdown";
public const string MultiText = "multi-text";
public const string CodeEditor = "code-editor";
/// <summary>
/// An editor that allows the user to write a blob of JSON.
/// </summary>
public const string Json = "json";
public static string GetUIHint(Type wrappedPropertyType, InputAttribute? inputAttribute)
{
if (inputAttribute?.UIHint != null)
return inputAttribute.UIHint;
if (wrappedPropertyType == typeof(bool) || wrappedPropertyType == typeof(bool?))
return InputUIHints.Checkbox;
if (wrappedPropertyType == typeof(string))
return InputUIHints.SingleLine;
if (typeof(IEnumerable).IsAssignableFrom(wrappedPropertyType))
return InputUIHints.Dropdown;
if (wrappedPropertyType.IsEnum || wrappedPropertyType.IsNullableType() && wrappedPropertyType.GetTypeOfNullable().IsEnum)
return InputUIHints.Dropdown;
return InputUIHints.SingleLine;
}
}