Allow passing of func for selectable and visible entries
parent
804e75da55
commit
9e0768a96d
|
@ -29,6 +29,8 @@
|
||||||
[Parameter] public bool AllowDirectories { get; set; } = false;
|
[Parameter] public bool AllowDirectories { get; set; } = false;
|
||||||
[Parameter] public string Prefix { get; set; }
|
[Parameter] public string Prefix { get; set; }
|
||||||
[Parameter] public string Root { 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;
|
bool ArchiveExists { get; set; } = false;
|
||||||
|
|
||||||
|
@ -56,7 +58,8 @@
|
||||||
Root = Root,
|
Root = Root,
|
||||||
Select = true,
|
Select = true,
|
||||||
Multiple = false,
|
Multiple = false,
|
||||||
AllowDirectories = AllowDirectories
|
EntrySelectable = EntrySelectable,
|
||||||
|
EntryVisible = EntryVisible
|
||||||
};
|
};
|
||||||
|
|
||||||
var modalRef = await ModalService.CreateModalAsync<FilePickerDialog, FilePickerOptions, IEnumerable<IFileManagerEntry>>(modalOptions, browserOptions);
|
var modalRef = await ModalService.CreateModalAsync<FilePickerDialog, FilePickerOptions, IEnumerable<IFileManagerEntry>>(modalOptions, browserOptions);
|
||||||
|
|
|
@ -3,21 +3,14 @@
|
||||||
@using LANCommander.Components.FileManagerComponents;
|
@using LANCommander.Components.FileManagerComponents;
|
||||||
@using LANCommander.Models;
|
@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 {
|
@code {
|
||||||
|
|
||||||
private IEnumerable<IFileManagerEntry> SelectedFiles { get; set; }
|
private IEnumerable<IFileManagerEntry> SelectedFiles { get; set; }
|
||||||
|
|
||||||
public override async Task OnFeedbackOkAsync(ModalClosingEventArgs args)
|
public override async Task OnFeedbackOkAsync(ModalClosingEventArgs args)
|
||||||
{
|
{
|
||||||
await base.OkCancelRefWithResult!.OnOk(SelectedFiles);
|
await base.OkCancelRefWithResult!.OnOk(SelectedFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsEntrySelectable(IFileManagerEntry entry)
|
|
||||||
{
|
|
||||||
if (!Options.AllowDirectories && entry is FileManagerDirectory)
|
|
||||||
return false;
|
|
||||||
else
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
namespace LANCommander.Models
|
using LANCommander.Components.FileManagerComponents;
|
||||||
|
|
||||||
|
namespace LANCommander.Models
|
||||||
{
|
{
|
||||||
public class FilePickerOptions
|
public class FilePickerOptions
|
||||||
{
|
{
|
||||||
|
@ -6,6 +8,7 @@
|
||||||
public string Root { get; set; }
|
public string Root { get; set; }
|
||||||
public bool Select { get; set; }
|
public bool Select { get; set; }
|
||||||
public bool Multiple { get; set; } = false;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue