Allow passing of func for selectable and visible entries

dhcp-server
Pat Hartl 2023-09-11 19:17:00 -05:00
parent 804e75da55
commit 9e0768a96d
3 changed files with 11 additions and 12 deletions

View File

@ -29,6 +29,8 @@
[Parameter] public bool AllowDirectories { get; set; } = false;
[Parameter] public string Prefix { get; set; }
[Parameter] public string Root { get; set; }
[Parameter] public Func<IFileManagerEntry, bool> EntrySelectable { get; set; } = _ => true;
[Parameter] public Func<IFileManagerEntry, bool> EntryVisible { get; set; } = _ => true;
bool ArchiveExists { get; set; } = false;
@ -56,7 +58,8 @@
Root = Root,
Select = true,
Multiple = false,
AllowDirectories = AllowDirectories
EntrySelectable = EntrySelectable,
EntryVisible = EntryVisible
};
var modalRef = await ModalService.CreateModalAsync<FilePickerDialog, FilePickerOptions, IEnumerable<IFileManagerEntry>>(modalOptions, browserOptions);

View File

@ -3,21 +3,14 @@
@using LANCommander.Components.FileManagerComponents;
@using LANCommander.Models;
<FileManager ArchiveId="@Options.ArchiveId" WorkingDirectory="@Options.Root" @bind-Selected="SelectedFiles" EntrySelectable="IsEntrySelectable" SelectMultiple="Options.Multiple" Features="@(FileManagerFeatures.NavigationBack | FileManagerFeatures.NavigationForward | FileManagerFeatures.UpALevel | FileManagerFeatures.Breadcrumbs)" />
<FileManager ArchiveId="@Options.ArchiveId" WorkingDirectory="@Options.Root" @bind-Selected="SelectedFiles" EntrySelectable="Options.EntrySelectable" EntryVisible="Options.EntryVisible" SelectMultiple="Options.Multiple" Features="@(FileManagerFeatures.NavigationBack | FileManagerFeatures.NavigationForward | FileManagerFeatures.UpALevel | FileManagerFeatures.Breadcrumbs)" />
@code {
private IEnumerable<IFileManagerEntry> SelectedFiles { get; set; }
public override async Task OnFeedbackOkAsync(ModalClosingEventArgs args)
{
await base.OkCancelRefWithResult!.OnOk(SelectedFiles);
}
bool IsEntrySelectable(IFileManagerEntry entry)
{
if (!Options.AllowDirectories && entry is FileManagerDirectory)
return false;
else
return true;
}
}

View File

@ -1,4 +1,6 @@
namespace LANCommander.Models
using LANCommander.Components.FileManagerComponents;
namespace LANCommander.Models
{
public class FilePickerOptions
{
@ -6,6 +8,7 @@
public string Root { get; set; }
public bool Select { get; set; }
public bool Multiple { get; set; } = false;
public bool AllowDirectories { get; set; } = false;
public Func<IFileManagerEntry, bool> EntryVisible { get; set; } = _ => true;
public Func<IFileManagerEntry, bool> EntrySelectable { get; set; } = _ => true;
}
}