From 42c3b7ade9046fea8900aac94f170973d36a6090 Mon Sep 17 00:00:00 2001 From: NeoCoderMatrix86 <40752681+NeoCoderMatrix86@users.noreply.github.com> Date: Tue, 17 Sep 2024 14:01:44 +0200 Subject: [PATCH 1/2] removed redundant file upload fields --- .../Pages/ViewModeImport.razor | 107 +----------------- .../Localization/ViewModeImport/de.json | 6 - .../Localization/ViewModeImport/en.json | 6 - 3 files changed, 3 insertions(+), 116 deletions(-) diff --git a/AudioCuesheetEditor/Pages/ViewModeImport.razor b/AudioCuesheetEditor/Pages/ViewModeImport.razor index 6318091d..38f1a640 100644 --- a/AudioCuesheetEditor/Pages/ViewModeImport.razor +++ b/AudioCuesheetEditor/Pages/ViewModeImport.razor @@ -41,7 +41,7 @@ along with Foobar. If not, see - @((MarkupString)(_localizer["Choose file or drag it here"].ToString())) + @((MarkupString)(_localizer["Choose file or drag it here"])) @foreach (var invalidFileName in invalidDropFileNames) { @@ -51,55 +51,6 @@ along with Foobar. If not, see } - - - - @_localizer["Textfile"] - - - - - - @foreach (var invalidFileName in invalidTextImportFileNames) - { - - @_localizer["Invalid file"] - @String.Format(_localizer["You dropped an invalid file ({0}) that can not be processed."], invalidFileName) - - - } - - - @_localizer["Cuesheet"] - - - - - - @foreach (var invalidFileName in invalidCuesheetfileNames) - { - - @_localizer["Invalid file"] - @String.Format(_localizer["You dropped an invalid file ({0}) that can not be processed."], invalidFileName) - - - } - - - @_localizer["Project filename"] - - - - - - @foreach (var invalidFileName in invalidProjectfileNames) - { - - @_localizer["Invalid file"] - @String.Format(_localizer["You dropped an invalid file ({0}) that can not be processed."], invalidFileName) - - - } @@ -247,6 +198,7 @@ along with Foobar. If not, see selectedStep = name; break; case "validateData": + //TODO: File validation should be done seperatly if ((_sessionStateContainer.ImportCuesheet != null) || (_sessionStateContainer.Importfile != null)) { selectFilesCompleted = true; @@ -267,6 +219,7 @@ along with Foobar. If not, see } } + //TODO: Shouldn't edit the selected step String SelectedStep { get @@ -280,60 +233,6 @@ along with Foobar. If not, see } } - private async Task OnTextImportFileChanged(FileChangedEventArgs e) - { - invalidTextImportFileNames.Clear(); - if (e.Files.FirstOrDefault() != null) - { - var file = e.Files.First(); - if (IOUtility.CheckFileMimeType(file, FileMimeTypes.Text, FileExtensions.Text) == false) - { - invalidTextImportFileNames.Add(file.Name); - } - else - { - await OnFileChanged(new List() { file }); - } - StateHasChanged(); - } - } - - private async Task OnCuesheetfileChanged(FileChangedEventArgs e) - { - invalidCuesheetfileNames.Clear(); - if (e.Files.FirstOrDefault() != null) - { - var file = e.Files.First(); - if (IOUtility.CheckFileMimeType(file, FileMimeTypes.Cuesheet, FileExtensions.Cuesheet) == false) - { - invalidCuesheetfileNames.Add(file.Name); - } - else - { - await OnFileChanged(new List() { file }); - } - StateHasChanged(); - } - } - - private async Task OnProjectfileChanged(FileChangedEventArgs e) - { - invalidProjectfileNames.Clear(); - if (e.Files.FirstOrDefault() != null) - { - var file = e.Files.First(); - if (IOUtility.CheckFileMimeType(file, FileMimeTypes.Projectfile, FileExtensions.Projectfile) == false) - { - invalidProjectfileNames.Add(file.Name); - } - else - { - await OnFileChanged(new List() { file }); - } - StateHasChanged(); - } - } - private async Task OnDropFileChanged(FileChangedEventArgs e) { invalidDropFileNames.Clear(); diff --git a/AudioCuesheetEditor/Resources/Localization/ViewModeImport/de.json b/AudioCuesheetEditor/Resources/Localization/ViewModeImport/de.json index 4d8539a4..1a863c80 100644 --- a/AudioCuesheetEditor/Resources/Localization/ViewModeImport/de.json +++ b/AudioCuesheetEditor/Resources/Localization/ViewModeImport/de.json @@ -7,12 +7,6 @@ "Choose file or drag it here": "Wählen Sie die Dateien oder ziehen Sie diese hier her", "Invalid file": "Ungültige Datei", "You dropped an invalid file ({0}) that can not be processed.": "Sie haben eine ungültige Datei ({0}) selektiert, die nicht verarbeitet werden kann.", - "Import textfile tooltip": "Textdatei importieren und Daten über reguläre Ausdrücke extrahieren", - "Textfile": "Textdatei", - "Import cuesheet tooltip": "Importieren Sie ein Cuesheet und extrahieren Sie alle Daten daraus", - "Cuesheet": "Cuesheet", - "Import project tooltip": "Ein gespeichertes Projekt importieren", - "Project filename": "Projektdatei", "Validate data for import": "Daten für den Import validieren", "Recognition of import data finished": "Analyse der Importdateien abgeschlossen", "Please validate the following data recognized by import assistant. Once you have validated all input, you can confirm import of data.": "Bitte validieren sie die analysierten und angezeigten Dateien. Anschließend können Sie die Daten bestätigen und den Import durchführen.", diff --git a/AudioCuesheetEditor/Resources/Localization/ViewModeImport/en.json b/AudioCuesheetEditor/Resources/Localization/ViewModeImport/en.json index 960cb5a1..6cc78fc4 100644 --- a/AudioCuesheetEditor/Resources/Localization/ViewModeImport/en.json +++ b/AudioCuesheetEditor/Resources/Localization/ViewModeImport/en.json @@ -7,12 +7,6 @@ "Choose file or drag it here": "Choose files or drag them here", "Invalid file": "Invalid file", "You dropped an invalid file ({0}) that can not be processed.": "You dropped an invalid file ({0}) that can not be processed.", - "Import textfile tooltip": "Import a plain text file and extract data via regular expressions", - "Textfile": "Textfile", - "Import cuesheet tooltip": "Import a cuesheet file and extract all data from it", - "Cuesheet": "Cuesheet", - "Import project tooltip": "Import a saved project", - "Project filename": "Project filename", "Validate data for import": "Validate data for import", "Recognition of import data finished": "Recognition of import data finished", "Please validate the following data recognized by import assistant. Once you have validated all input, you can confirm import of data.": "Please validate the following data recognized by import assistant. Once you have validated all input, you can confirm import of data.", From 4d2efc3e4eae9b0e4d415662cac44175616485ca Mon Sep 17 00:00:00 2001 From: NeoCoderMatrix86 <40752681+NeoCoderMatrix86@users.noreply.github.com> Date: Tue, 17 Sep 2024 14:41:04 +0200 Subject: [PATCH 2/2] fixed record view selected step --- .../Pages/ViewModeImport.razor | 59 ++++--------------- .../Localization/ViewModeImport/de.json | 2 - .../Localization/ViewModeImport/en.json | 2 - 3 files changed, 11 insertions(+), 52 deletions(-) diff --git a/AudioCuesheetEditor/Pages/ViewModeImport.razor b/AudioCuesheetEditor/Pages/ViewModeImport.razor index 38f1a640..05cf22ba 100644 --- a/AudioCuesheetEditor/Pages/ViewModeImport.razor +++ b/AudioCuesheetEditor/Pages/ViewModeImport.razor @@ -28,9 +28,9 @@ along with Foobar. If not, see @inject ImportManager _importManager - + - @_localizer["Select files"] + @_localizer["Select files"] @_localizer["Validate"] @@ -156,16 +156,11 @@ along with Foobar. If not, see Boolean cuesheetSplitPointsVisible = true; Boolean importFileContentVisible = true; Boolean importOptionsVisible = true; - Boolean selectFilesCompleted = false; - Boolean userChangedSelectedStep = false; Boolean displaySplitPoints = false; Boolean displayFileContent = true; Boolean displayEditImportOptions = true; Alert? alertInvalidFile; ModalDialog? modalDialog; - List invalidTextImportFileNames = new(); - List invalidCuesheetfileNames = new(); - List invalidProjectfileNames = new(); List invalidDropFileNames = new(); HotKeysContext? hotKeysContext; @@ -189,48 +184,16 @@ along with Foobar. If not, see .Add(Key.Enter, OnEnterKeyDown); } - async Task OnSelectedStepChanged(String name) - { - userChangedSelectedStep = true; - switch (name) - { - case "selectFiles": - selectedStep = name; - break; - case "validateData": - //TODO: File validation should be done seperatly - if ((_sessionStateContainer.ImportCuesheet != null) || (_sessionStateContainer.Importfile != null)) - { - selectFilesCompleted = true; - selectedStep = name; - } - else - { - if (modalDialog != null) - { - modalDialog.Title = _localizer["Not possible!"]; - modalDialog.Text = _localizer["Please select files for import before going to validation!"]; - modalDialog.ModalSize = ModalSize.Small; - modalDialog.Mode = ModalDialog.DialogMode.Alert; - await modalDialog.ShowModal(); - } - } - break; - } - } + Boolean SelectFilesCompleted => (_sessionStateContainer.ImportCuesheet != null) || (_sessionStateContainer.Importfile != null); - //TODO: Shouldn't edit the selected step - String SelectedStep + bool NavigationAllowed(StepNavigationContext context) { - get + if (context.CurrentStepName == "selectFiles" && context.NextStepName == "validateData") { - if ((userChangedSelectedStep == false) && ((_sessionStateContainer.ImportCuesheet != null) || (_sessionStateContainer.Importfile != null))) - { - selectFilesCompleted = true; - selectedStep = "validateData"; - } - return selectedStep; + return SelectFilesCompleted; } + + return true; } private async Task OnDropFileChanged(FileChangedEventArgs e) @@ -273,7 +236,7 @@ along with Foobar. If not, see displaySplitPoints = importedFiles.ContainsValue(ImportFileType.ProjectFile); displayFileContent = importedFiles.ContainsValue(ImportFileType.Textfile); displayEditImportOptions = importedFiles.ContainsValue(ImportFileType.Textfile); - await OnSelectedStepChanged("validateData"); + selectedStep = "validateData"; StateHasChanged(); } @@ -304,10 +267,10 @@ along with Foobar. If not, see StateHasChanged(); } - async Task AbortImport() + void AbortImport() { _sessionStateContainer.ResetImport(); - await OnSelectedStepChanged("selectFiles"); + selectedStep = "selectFiles"; } private void LocalizationService_LocalizationChanged(object? sender, EventArgs args) diff --git a/AudioCuesheetEditor/Resources/Localization/ViewModeImport/de.json b/AudioCuesheetEditor/Resources/Localization/ViewModeImport/de.json index 1a863c80..6fadba0f 100644 --- a/AudioCuesheetEditor/Resources/Localization/ViewModeImport/de.json +++ b/AudioCuesheetEditor/Resources/Localization/ViewModeImport/de.json @@ -36,8 +36,6 @@ "Begin": "Beginn", "End": "Ende", "Length": "Länge", - "Not possible!": "Ungültig!", - "Please select files for import before going to validation!": "Bitte selektieren Sie Dateien bevor Sie zur Validierung wechseln!", "Textimportscheme cuesheet": "Import Schema Cuesheet", "Textimportscheme track": "Import Schema Titel", "Import Options": "Importoptionen", diff --git a/AudioCuesheetEditor/Resources/Localization/ViewModeImport/en.json b/AudioCuesheetEditor/Resources/Localization/ViewModeImport/en.json index 6cc78fc4..be324ec3 100644 --- a/AudioCuesheetEditor/Resources/Localization/ViewModeImport/en.json +++ b/AudioCuesheetEditor/Resources/Localization/ViewModeImport/en.json @@ -35,8 +35,6 @@ "Begin": "Begin", "End": "End", "Length": "Length", - "Not possible!": "Not possible!", - "Please select files for import before going to validation!": "Please select files for import before going to validation!", "Textimportscheme cuesheet": "Textimport scheme cuesheet", "Textimportscheme track": "Textimport scheme track", "Import Options": "Import options",