Rename input to file picker
parent
8de8d7cfdc
commit
bf63813e90
|
@ -10,7 +10,13 @@
|
|||
</SpaceItem>
|
||||
@if (ArchiveId != Guid.Empty) {
|
||||
<SpaceItem>
|
||||
<Button OnClick="() => BrowseForFile()" Type="@ButtonType.Primary" Icon="@IconType.Outline.FolderOpen" Disabled="!ArchiveExists" />
|
||||
<Button OnClick="BrowseForFile" Type="@ButtonType.Primary" Icon="@IconType.Outline.FolderOpen" Disabled="!ArchiveExists" />
|
||||
</SpaceItem>
|
||||
}
|
||||
else if (!String.IsNullOrWhiteSpace(Root))
|
||||
{
|
||||
<SpaceItem>
|
||||
<Button OnClick="BrowseForFile" Type="@ButtonType.Primary" Icon="@IconType.Outline.FolderOpen" />
|
||||
</SpaceItem>
|
||||
}
|
||||
</Space>
|
||||
|
@ -19,9 +25,10 @@
|
|||
[Parameter] public string Value { get; set; }
|
||||
[Parameter] public EventCallback<string> ValueChanged { get; set; }
|
||||
[Parameter] public Guid ArchiveId { get; set; }
|
||||
[Parameter] public string ArchiveBrowserTitle { get; set; } = "Choose File";
|
||||
[Parameter] public string Title { get; set; } = "Choose File";
|
||||
[Parameter] public bool AllowDirectories { get; set; } = false;
|
||||
[Parameter] public string Prefix { get; set; }
|
||||
[Parameter] public string Root { get; set; }
|
||||
|
||||
bool ArchiveExists { get; set; } = false;
|
||||
|
||||
|
@ -35,28 +42,29 @@
|
|||
{
|
||||
var modalOptions = new ModalOptions()
|
||||
{
|
||||
Title = ArchiveBrowserTitle,
|
||||
Title = Title,
|
||||
Maximizable = false,
|
||||
DefaultMaximized = true,
|
||||
Closable = true,
|
||||
OkText = "Select File",
|
||||
WrapClassName = "archive-file-picker-dialog"
|
||||
WrapClassName = "file-picker-dialog"
|
||||
};
|
||||
|
||||
var browserOptions = new ArchiveFilePickerOptions()
|
||||
var browserOptions = new FilePickerOptions()
|
||||
{
|
||||
ArchiveId = ArchiveId,
|
||||
Root = Root,
|
||||
Select = true,
|
||||
Multiple = false,
|
||||
AllowDirectories = AllowDirectories
|
||||
};
|
||||
|
||||
var modalRef = await ModalService.CreateModalAsync<ArchiveFilePickerDialog, ArchiveFilePickerOptions, IEnumerable<IFileManagerEntry>>(modalOptions, browserOptions);
|
||||
var modalRef = await ModalService.CreateModalAsync<FilePickerDialog, FilePickerOptions, IEnumerable<IFileManagerEntry>>(modalOptions, browserOptions);
|
||||
|
||||
modalRef.OnOk = async (results) =>
|
||||
{
|
||||
if (!String.IsNullOrWhiteSpace(Prefix))
|
||||
Value = "{InstallDir}/" + results?.FirstOrDefault()?.Path;
|
||||
Value = Prefix + results?.FirstOrDefault()?.Path;
|
||||
else
|
||||
Value = results?.FirstOrDefault()?.Path;
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
@inherits FeedbackComponent<ArchiveFilePickerOptions, IEnumerable<IFileManagerEntry>>
|
||||
@inherits FeedbackComponent<FilePickerOptions, IEnumerable<IFileManagerEntry>>
|
||||
@using System.IO.Compression;
|
||||
@using LANCommander.Components.FileManagerComponents;
|
||||
@using LANCommander.Models;
|
||||
|
||||
<FileManager ArchiveId="Options.ArchiveId" @bind-Selected="SelectedFiles" EntryVisible="IsEntryVisible" SelectMultiple="Options.Multiple" Features="@(FileManagerFeatures.NavigationBack | FileManagerFeatures.NavigationForward | FileManagerFeatures.UpALevel | FileManagerFeatures.Breadcrumbs)" />
|
||||
<FileManager ArchiveId="@Options.ArchiveId" WorkingDirectory="@Options.Root" @bind-Selected="SelectedFiles" EntrySelectable="IsEntrySelectable" SelectMultiple="Options.Multiple" Features="@(FileManagerFeatures.NavigationBack | FileManagerFeatures.NavigationForward | FileManagerFeatures.UpALevel | FileManagerFeatures.Breadcrumbs)" />
|
||||
|
||||
@code {
|
||||
private IEnumerable<IFileManagerEntry> SelectedFiles { get; set; }
|
||||
|
@ -13,7 +13,7 @@
|
|||
await base.OkCancelRefWithResult!.OnOk(SelectedFiles);
|
||||
}
|
||||
|
||||
bool IsEntryVisible(IFileManagerEntry entry)
|
||||
bool IsEntrySelectable(IFileManagerEntry entry)
|
||||
{
|
||||
if (!Options.AllowDirectories && entry is FileManagerDirectory)
|
||||
return false;
|
|
@ -1,8 +1,9 @@
|
|||
namespace LANCommander.Models
|
||||
{
|
||||
public class ArchiveFilePickerOptions
|
||||
public class FilePickerOptions
|
||||
{
|
||||
public Guid ArchiveId { get; set; }
|
||||
public string Root { get; set; }
|
||||
public bool Select { get; set; }
|
||||
public bool Multiple { get; set; } = false;
|
||||
public bool AllowDirectories { get; set; } = false;
|
|
@ -12,7 +12,7 @@
|
|||
<Input Type="text" @bind-Value="context.Name" />
|
||||
</PropertyColumn>
|
||||
<PropertyColumn Property="a => a.Path">
|
||||
<ArchiveFilePicker @bind-Value="context.Path" ArchiveId="@ArchiveId" AllowDirectories="true" />
|
||||
<FilePicker @bind-Value="context.Path" ArchiveId="@ArchiveId" AllowDirectories="true" />
|
||||
</PropertyColumn>
|
||||
<PropertyColumn Property="a => a.Arguments">
|
||||
<Input Type="text" @bind-Value="context.Arguments" />
|
||||
|
@ -101,14 +101,14 @@
|
|||
OkText = "Select File"
|
||||
};
|
||||
|
||||
var browserOptions = new ArchiveFilePickerOptions()
|
||||
var browserOptions = new FilePickerOptions()
|
||||
{
|
||||
ArchiveId = ArchiveId,
|
||||
Select = true,
|
||||
Multiple = false
|
||||
};
|
||||
|
||||
var modalRef = await ModalService.CreateModalAsync<ArchiveFilePickerDialog, ArchiveFilePickerOptions, IEnumerable<IFileManagerEntry>>(modalOptions, browserOptions);
|
||||
var modalRef = await ModalService.CreateModalAsync<FilePickerDialog, FilePickerOptions, IEnumerable<IFileManagerEntry>>(modalOptions, browserOptions);
|
||||
|
||||
modalRef.OnOk = (results) =>
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
<ArchiveFilePicker @bind-Value="context.Path" ArchiveId="@ArchiveId" AllowDirectories="true" />
|
||||
<FilePicker @bind-Value="context.Path" ArchiveId="@ArchiveId" AllowDirectories="true" />
|
||||
}
|
||||
</PropertyColumn>
|
||||
<ActionColumn>
|
||||
|
|
|
@ -214,14 +214,14 @@
|
|||
OkText = "Insert File Path"
|
||||
};
|
||||
|
||||
var browserOptions = new ArchiveFilePickerOptions()
|
||||
var browserOptions = new FilePickerOptions()
|
||||
{
|
||||
ArchiveId = ArchiveId,
|
||||
Select = true,
|
||||
Multiple = false
|
||||
};
|
||||
|
||||
var modalRef = await ModalService.CreateModalAsync<ArchiveFilePickerDialog, ArchiveFilePickerOptions, IEnumerable<IFileManagerEntry>>(modalOptions, browserOptions);
|
||||
var modalRef = await ModalService.CreateModalAsync<FilePickerDialog, FilePickerOptions, IEnumerable<IFileManagerEntry>>(modalOptions, browserOptions);
|
||||
|
||||
modalRef.OnOk = (results) =>
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue