Skip to content

Commit 86e557e

Browse files
Merge pull request #388 from NeoCoderMatrix86/386-invalid-file-alert-is-not-cleared
Invalid file alert is not cleared
2 parents 875f524 + 4d2efc3 commit 86e557e

3 files changed

Lines changed: 11 additions & 165 deletions

File tree

AudioCuesheetEditor/Pages/ViewModeImport.razor

Lines changed: 11 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ along with Foobar. If not, see
2828
@inject ImportManager _importManager
2929

3030
<Validations @ref="validations">
31-
<Steps SelectedStep="@SelectedStep" SelectedStepChanged="@OnSelectedStepChanged">
31+
<Steps @bind-SelectedStep="selectedStep" NavigationAllowed="NavigationAllowed">
3232
<Items>
33-
<Step Name="selectFiles" Completed="selectFilesCompleted">@_localizer["Select files"]</Step>
33+
<Step Name="selectFiles" Completed="SelectFilesCompleted">@_localizer["Select files"]</Step>
3434
<Step Name="validateData">@_localizer["Validate"]</Step>
3535
</Items>
3636
<Content>
@@ -41,7 +41,7 @@ along with Foobar. If not, see
4141
<Field class="dragNDropFile mb-3" ondragover="dragOver(event, this)" ondragleave="dragLeave(event, this)" ondrop="dropFiles(event, this, 'dropFileInput')">
4242
<svg class="dragNDropFileIcon" xmlns="http://www.w3.org/2000/svg" width="50" height="43" viewBox="0 0 50 43"><path d="M48.4 26.5c-.9 0-1.7.7-1.7 1.7v11.6h-43.3v-11.6c0-.9-.7-1.7-1.7-1.7s-1.7.7-1.7 1.7v13.2c0 .9.7 1.7 1.7 1.7h46.7c.9 0 1.7-.7 1.7-1.7v-13.2c0-1-.7-1.7-1.7-1.7zm-24.5 6.1c.3.3.8.5 1.2.5.4 0 .9-.2 1.2-.5l10-11.6c.7-.7.7-1.7 0-2.4s-1.7-.7-2.4 0l-7.1 8.3v-25.3c0-.9-.7-1.7-1.7-1.7s-1.7.7-1.7 1.7v25.3l-7.1-8.3c-.7-.7-1.7-.7-2.4 0s-.7 1.7 0 2.4l10 11.6z"></path></svg>
4343
<FileEdit id="dropFileInput" Multiple Filter="@dragNDropUploadFilter" Changed="OnDropFileChanged" AutoReset="false"></FileEdit>
44-
<FieldLabel for="dropFileInput">@((MarkupString)(_localizer["Choose file or drag it here"].ToString()))</FieldLabel>
44+
<FieldLabel for="dropFileInput">@((MarkupString)(_localizer["Choose file or drag it here"]))</FieldLabel>
4545
</Field>
4646
@foreach (var invalidFileName in invalidDropFileNames)
4747
{
@@ -51,55 +51,6 @@ along with Foobar. If not, see
5151
<CloseButton />
5252
</Alert>
5353
}
54-
<Divider />
55-
<Tooltip Placement="TooltipPlacement.Top" Text="@_localizer["Import textfile tooltip"]">
56-
<Field Horizontal="true">
57-
<FieldLabel ColumnSize="ColumnSize.Is2.OnFullHD.Is3.OnDesktop.Is4.OnTablet.Is5.OnMobile">@_localizer["Textfile"]</FieldLabel>
58-
<FieldBody ColumnSize="ColumnSize.Is10.OnFullHD.Is9.OnDesktop.Is8.OnTablet.Is12.OnMobile">
59-
<FileEdit Filter="@FileMimeTypes.Text" Changed="OnTextImportFileChanged" AutoReset="false"></FileEdit>
60-
</FieldBody>
61-
</Field>
62-
</Tooltip>
63-
@foreach (var invalidFileName in invalidTextImportFileNames)
64-
{
65-
<Alert @ref="alertInvalidFile" Color="Color.Danger" Visible Dismisable>
66-
<AlertMessage>@_localizer["Invalid file"]</AlertMessage>
67-
<AlertDescription>@String.Format(_localizer["You dropped an invalid file ({0}) that can not be processed."], invalidFileName)</AlertDescription>
68-
<CloseButton />
69-
</Alert>
70-
}
71-
<Tooltip Placement="TooltipPlacement.Top" Text="@_localizer["Import cuesheet tooltip"]">
72-
<Field Horizontal="true">
73-
<FieldLabel ColumnSize="ColumnSize.Is2.OnFullHD.Is3.OnDesktop.Is4.OnTablet.Is5.OnMobile">@_localizer["Cuesheet"]</FieldLabel>
74-
<FieldBody ColumnSize="ColumnSize.Is10.OnFullHD.Is9.OnDesktop.Is8.OnTablet.Is12.OnMobile">
75-
<FileEdit Filter="@FileExtensions.Cuesheet" Changed="OnCuesheetfileChanged" AutoReset="false"></FileEdit>
76-
</FieldBody>
77-
</Field>
78-
</Tooltip>
79-
@foreach (var invalidFileName in invalidCuesheetfileNames)
80-
{
81-
<Alert @ref="alertInvalidFile" Color="Color.Danger" Visible Dismisable>
82-
<AlertMessage>@_localizer["Invalid file"]</AlertMessage>
83-
<AlertDescription>@String.Format(_localizer["You dropped an invalid file ({0}) that can not be processed."], invalidFileName)</AlertDescription>
84-
<CloseButton />
85-
</Alert>
86-
}
87-
<Tooltip Placement="TooltipPlacement.Top" Text="@_localizer["Import project tooltip"]">
88-
<Field Horizontal="true">
89-
<FieldLabel ColumnSize="ColumnSize.Is2.OnFullHD.Is3.OnDesktop.Is4.OnTablet.Is5.OnMobile">@_localizer["Project filename"]</FieldLabel>
90-
<FieldBody ColumnSize="ColumnSize.Is10.OnFullHD.Is9.OnDesktop.Is8.OnTablet.Is12.OnMobile">
91-
<FileEdit Filter="@FileExtensions.Projectfile" Changed="OnProjectfileChanged" AutoReset="false"></FileEdit>
92-
</FieldBody>
93-
</Field>
94-
</Tooltip>
95-
@foreach (var invalidFileName in invalidProjectfileNames)
96-
{
97-
<Alert @ref="alertInvalidFile" Color="Color.Danger" Visible Dismisable>
98-
<AlertMessage>@_localizer["Invalid file"]</AlertMessage>
99-
<AlertDescription>@String.Format(_localizer["You dropped an invalid file ({0}) that can not be processed."], invalidFileName)</AlertDescription>
100-
<CloseButton />
101-
</Alert>
102-
}
10354
</CardBody>
10455
</Card>
10556
</StepPanel>
@@ -205,16 +156,11 @@ along with Foobar. If not, see
205156
Boolean cuesheetSplitPointsVisible = true;
206157
Boolean importFileContentVisible = true;
207158
Boolean importOptionsVisible = true;
208-
Boolean selectFilesCompleted = false;
209-
Boolean userChangedSelectedStep = false;
210159
Boolean displaySplitPoints = false;
211160
Boolean displayFileContent = true;
212161
Boolean displayEditImportOptions = true;
213162
Alert? alertInvalidFile;
214163
ModalDialog? modalDialog;
215-
List<String> invalidTextImportFileNames = new();
216-
List<String> invalidCuesheetfileNames = new();
217-
List<String> invalidProjectfileNames = new();
218164
List<String> invalidDropFileNames = new();
219165

220166
HotKeysContext? hotKeysContext;
@@ -238,100 +184,16 @@ along with Foobar. If not, see
238184
.Add(Key.Enter, OnEnterKeyDown);
239185
}
240186

241-
async Task OnSelectedStepChanged(String name)
242-
{
243-
userChangedSelectedStep = true;
244-
switch (name)
245-
{
246-
case "selectFiles":
247-
selectedStep = name;
248-
break;
249-
case "validateData":
250-
if ((_sessionStateContainer.ImportCuesheet != null) || (_sessionStateContainer.Importfile != null))
251-
{
252-
selectFilesCompleted = true;
253-
selectedStep = name;
254-
}
255-
else
256-
{
257-
if (modalDialog != null)
258-
{
259-
modalDialog.Title = _localizer["Not possible!"];
260-
modalDialog.Text = _localizer["Please select files for import before going to validation!"];
261-
modalDialog.ModalSize = ModalSize.Small;
262-
modalDialog.Mode = ModalDialog.DialogMode.Alert;
263-
await modalDialog.ShowModal();
264-
}
265-
}
266-
break;
267-
}
268-
}
187+
Boolean SelectFilesCompleted => (_sessionStateContainer.ImportCuesheet != null) || (_sessionStateContainer.Importfile != null);
269188

270-
String SelectedStep
189+
bool NavigationAllowed(StepNavigationContext context)
271190
{
272-
get
191+
if (context.CurrentStepName == "selectFiles" && context.NextStepName == "validateData")
273192
{
274-
if ((userChangedSelectedStep == false) && ((_sessionStateContainer.ImportCuesheet != null) || (_sessionStateContainer.Importfile != null)))
275-
{
276-
selectFilesCompleted = true;
277-
selectedStep = "validateData";
278-
}
279-
return selectedStep;
193+
return SelectFilesCompleted;
280194
}
281-
}
282-
283-
private async Task OnTextImportFileChanged(FileChangedEventArgs e)
284-
{
285-
invalidTextImportFileNames.Clear();
286-
if (e.Files.FirstOrDefault() != null)
287-
{
288-
var file = e.Files.First();
289-
if (IOUtility.CheckFileMimeType(file, FileMimeTypes.Text, FileExtensions.Text) == false)
290-
{
291-
invalidTextImportFileNames.Add(file.Name);
292-
}
293-
else
294-
{
295-
await OnFileChanged(new List<IFileEntry>() { file });
296-
}
297-
StateHasChanged();
298-
}
299-
}
300-
301-
private async Task OnCuesheetfileChanged(FileChangedEventArgs e)
302-
{
303-
invalidCuesheetfileNames.Clear();
304-
if (e.Files.FirstOrDefault() != null)
305-
{
306-
var file = e.Files.First();
307-
if (IOUtility.CheckFileMimeType(file, FileMimeTypes.Cuesheet, FileExtensions.Cuesheet) == false)
308-
{
309-
invalidCuesheetfileNames.Add(file.Name);
310-
}
311-
else
312-
{
313-
await OnFileChanged(new List<IFileEntry>() { file });
314-
}
315-
StateHasChanged();
316-
}
317-
}
318195

319-
private async Task OnProjectfileChanged(FileChangedEventArgs e)
320-
{
321-
invalidProjectfileNames.Clear();
322-
if (e.Files.FirstOrDefault() != null)
323-
{
324-
var file = e.Files.First();
325-
if (IOUtility.CheckFileMimeType(file, FileMimeTypes.Projectfile, FileExtensions.Projectfile) == false)
326-
{
327-
invalidProjectfileNames.Add(file.Name);
328-
}
329-
else
330-
{
331-
await OnFileChanged(new List<IFileEntry>() { file });
332-
}
333-
StateHasChanged();
334-
}
196+
return true;
335197
}
336198

337199
private async Task OnDropFileChanged(FileChangedEventArgs e)
@@ -374,7 +236,7 @@ along with Foobar. If not, see
374236
displaySplitPoints = importedFiles.ContainsValue(ImportFileType.ProjectFile);
375237
displayFileContent = importedFiles.ContainsValue(ImportFileType.Textfile);
376238
displayEditImportOptions = importedFiles.ContainsValue(ImportFileType.Textfile);
377-
await OnSelectedStepChanged("validateData");
239+
selectedStep = "validateData";
378240
StateHasChanged();
379241
}
380242

@@ -405,10 +267,10 @@ along with Foobar. If not, see
405267
StateHasChanged();
406268
}
407269

408-
async Task AbortImport()
270+
void AbortImport()
409271
{
410272
_sessionStateContainer.ResetImport();
411-
await OnSelectedStepChanged("selectFiles");
273+
selectedStep = "selectFiles";
412274
}
413275

414276
private void LocalizationService_LocalizationChanged(object? sender, EventArgs args)

AudioCuesheetEditor/Resources/Localization/ViewModeImport/de.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
"Choose file or drag it here": "<strong>Wählen Sie die Dateien</strong><span> oder ziehen Sie diese hier her</span>",
88
"Invalid file": "Ungültige Datei",
99
"You dropped an invalid file ({0}) that can not be processed.": "Sie haben eine ungültige Datei ({0}) selektiert, die nicht verarbeitet werden kann.",
10-
"Import textfile tooltip": "Textdatei importieren und Daten über reguläre Ausdrücke extrahieren",
11-
"Textfile": "Textdatei",
12-
"Import cuesheet tooltip": "Importieren Sie ein Cuesheet und extrahieren Sie alle Daten daraus",
13-
"Cuesheet": "Cuesheet",
14-
"Import project tooltip": "Ein gespeichertes Projekt importieren",
15-
"Project filename": "Projektdatei",
1610
"Validate data for import": "Daten für den Import validieren",
1711
"Recognition of import data finished": "Analyse der Importdateien abgeschlossen",
1812
"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.",
@@ -42,8 +36,6 @@
4236
"Begin": "Beginn",
4337
"End": "Ende",
4438
"Length": "Länge",
45-
"Not possible!": "Ungültig!",
46-
"Please select files for import before going to validation!": "Bitte selektieren Sie Dateien bevor Sie zur Validierung wechseln!",
4739
"Textimportscheme cuesheet": "Import Schema Cuesheet",
4840
"Textimportscheme track": "Import Schema Titel",
4941
"Import Options": "Importoptionen",

AudioCuesheetEditor/Resources/Localization/ViewModeImport/en.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
"Choose file or drag it here": "<strong>Choose files</strong><span> or drag them here</span>",
88
"Invalid file": "Invalid file",
99
"You dropped an invalid file ({0}) that can not be processed.": "You dropped an invalid file ({0}) that can not be processed.",
10-
"Import textfile tooltip": "Import a plain text file and extract data via regular expressions",
11-
"Textfile": "Textfile",
12-
"Import cuesheet tooltip": "Import a cuesheet file and extract all data from it",
13-
"Cuesheet": "Cuesheet",
14-
"Import project tooltip": "Import a saved project",
15-
"Project filename": "Project filename",
1610
"Validate data for import": "Validate data for import",
1711
"Recognition of import data finished": "Recognition of import data finished",
1812
"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.",
@@ -41,8 +35,6 @@
4135
"Begin": "Begin",
4236
"End": "End",
4337
"Length": "Length",
44-
"Not possible!": "Not possible!",
45-
"Please select files for import before going to validation!": "Please select files for import before going to validation!",
4638
"Textimportscheme cuesheet": "Textimport scheme cuesheet",
4739
"Textimportscheme track": "Textimport scheme track",
4840
"Import Options": "Import options",

0 commit comments

Comments
 (0)