diff --git a/app/MindWork AI Studio/Components/Blocks/EnumSelection.razor b/app/MindWork AI Studio/Components/Blocks/EnumSelection.razor
new file mode 100644
index 00000000..144d0ea1
--- /dev/null
+++ b/app/MindWork AI Studio/Components/Blocks/EnumSelection.razor
@@ -0,0 +1,17 @@
+@typeparam T
+@inherits EnumSelectionBase
+
+
+
+ @foreach (var value in Enum.GetValues())
+ {
+
+ @this.NameFunc(value)
+
+ }
+
+ @if (this.AllowOther && this.Value.Equals(this.OtherValue))
+ {
+
+ }
+
\ No newline at end of file
diff --git a/app/MindWork AI Studio/Components/Blocks/EnumSelection.razor.cs b/app/MindWork AI Studio/Components/Blocks/EnumSelection.razor.cs
new file mode 100644
index 00000000..d87384fc
--- /dev/null
+++ b/app/MindWork AI Studio/Components/Blocks/EnumSelection.razor.cs
@@ -0,0 +1,79 @@
+using AIStudio.Settings;
+
+using Microsoft.AspNetCore.Components;
+
+namespace AIStudio.Components.Blocks;
+
+public partial class EnumSelection : EnumSelectionBase where T : struct, Enum
+{
+ [Parameter]
+ public T Value { get; set; }
+
+ [Parameter]
+ public EventCallback ValueChanged { get; set; }
+
+ [Parameter]
+ public bool AllowOther { get; set; }
+
+ [Parameter]
+ public T OtherValue { get; set; }
+
+ [Parameter]
+ public string OtherInput { get; set; } = string.Empty;
+
+ [Parameter]
+ public EventCallback OtherInputChanged { get; set; }
+
+ [Parameter]
+ public string Label { get; set; } = string.Empty;
+
+ [Parameter]
+ public string LabelOther { get; set; } = "Other";
+
+ [Parameter]
+ public Func ValidateSelection { get; set; } = _ => null;
+
+ [Parameter]
+ public Func ValidateOther { get; set; } = _ => null;
+
+ [Parameter]
+ public string Icon { get; set; } = Icons.Material.Filled.ArrowDropDown;
+
+ ///
+ /// Gets or sets the custom name function for selecting the display name of an enum value.
+ ///
+ /// The enum type.
+ /// The enum value.
+ /// The display name of the enum value.
+ [Parameter]
+ public Func NameFunc { get; set; } = value => value.ToString();
+
+ [Parameter]
+ public Func SelectionUpdated { get; set; } = _ => Task.CompletedTask;
+
+ [Inject]
+ private SettingsManager SettingsManager { get; set; } = null!;
+
+ #region Overrides of ComponentBase
+
+ protected override async Task OnInitializedAsync()
+ {
+ // Configure the spellchecking for the user input:
+ this.SettingsManager.InjectSpellchecking(USER_INPUT_ATTRIBUTES);
+ await base.OnInitializedAsync();
+ }
+
+ #endregion
+
+ private async Task SelectionChanged(T value)
+ {
+ await this.ValueChanged.InvokeAsync(value);
+ await this.SelectionUpdated(value);
+ }
+
+ private async Task OtherValueChanged(string value)
+ {
+ await this.OtherInputChanged.InvokeAsync(value);
+ await this.SelectionUpdated(this.Value);
+ }
+}
\ No newline at end of file
diff --git a/app/MindWork AI Studio/Components/Blocks/EnumSelectionBase.cs b/app/MindWork AI Studio/Components/Blocks/EnumSelectionBase.cs
new file mode 100644
index 00000000..f84478de
--- /dev/null
+++ b/app/MindWork AI Studio/Components/Blocks/EnumSelectionBase.cs
@@ -0,0 +1,8 @@
+using Microsoft.AspNetCore.Components;
+
+namespace AIStudio.Components.Blocks;
+
+public abstract class EnumSelectionBase : ComponentBase
+{
+ protected static readonly Dictionary USER_INPUT_ATTRIBUTES = new();
+}
\ No newline at end of file
diff --git a/app/MindWork AI Studio/Components/Pages/TextSummarizer/AssistantTextSummarizer.razor b/app/MindWork AI Studio/Components/Pages/TextSummarizer/AssistantTextSummarizer.razor
index 82f138ed..6ea597f4 100644
--- a/app/MindWork AI Studio/Components/Pages/TextSummarizer/AssistantTextSummarizer.razor
+++ b/app/MindWork AI Studio/Components/Pages/TextSummarizer/AssistantTextSummarizer.razor
@@ -9,33 +9,8 @@
}
-
-
-
- @foreach (var targetLanguage in Enum.GetValues())
- {
- @targetLanguage.Name()
- }
-
- @if (this.selectedTargetLanguage is CommonLanguages.OTHER)
- {
-
- }
-
-
-
-
- @foreach (var targetComplexity in Enum.GetValues())
- {
- @targetComplexity.Name()
- }
-
- @if (this.selectedComplexity is Complexity.SCIENTIFIC_LANGUAGE_OTHER_EXPERTS)
- {
-
- }
-
-
+
+
@foreach (var provider in this.SettingsManager.ConfigurationData.Providers)
{
diff --git a/app/MindWork AI Studio/Components/Pages/Translation/AssistantTranslation.razor b/app/MindWork AI Studio/Components/Pages/Translation/AssistantTranslation.razor
index 090f1db6..70e5b6cc 100644
--- a/app/MindWork AI Studio/Components/Pages/Translation/AssistantTranslation.razor
+++ b/app/MindWork AI Studio/Components/Pages/Translation/AssistantTranslation.razor
@@ -18,26 +18,7 @@ else
}
-
-
- @foreach (var targetLanguage in Enum.GetValues())
- {
- if (targetLanguage is CommonLanguages.AS_IS)
- {
- Please select the target language
- }
- else
- {
- @targetLanguage.Name()
- }
- }
-
- @if (this.selectedTargetLanguage is CommonLanguages.OTHER)
- {
-
- }
-
-
+
@foreach (var provider in this.SettingsManager.ConfigurationData.Providers)
{
diff --git a/app/MindWork AI Studio/Components/Pages/Translation/AssistantTranslation.razor.cs b/app/MindWork AI Studio/Components/Pages/Translation/AssistantTranslation.razor.cs
index e21dcd31..9fccc651 100644
--- a/app/MindWork AI Studio/Components/Pages/Translation/AssistantTranslation.razor.cs
+++ b/app/MindWork AI Studio/Components/Pages/Translation/AssistantTranslation.razor.cs
@@ -67,6 +67,12 @@ public partial class AssistantTranslation : AssistantBaseCore
return null;
}
+ private string GetDisplayName(CommonLanguages language) => language switch
+ {
+ CommonLanguages.AS_IS => "Please select the target language",
+ _ => language.Name()
+ };
+
private async Task TranslateText(bool force)
{
if (!this.inputIsValid)