Add option to select directories in archive browsers
This commit is contained in:
parent
c2dd624cec
commit
e2a28a57ea
3 changed files with 22 additions and 5 deletions
|
@ -22,14 +22,14 @@
|
||||||
DataSource="CurrentPathEntries"
|
DataSource="CurrentPathEntries"
|
||||||
HidePagination="true"
|
HidePagination="true"
|
||||||
Loading="Entries == null"
|
Loading="Entries == null"
|
||||||
RowSelectable="@(x => x.FullName != null && !x.FullName.EndsWith('/'))"
|
RowSelectable="@(x => CanSelect(x))"
|
||||||
OnRowClick="OnRowClicked"
|
OnRowClick="OnRowClicked"
|
||||||
SelectedRowsChanged="SelectedFilesChanged"
|
SelectedRowsChanged="SelectedFilesChanged"
|
||||||
ScrollY="calc(100vh - 55px - 55px - 53px)">
|
ScrollY="calc(100vh - 55px - 55px - 53px)">
|
||||||
|
|
||||||
@if (Select)
|
@if (Select)
|
||||||
{
|
{
|
||||||
<Selection Key="@context.FullName" Type="@(Multiple ? "checkbox" : "radio")" Disabled="@(context.FullName != null && context.FullName.EndsWith('/'))" />
|
<Selection Key="@context.FullName" Type="@(Multiple ? "checkbox" : "radio")" Disabled="@(!CanSelect(context))" />
|
||||||
}
|
}
|
||||||
<Column TData="string" Width="32">
|
<Column TData="string" Width="32">
|
||||||
<Icon Type="@GetIcon(context)" Theme="outline" />
|
<Icon Type="@GetIcon(context)" Theme="outline" />
|
||||||
|
@ -60,7 +60,8 @@
|
||||||
@code {
|
@code {
|
||||||
[Parameter] public Guid ArchiveId { get; set; }
|
[Parameter] public Guid ArchiveId { get; set; }
|
||||||
[Parameter] public bool Select { get; set; }
|
[Parameter] public bool Select { get; set; }
|
||||||
[Parameter] public bool Multiple { get; set; }
|
[Parameter] public bool Multiple { get; set; } = false;
|
||||||
|
[Parameter] public bool AllowDirectories { get; set; } = false;
|
||||||
|
|
||||||
[Parameter] public IEnumerable<ZipArchiveEntry> SelectedFiles { get; set; }
|
[Parameter] public IEnumerable<ZipArchiveEntry> SelectedFiles { get; set; }
|
||||||
[Parameter] public EventCallback<IEnumerable<ZipArchiveEntry>> SelectedFilesChanged { get; set; }
|
[Parameter] public EventCallback<IEnumerable<ZipArchiveEntry>> SelectedFilesChanged { get; set; }
|
||||||
|
@ -186,6 +187,21 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool CanSelect(ZipArchiveEntry entry)
|
||||||
|
{
|
||||||
|
if (entry == null || entry.FullName == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var isDirectory = entry.FullName.EndsWith('/');
|
||||||
|
|
||||||
|
if (isDirectory && AllowDirectories)
|
||||||
|
return true;
|
||||||
|
else if (!isDirectory)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public class ArchiveDirectory
|
public class ArchiveDirectory
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
@using System.IO.Compression;
|
@using System.IO.Compression;
|
||||||
@using LANCommander.Models;
|
@using LANCommander.Models;
|
||||||
|
|
||||||
<ArchiveBrowser ArchiveId="Options.ArchiveId" @bind-SelectedFiles="SelectedFiles" Select="Options.Select" Multiple="Options.Multiple" />
|
<ArchiveBrowser ArchiveId="Options.ArchiveId" @bind-SelectedFiles="SelectedFiles" Select="Options.Select" Multiple="Options.Multiple" AllowDirectories="Options.AllowDirectories" />
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private IEnumerable<ZipArchiveEntry> SelectedFiles { get; set; }
|
private IEnumerable<ZipArchiveEntry> SelectedFiles { get; set; }
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
{
|
{
|
||||||
public Guid ArchiveId { get; set; }
|
public Guid ArchiveId { get; set; }
|
||||||
public bool Select { get; set; }
|
public bool Select { get; set; }
|
||||||
public bool Multiple { get; set; }
|
public bool Multiple { get; set; } = false;
|
||||||
|
public bool AllowDirectories { get; set; } = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue