Remove botched SimpleSelect

pull/6/head
Matija Koželj 2 years ago
parent ed15c8f24d
commit 4f36e41d73

@ -1,18 +0,0 @@
@using Connected.Models;
@typeparam ValueType
@inherits InputBase;
<div class="@InputFieldClassList">
<select @bind="@Value" @oninput="@ChangeValueAsync">
@if (EnableSearch)
{
<InputText @bind-Value="@SearchText" ValueChanged=""></InputText>
}
@foreach(SelectItem<ValueType> item in Items)
{
<option value="@item.Value">@item.DisplayedText</option>
}
</select>
</div>

@ -1,45 +0,0 @@
using Connected.Models;
using Microsoft.AspNetCore.Components;
using System;
namespace Connected.Components;
public partial class SimpleSelect<ValueType> : InputBase
{
[Parameter]
public ValueType Value { get; set; }
[Parameter]
public IEnumerable<SelectItem<ValueType>> Items { get; set; }
public IEnumerable<SelectItem<ValueType>> OriginalItems { get; set; }
[Parameter]
public bool EnableSearch { get; set; } = true;
public string SearchText { get; set; }
public void FilterItems()
{
Items= Items.Where(item => item.Value.ToString().ToLower().Contains(SearchText.ToLower()) || item.DisplayedText.ToString().ToLower().Contains(SearchText.ToLower()));
}
[Parameter]
public EventCallback<ValueType> ValueChanged { get; set; }
private async Task ChangeValueAsync(ChangeEventArgs args)
{
await ValueChanged.InvokeAsync((ValueType)Convert.ChangeType(args.Value, typeof(ValueType)));
}
protected override async Task OnParametersSetAsync()
{
if (base.InputAttributes is null) base.InputAttributes = new();
if (base.Required)
{
if (base.InputAttributes.ContainsKey("required")) base.InputAttributes.Add("required", true);
}
OriginalItems = Items;
await base.OnInitializedAsync();
}
}
Loading…
Cancel
Save