2025-09-24 20:58:23 -05:00
|
|
|
@typeparam TTaxonomy where TTaxonomy : BaseTaxonomyModel
|
|
|
|
|
|
|
|
|
|
<TagsInput
|
2025-12-06 19:28:04 -06:00
|
|
|
DataSource="_entities"
|
2025-09-24 20:58:23 -05:00
|
|
|
OnCreateTag="Add"
|
|
|
|
|
Values="Values"
|
|
|
|
|
ValuesChanged="ValuesChanged"
|
|
|
|
|
OptionLabelSelector="t => t.Name" />
|
|
|
|
|
|
|
|
|
|
@code {
|
2025-12-17 14:50:05 +11:00
|
|
|
[Parameter] public required BaseDatabaseService<TTaxonomy> DataService { get; set; }
|
|
|
|
|
[Parameter] public required ICollection<TTaxonomy>? Values { get; set; }
|
2025-09-24 20:58:23 -05:00
|
|
|
[Parameter] public EventCallback<ICollection<TTaxonomy>> ValuesChanged { get; set; }
|
|
|
|
|
|
|
|
|
|
ICollection<TTaxonomy> _entities = new List<TTaxonomy>();
|
|
|
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
{
|
|
|
|
|
_entities = await DataService.AsNoTracking().GetAsync();
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-06 19:28:04 -06:00
|
|
|
async Task<TTaxonomy> Add(string name)
|
2025-09-24 20:58:23 -05:00
|
|
|
{
|
2025-12-17 14:50:05 +11:00
|
|
|
var taxonomy = (TTaxonomy?)Activator.CreateInstance(typeof(TTaxonomy));
|
|
|
|
|
|
|
|
|
|
if (taxonomy == null)
|
|
|
|
|
throw new InvalidOperationException($"Could not create instance of type {nameof(TTaxonomy)}");
|
2025-09-24 20:58:23 -05:00
|
|
|
|
|
|
|
|
taxonomy.Name = name;
|
|
|
|
|
|
|
|
|
|
taxonomy = await DataService.AddAsync(taxonomy);
|
|
|
|
|
|
2025-12-06 19:28:04 -06:00
|
|
|
return taxonomy;
|
2025-09-24 20:58:23 -05:00
|
|
|
}
|
|
|
|
|
}
|