mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-03-30 07:11:38 +00:00
fixed final bugs
This commit is contained in:
parent
133be5b325
commit
41126be7b7
@ -6,6 +6,7 @@
|
||||
T="string"
|
||||
SelectedValues="@this.SelectedValues"
|
||||
SelectedValuesChanged="@this.OnSelectedValuesChanged"
|
||||
MultiSelectionTextFunc="@this.GetMultiSelectionText"
|
||||
Label="@this.Label"
|
||||
HelperText="@this.HelperText"
|
||||
Placeholder="@this.Default.Display"
|
||||
@ -18,7 +19,7 @@
|
||||
MultiSelection="@true"
|
||||
SelectAll="@this.HasSelectAll"
|
||||
SelectAllText="@this.SelectAllText">
|
||||
@foreach (var item in Items)
|
||||
@foreach (var item in this.GetRenderedItems())
|
||||
{
|
||||
<MudSelectItem Value="@item.Value">
|
||||
@item.Display
|
||||
@ -41,7 +42,7 @@
|
||||
AdornmentColor="@this.IconColor"
|
||||
Variant="@this.Variant"
|
||||
Margin="Margin.Normal">
|
||||
@foreach (var item in Items)
|
||||
@foreach (var item in this.GetRenderedItems())
|
||||
{
|
||||
<MudSelectItem Value="@item.Value">
|
||||
@item.Display
|
||||
|
||||
@ -71,6 +71,38 @@ namespace AIStudio.Components
|
||||
await this.SelectedValuesChanged.InvokeAsync(updatedValues);
|
||||
}
|
||||
|
||||
private List<AssistantDropdownItem> GetRenderedItems()
|
||||
{
|
||||
var items = this.Items ?? [];
|
||||
if (string.IsNullOrWhiteSpace(this.Default.Value))
|
||||
return items;
|
||||
|
||||
if (items.Any(item => string.Equals(item.Value, this.Default.Value, StringComparison.Ordinal)))
|
||||
return items;
|
||||
|
||||
return [this.Default, .. items];
|
||||
}
|
||||
|
||||
private string GetMultiSelectionText(List<string?>? selectedValues)
|
||||
{
|
||||
if (selectedValues is null || selectedValues.Count == 0)
|
||||
return this.Default.Display;
|
||||
|
||||
var labels = selectedValues
|
||||
.Where(value => !string.IsNullOrWhiteSpace(value))
|
||||
.Select(value => this.ResolveDisplayText(value!))
|
||||
.Where(value => !string.IsNullOrWhiteSpace(value))
|
||||
.ToList();
|
||||
|
||||
return labels.Count == 0 ? this.Default.Display : string.Join(", ", labels);
|
||||
}
|
||||
|
||||
private string ResolveDisplayText(string value)
|
||||
{
|
||||
var item = this.GetRenderedItems().FirstOrDefault(item => string.Equals(item.Value, value, StringComparison.Ordinal));
|
||||
return item?.Display ?? value;
|
||||
}
|
||||
|
||||
private string MergeClasses(string custom, string fallback)
|
||||
{
|
||||
var trimmedCustom = custom?.Trim() ?? string.Empty;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user