88 lines
2.0 KiB
C#
88 lines
2.0 KiB
C#
|
using Microsoft.AspNetCore.Components;
|
|||
|
using Seenginx.Models;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace Seenginx.Components
|
|||
|
{
|
|||
|
public partial class FilesWithEditor<CFile> : ComponentBase
|
|||
|
where CFile : ConfigFile
|
|||
|
{
|
|||
|
[Parameter]
|
|||
|
public List<CFile> Files { get; set; } = new List<CFile>();
|
|||
|
|
|||
|
[Parameter]
|
|||
|
public List<string> Filters { get; set; } = new List<string>();
|
|||
|
[Parameter]
|
|||
|
public List<int> FilteredOutFiles { get; set; } = new List<int>();
|
|||
|
[Parameter]
|
|||
|
public EventCallback<string> ApplyFilter { get; set; }
|
|||
|
|
|||
|
[Parameter]
|
|||
|
public RenderFragment<CFile> Editor { get; set; }
|
|||
|
|
|||
|
[Parameter]
|
|||
|
public RenderFragment<CFile> CreateDialog { get; set; }
|
|||
|
|
|||
|
[Parameter]
|
|||
|
public RenderFragment<CFile> UpdateDialog { get; set; }
|
|||
|
|
|||
|
[Parameter]
|
|||
|
public RenderFragment<CFile> DeleteDialog { get; set; }
|
|||
|
|
|||
|
protected bool IsAnyFileSelected => SelectedFile != default;
|
|||
|
|
|||
|
private CFile SelectedFile { get; set; }
|
|||
|
|
|||
|
protected string SearchInput { get; set; }
|
|||
|
|
|||
|
protected async Task OnDeselectClick()
|
|||
|
{
|
|||
|
SelectedFile = null;
|
|||
|
//Clean on the right
|
|||
|
}
|
|||
|
|
|||
|
protected async Task OnFilterClick(EventArgs e, string filter)
|
|||
|
{
|
|||
|
await ApplyFilter.InvokeAsync(filter);
|
|||
|
for (int index = 0; index < Files.Count; index++)
|
|||
|
if (FilteredOutFiles.Contains(index))
|
|||
|
Files[index].Hide();
|
|||
|
else
|
|||
|
Files[index].Unhide();
|
|||
|
}
|
|||
|
|
|||
|
protected async Task OnSearchChanged()
|
|||
|
{
|
|||
|
if (string.IsNullOrEmpty(SearchInput))
|
|||
|
Files.ForEach(f => f.Hide());
|
|||
|
else
|
|||
|
Files.ForEach(f =>
|
|||
|
{
|
|||
|
if (f.Name.ToLower().Contains(SearchInput.ToLower()))
|
|||
|
f.Unhide();
|
|||
|
else
|
|||
|
f.Hide();
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
protected async Task OnFileClick(CFile file)
|
|||
|
{
|
|||
|
SelectedFile = file;
|
|||
|
}
|
|||
|
|
|||
|
protected async Task OnCreateFile()
|
|||
|
{
|
|||
|
}
|
|||
|
protected async Task OnUpdateDialog(CFile file)
|
|||
|
{
|
|||
|
}
|
|||
|
protected async Task OnDeleteDialog(CFile file)
|
|||
|
{
|
|||
|
}
|
|||
|
}
|
|||
|
}
|