diff --git a/LANCommander/Components/ArchiveBrowserDialog.razor b/LANCommander/Components/ArchiveBrowserDialog.razor deleted file mode 100644 index 79b270b..0000000 --- a/LANCommander/Components/ArchiveBrowserDialog.razor +++ /dev/null @@ -1,14 +0,0 @@ -@inherits FeedbackComponent> -@using System.IO.Compression; -@using LANCommander.Models; - - - -@code { - private IEnumerable SelectedFiles { get; set; } - - public override async Task OnFeedbackOkAsync(ModalClosingEventArgs args) - { - await base.OkCancelRefWithResult!.OnOk(SelectedFiles); - } -} diff --git a/LANCommander/Components/InputArchiveFile.razor b/LANCommander/Components/ArchiveFilePicker.razor similarity index 69% rename from LANCommander/Components/InputArchiveFile.razor rename to LANCommander/Components/ArchiveFilePicker.razor index 8e19a4e..68a5f26 100644 --- a/LANCommander/Components/InputArchiveFile.razor +++ b/LANCommander/Components/ArchiveFilePicker.razor @@ -1,4 +1,5 @@ -@using LANCommander.Models; +@using LANCommander.Components.FileManagerComponents; +@using LANCommander.Models; @using System.IO.Compression; @inject ModalService ModalService @inject ArchiveService ArchiveService @@ -20,6 +21,7 @@ [Parameter] public Guid ArchiveId { get; set; } [Parameter] public string ArchiveBrowserTitle { get; set; } = "Choose File"; [Parameter] public bool AllowDirectories { get; set; } = false; + [Parameter] public string Prefix { get; set; } bool ArchiveExists { get; set; } = false; @@ -32,15 +34,16 @@ private async void BrowseForFile() { var modalOptions = new ModalOptions() - { - Title = ArchiveBrowserTitle, - Maximizable = false, - DefaultMaximized = true, - Closable = true, - OkText = "Select File" - }; + { + Title = ArchiveBrowserTitle, + Maximizable = false, + DefaultMaximized = true, + Closable = true, + OkText = "Select File", + WrapClassName = "archive-file-picker-dialog" + }; - var browserOptions = new ArchiveBrowserOptions() + var browserOptions = new ArchiveFilePickerOptions() { ArchiveId = ArchiveId, Select = true, @@ -48,11 +51,12 @@ AllowDirectories = AllowDirectories }; - var modalRef = await ModalService.CreateModalAsync>(modalOptions, browserOptions); + var modalRef = await ModalService.CreateModalAsync>(modalOptions, browserOptions); modalRef.OnOk = async (results) => { - Value = "{InstallDir}/" + results.FirstOrDefault().FullName; + if (!String.IsNullOrWhiteSpace(Prefix)) + Value = "{InstallDir}/" + results.FirstOrDefault().Path; if (ValueChanged.HasDelegate) await ValueChanged.InvokeAsync(Value); diff --git a/LANCommander/Components/ArchiveFilePickerDialog.razor b/LANCommander/Components/ArchiveFilePickerDialog.razor new file mode 100644 index 0000000..19061e9 --- /dev/null +++ b/LANCommander/Components/ArchiveFilePickerDialog.razor @@ -0,0 +1,23 @@ +@inherits FeedbackComponent> +@using System.IO.Compression; +@using LANCommander.Components.FileManagerComponents; +@using LANCommander.Models; + + + +@code { + private IEnumerable SelectedFiles { get; set; } + + public override async Task OnFeedbackOkAsync(ModalClosingEventArgs args) + { + await base.OkCancelRefWithResult!.OnOk(SelectedFiles); + } + + bool IsEntryVisible(IFileManagerEntry entry) + { + if (!Options.AllowDirectories && entry is FileManagerDirectory) + return false; + else + return true; + } +} diff --git a/LANCommander/Models/ArchiveBrowserOptions.cs b/LANCommander/Models/ArchiveFilePickerOptions.cs similarity index 85% rename from LANCommander/Models/ArchiveBrowserOptions.cs rename to LANCommander/Models/ArchiveFilePickerOptions.cs index 980e269..f014eff 100644 --- a/LANCommander/Models/ArchiveBrowserOptions.cs +++ b/LANCommander/Models/ArchiveFilePickerOptions.cs @@ -1,6 +1,6 @@ namespace LANCommander.Models { - public class ArchiveBrowserOptions + public class ArchiveFilePickerOptions { public Guid ArchiveId { get; set; } public bool Select { get; set; } diff --git a/LANCommander/Pages/Games/Components/ActionEditor.razor b/LANCommander/Pages/Games/Components/ActionEditor.razor index 1412222..1bf1144 100644 --- a/LANCommander/Pages/Games/Components/ActionEditor.razor +++ b/LANCommander/Pages/Games/Components/ActionEditor.razor @@ -1,4 +1,5 @@ -@using LANCommander.Data.Models +@using LANCommander.Components.FileManagerComponents; +@using LANCommander.Data.Models @using LANCommander.Extensions @using LANCommander.Models; @using System.IO.Compression; @@ -11,7 +12,7 @@ - + @@ -100,18 +101,18 @@ OkText = "Select File" }; - var browserOptions = new ArchiveBrowserOptions() + var browserOptions = new ArchiveFilePickerOptions() { ArchiveId = ArchiveId, Select = true, Multiple = false }; - var modalRef = await ModalService.CreateModalAsync>(modalOptions, browserOptions); + var modalRef = await ModalService.CreateModalAsync>(modalOptions, browserOptions); modalRef.OnOk = (results) => { - action.Path = results.FirstOrDefault().FullName; + action.Path = results.FirstOrDefault().Path; var parts = action.Path.Split('/'); diff --git a/LANCommander/Pages/Games/Components/SavePathEditor.razor b/LANCommander/Pages/Games/Components/SavePathEditor.razor index 9a4e1a1..27f0a72 100644 --- a/LANCommander/Pages/Games/Components/SavePathEditor.razor +++ b/LANCommander/Pages/Games/Components/SavePathEditor.razor @@ -14,7 +14,7 @@ } else { - + } diff --git a/LANCommander/Pages/Games/Components/ScriptEditor.razor b/LANCommander/Pages/Games/Components/ScriptEditor.razor index d59c01a..96dede6 100644 --- a/LANCommander/Pages/Games/Components/ScriptEditor.razor +++ b/LANCommander/Pages/Games/Components/ScriptEditor.razor @@ -1,4 +1,5 @@ -@using LANCommander.Data.Enums; +@using LANCommander.Components.FileManagerComponents; +@using LANCommander.Data.Enums; @using LANCommander.Extensions; @using LANCommander.Models @using LANCommander.Services @@ -213,18 +214,18 @@ OkText = "Insert File Path" }; - var browserOptions = new ArchiveBrowserOptions() + var browserOptions = new ArchiveFilePickerOptions() { ArchiveId = ArchiveId, Select = true, Multiple = false }; - var modalRef = await ModalService.CreateModalAsync>(modalOptions, browserOptions); + var modalRef = await ModalService.CreateModalAsync>(modalOptions, browserOptions); modalRef.OnOk = (results) => { - var path = results.FirstOrDefault().FullName; + var path = results.FirstOrDefault().Path; Editor.Trigger("keyboard", "type", new { diff --git a/LANCommander/Pages/Games/Edit.razor b/LANCommander/Pages/Games/Edit.razor index a12414c..1e59d1c 100644 --- a/LANCommander/Pages/Games/Edit.razor +++ b/LANCommander/Pages/Games/Edit.razor @@ -1,6 +1,7 @@ @page "/Games/{id:guid}" @page "/Games/{id:guid}/{panel}" @page "/Games/Add" +@using LANCommander.Components.FileManagerComponents; @using LANCommander.Models; @using LANCommander.Pages.Games.Components @using System.IO.Compression; @@ -70,7 +71,7 @@ - +