Implementing filtering
This commit is contained in:
parent
ae1726ce7a
commit
234a0e28cd
@ -4,7 +4,13 @@
|
||||
|
||||
<div class="files">
|
||||
|
||||
<div class="field is-horizontal sameMarginBottom">
|
||||
<div class="field has-addons sameMarginBottom">
|
||||
<div class="control has-icons-left is-expanded">
|
||||
<input formnovalidate @oninput="e => SearchInputChanged(e.Value.ToString())" class="input is-rounded is-small" type="text" placeholder="Search...">
|
||||
<span class="icon is-small is-left">
|
||||
<i class="mdi mdi-search-web"></i>
|
||||
</span>
|
||||
</div>
|
||||
<div class="control has-icons-left">
|
||||
<div class="select is-small is-rounded">
|
||||
<select @onchange="e => OnFilterClick(e.Value.ToString())">
|
||||
@ -18,12 +24,6 @@
|
||||
<i class="mdi mdi-folder-cog-outline"></i>
|
||||
</span>
|
||||
</div>
|
||||
<p class="control has-icons-left">
|
||||
<input formnovalidate @oninput="e => SearchInputChanged(e.Value.ToString())" class="input is-rounded is-small" type="text" placeholder="Search...">
|
||||
<span class="icon is-small is-left">
|
||||
<i class="mdi mdi-search-web"></i>
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="filesList neomorphSmall borderRSmall sameMarginBottom">
|
||||
|
@ -18,9 +18,7 @@ namespace Seenginx.Components
|
||||
[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; }
|
||||
public Dictionary<string, string> FilterFolder { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
[Parameter]
|
||||
public EventCallback AddFile { get; set; }
|
||||
@ -42,6 +40,7 @@ namespace Seenginx.Components
|
||||
public RenderFragment<CFile> DeleteDialog { get; set; }
|
||||
|
||||
protected string SelectedFilter { get; set; }
|
||||
protected string SearchInput { get; set; }
|
||||
|
||||
protected bool IsAnyFileSelected => SelectedFile != default;
|
||||
|
||||
@ -58,26 +57,69 @@ namespace Seenginx.Components
|
||||
|
||||
protected async Task OnFilterClick(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();
|
||||
SelectedFilter = filter;
|
||||
SearchFile();
|
||||
}
|
||||
|
||||
protected async Task SearchInputChanged(string searchInput)
|
||||
{
|
||||
if (string.IsNullOrEmpty(searchInput))
|
||||
SearchInput = searchInput;
|
||||
SearchFile();
|
||||
}
|
||||
|
||||
private void SearchFile()
|
||||
{
|
||||
if (string.IsNullOrEmpty(SearchInput))
|
||||
{
|
||||
if (SelectedFilter == "All")
|
||||
Files.ForEach(f => f.Unhide());
|
||||
else
|
||||
else if (SelectedFilter == "Root")
|
||||
Files.ForEach(f =>
|
||||
{
|
||||
if (f.Name.ToLower().Contains(searchInput.ToLower()))
|
||||
if (f.Folder == FilterFolder[SelectedFilter])
|
||||
f.Unhide();
|
||||
else
|
||||
f.Hide();
|
||||
});
|
||||
else
|
||||
Files.ForEach(f =>
|
||||
{
|
||||
if (f.Folder.Contains(FilterFolder[SelectedFilter]))
|
||||
f.Unhide();
|
||||
else
|
||||
f.Hide();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SelectedFilter == "All")
|
||||
Files.ForEach(f => { if (f.Name.ToLower().Contains(SearchInput)) f.Unhide(); else f.Hide(); });
|
||||
else if (SelectedFilter == "Root")
|
||||
Files.ForEach(f =>
|
||||
{
|
||||
if (f.Folder == FilterFolder[SelectedFilter])
|
||||
f.Unhide();
|
||||
else
|
||||
f.Hide();
|
||||
});
|
||||
else
|
||||
Files.ForEach(f =>
|
||||
{
|
||||
if (f.Folder.Contains(FilterFolder[SelectedFilter]))
|
||||
f.Unhide();
|
||||
else
|
||||
f.Hide();
|
||||
});
|
||||
//Files.ForEach(f => f.Unhide());
|
||||
//else
|
||||
// Files.ForEach(f =>
|
||||
// {
|
||||
// if (f.Name.ToLower().Contains(searchInput.ToLower()))
|
||||
// f.Unhide();
|
||||
// else
|
||||
// f.Hide();
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
protected async Task OnFileClick(MouseEventArgs e, CFile file)
|
||||
|
@ -2,8 +2,8 @@
|
||||
@page "/nginx"
|
||||
|
||||
|
||||
<FilesWithEditor CFile="ConfigFile" Filters="Filters" FilteredOutFiles="FilteredOutFiles" Files="ConfigFiles"
|
||||
SelectedFile="SelectedFile" SelectedFileChanged="SelectedFileChanged" ApplyFilter="ApplyFilter"
|
||||
<FilesWithEditor CFile="ConfigFile" Filters="Filters" Files="ConfigFiles" FilterFolder="FilterFolder"
|
||||
SelectedFile="SelectedFile" SelectedFileChanged="SelectedFileChanged"
|
||||
AddFile="AddFile" UpdateFile="UpdateFile" DeleteFile="DeleteFile" >
|
||||
<CreateDialog>
|
||||
|
||||
|
@ -23,7 +23,7 @@ namespace Seenginx.Pages
|
||||
public List<string> Filters { get; set; } = new List<string>();
|
||||
public List<int> FilteredOutFiles { get; set; } = new List<int>();
|
||||
|
||||
private Dictionary<string, string> FilterFolder { get; set; } = new Dictionary<string, string>();
|
||||
public Dictionary<string, string> FilterFolder { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
@ -37,28 +37,6 @@ namespace Seenginx.Pages
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
public async Task ApplyFilter(string filter)
|
||||
{
|
||||
if (filter == "All")
|
||||
ConfigFiles.ForEach(f => f.Unhide());
|
||||
else if (filter == "Root")
|
||||
ConfigFiles.ForEach(f =>
|
||||
{
|
||||
if (f.Folder == FilterFolder[filter])
|
||||
f.Unhide();
|
||||
else
|
||||
f.Hide();
|
||||
});
|
||||
else
|
||||
ConfigFiles.ForEach(f =>
|
||||
{
|
||||
if (f.Folder.Contains(FilterFolder[filter]))
|
||||
f.Unhide();
|
||||
else
|
||||
f.Hide();
|
||||
});
|
||||
}
|
||||
|
||||
public async Task SelectedFileChanged(ConfigFile configFile)
|
||||
{
|
||||
SelectedFile = configFile;
|
||||
|
Loading…
Reference in New Issue
Block a user