|
|
@ -1,5 +1,6 @@
|
|
|
|
using Connected.Models;
|
|
|
|
using Connected.Models;
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Connected.Components;
|
|
|
|
namespace Connected.Components;
|
|
|
@ -9,17 +10,38 @@ public partial class SimpleSelect<ValueType> : InputBase
|
|
|
|
public ValueType Value { get; set; }
|
|
|
|
public ValueType Value { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
[Parameter]
|
|
|
|
public IEnumerable<SelectItem<ValueType>> Items { get; set; }
|
|
|
|
public IEnumerable<ValueType> Items { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public IEnumerable<SelectItem<ValueType>> OriginalItems { get; set; }
|
|
|
|
public IEnumerable<ValueType> OriginalItems { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
[Parameter]
|
|
|
|
public bool EnableSearch { get; set; } = true;
|
|
|
|
public bool EnableSearch { get; set; } = true;
|
|
|
|
public string SearchText { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void FilterItems()
|
|
|
|
private string _searchText { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
public string SearchText
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Items= Items.Where(item => item.Value.ToString().ToLower().Contains(SearchText.ToLower()) || item.DisplayedText.ToString().ToLower().Contains(SearchText.ToLower()));
|
|
|
|
get
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return _searchText;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_searchText = value;
|
|
|
|
|
|
|
|
FilterItems();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async Task FilterItems()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(_searchText))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Items = OriginalItems;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Items = Items.Where(item => item.ToString().ToLower().Contains(_searchText.ToLower()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
StateHasChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -41,5 +63,4 @@ public partial class SimpleSelect<ValueType> : InputBase
|
|
|
|
OriginalItems = Items;
|
|
|
|
OriginalItems = Items;
|
|
|
|
await base.OnInitializedAsync();
|
|
|
|
await base.OnInitializedAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|