mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-03-30 18:31:38 +00:00
fixed final bugs
This commit is contained in:
parent
133be5b325
commit
41126be7b7
@ -6,6 +6,7 @@
|
|||||||
T="string"
|
T="string"
|
||||||
SelectedValues="@this.SelectedValues"
|
SelectedValues="@this.SelectedValues"
|
||||||
SelectedValuesChanged="@this.OnSelectedValuesChanged"
|
SelectedValuesChanged="@this.OnSelectedValuesChanged"
|
||||||
|
MultiSelectionTextFunc="@this.GetMultiSelectionText"
|
||||||
Label="@this.Label"
|
Label="@this.Label"
|
||||||
HelperText="@this.HelperText"
|
HelperText="@this.HelperText"
|
||||||
Placeholder="@this.Default.Display"
|
Placeholder="@this.Default.Display"
|
||||||
@ -18,7 +19,7 @@
|
|||||||
MultiSelection="@true"
|
MultiSelection="@true"
|
||||||
SelectAll="@this.HasSelectAll"
|
SelectAll="@this.HasSelectAll"
|
||||||
SelectAllText="@this.SelectAllText">
|
SelectAllText="@this.SelectAllText">
|
||||||
@foreach (var item in Items)
|
@foreach (var item in this.GetRenderedItems())
|
||||||
{
|
{
|
||||||
<MudSelectItem Value="@item.Value">
|
<MudSelectItem Value="@item.Value">
|
||||||
@item.Display
|
@item.Display
|
||||||
@ -41,7 +42,7 @@
|
|||||||
AdornmentColor="@this.IconColor"
|
AdornmentColor="@this.IconColor"
|
||||||
Variant="@this.Variant"
|
Variant="@this.Variant"
|
||||||
Margin="Margin.Normal">
|
Margin="Margin.Normal">
|
||||||
@foreach (var item in Items)
|
@foreach (var item in this.GetRenderedItems())
|
||||||
{
|
{
|
||||||
<MudSelectItem Value="@item.Value">
|
<MudSelectItem Value="@item.Value">
|
||||||
@item.Display
|
@item.Display
|
||||||
|
|||||||
@ -71,6 +71,38 @@ namespace AIStudio.Components
|
|||||||
await this.SelectedValuesChanged.InvokeAsync(updatedValues);
|
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)
|
private string MergeClasses(string custom, string fallback)
|
||||||
{
|
{
|
||||||
var trimmedCustom = custom?.Trim() ?? string.Empty;
|
var trimmedCustom = custom?.Trim() ?? string.Empty;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user