Skip to content

Commit

Permalink
Reset active step for modal export
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoCoderMatrix86 committed Apr 3, 2024
1 parent cfd2e65 commit 4ae9030
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 58 deletions.
48 changes: 12 additions & 36 deletions AudioCuesheetEditor/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ along with Foobar. If not, see
<Field Horizontal="true">
<FieldLabel ColumnSize="ColumnSize.Is3">@_localizer["Filename"]</FieldLabel>
<FieldBody ColumnSize="ColumnSize.Is9">
<TextEdit Text="@applicationOptions.CuesheetFilename" Immediate="false" Disabled="ModalExportdialogCuesheetLockUserInput" TextChanged="OnApplicationOptionsCuesheetFilenameChanged">
<TextEdit Text="@applicationOptions.CuesheetFilename" Immediate="false" TextChanged="OnApplicationOptionsCuesheetFilenameChanged">
<Feedback>
<ValidationError />
</Feedback>
Expand All @@ -237,19 +237,19 @@ along with Foobar. If not, see
<Field Horizontal="true" JustifyContent="JustifyContent.End">
<FieldLabel ColumnSize="ColumnSize.Is3">@_localizer["Select exportprofile"]</FieldLabel>
<FieldBody ColumnSize="ColumnSize.Is9">
<SelectList TItem="SelectExportProfileModel" TValue="Guid?" Data="@exportProfileModels" TextField="@((item)=>item.ExportProfile.Name)" ValueField="@((item)=>item.Id)" SelectedValue="selectedExportProfileId" SelectedValueChanged="SelectedExportProfileChanged" Disabled="ModalExportdialogExportprofileLockUserInput" />
<SelectList TItem="SelectExportProfileModel" TValue="Guid?" Data="@exportProfileModels" TextField="@((item)=>item.ExportProfile.Name)" ValueField="@((item)=>item.Id)" SelectedValue="selectedExportProfileId" SelectedValueChanged="SelectedExportProfileChanged" />
</FieldBody>
</Field>
<Button Color="Color.Primary" Clicked="OnAddNewExportProfileClicked" Disabled="ModalExportdialogExportprofileLockUserInput">@_localizer["Add new exportprofile"]</Button>
<Button Color="Color.Danger" Clicked="OnDeleteExportProfileClicked" Disabled="ModalExportdialogExportprofileLockUserInput">@_localizer["Delete selected exportprofile"]</Button>
<Button Color="Color.Primary" Clicked="OnAddNewExportProfileClicked">@_localizer["Add new exportprofile"]</Button>
<Button Color="Color.Danger" Clicked="OnDeleteExportProfileClicked">@_localizer["Delete selected exportprofile"]</Button>
<Divider />
@if (SelectedExportProfile != null)
{
<Validation AsyncValidator="(args, token) => ValidatorUtility<Exportprofile>.Validate(args, SelectedExportProfile, x => x.Name, _validationMessageLocalizer, token)">
<Field Horizontal="true">
<FieldLabel ColumnSize="ColumnSize.Is3">@_localizer["Name"]</FieldLabel>
<FieldBody ColumnSize="ColumnSize.Is9">
<TextEdit Placeholder="@_localizer["Enter exportprofile name here"]" @bind-Text="SelectedExportProfile.Name" Disabled="ModalExportdialogExportprofileLockUserInput">
<TextEdit Placeholder="@_localizer["Enter exportprofile name here"]" @bind-Text="SelectedExportProfile.Name">
<Feedback>
<ValidationError />
</Feedback>
Expand All @@ -261,7 +261,7 @@ along with Foobar. If not, see
<Field Horizontal="true">
<FieldLabel ColumnSize="ColumnSize.Is3">@_localizer["Filename"]</FieldLabel>
<FieldBody ColumnSize="ColumnSize.Is9">
<TextEdit Placeholder="@_localizer["Enter exportprofile filename here"]" Text="@SelectedExportProfile.Filename" Disabled="ModalExportdialogExportprofileLockUserInput" TextChanged="OnSelectedExportProfileFilenameChanged">
<TextEdit Placeholder="@_localizer["Enter exportprofile filename here"]" Text="@SelectedExportProfile.Filename" TextChanged="OnSelectedExportProfileFilenameChanged">
<Feedback>
<ValidationError />
</Feedback>
Expand All @@ -279,14 +279,14 @@ along with Foobar. If not, see
<FieldBody ColumnSize="ColumnSize.Is9">
<Addons>
<Addon AddonType="AddonType.Body">
<TextEdit Placeholder="@_localizer["Enter exportscheme head here"]" Text="@SelectedExportProfile.SchemeHead" Disabled="ModalExportdialogExportprofileLockUserInput" TextChanged="OnSelectedExportProfileSchemeHeadChanged">
<TextEdit Placeholder="@_localizer["Enter exportscheme head here"]" Text="@SelectedExportProfile.SchemeHead" TextChanged="OnSelectedExportProfileSchemeHeadChanged">
<Feedback>
<ValidationError Tooltip />
</Feedback>
</TextEdit>
</Addon>
<Addon AddonType="AddonType.End">
<Dropdown Disabled="ModalExportdialogExportprofileLockUserInput">
<Dropdown>
<DropdownToggle Color="Color.Secondary">
@_localizer["Select placeholder"]
</DropdownToggle>
Expand All @@ -312,14 +312,14 @@ along with Foobar. If not, see
<FieldBody ColumnSize="ColumnSize.Is9">
<Addons>
<Addon AddonType="AddonType.Body">
<TextEdit Placeholder="@_localizer["Enter exportscheme track here"]" Text="@SelectedExportProfile.SchemeTracks" Disabled="ModalExportdialogExportprofileLockUserInput" TextChanged="OnSelectedExportProfileSchemeTracksChanged">
<TextEdit Placeholder="@_localizer["Enter exportscheme track here"]" Text="@SelectedExportProfile.SchemeTracks" TextChanged="OnSelectedExportProfileSchemeTracksChanged">
<Feedback>
<ValidationError Tooltip />
</Feedback>
</TextEdit>
</Addon>
<Addon AddonType="AddonType.End">
<Dropdown Disabled="ModalExportdialogExportprofileLockUserInput">
<Dropdown>
<DropdownToggle Color="Color.Secondary">
@_localizer["Select placeholder"]
</DropdownToggle>
Expand All @@ -345,14 +345,14 @@ along with Foobar. If not, see
<FieldBody ColumnSize="ColumnSize.Is9">
<Addons>
<Addon AddonType="AddonType.Body">
<TextEdit Placeholder="@_localizer["Enter exportscheme footer here"]" Text="@SelectedExportProfile.SchemeFooter" Disabled="ModalExportdialogExportprofileLockUserInput" TextChanged="OnSelectedExportProfileSchemeFooterChanged">
<TextEdit Placeholder="@_localizer["Enter exportscheme footer here"]" Text="@SelectedExportProfile.SchemeFooter" TextChanged="OnSelectedExportProfileSchemeFooterChanged">
<Feedback>
<ValidationError Tooltip />
</Feedback>
</TextEdit>
</Addon>
<Addon AddonType="AddonType.End">
<Dropdown Disabled="ModalExportdialogExportprofileLockUserInput">
<Dropdown>
<DropdownToggle Color="Color.Secondary">
@_localizer["Select placeholder"]
</DropdownToggle>
Expand Down Expand Up @@ -438,30 +438,6 @@ along with Foobar. If not, see

Boolean IsCuesheetExportable => IsCuesheetExportableTooltip == null;

Boolean ModalExportdialogCuesheetLockUserInput
{
get
{
if (modalExportdialogCuesheet != null)
{
return modalExportdialogCuesheet.LockUserInputs;
}
return false;
}
}

Boolean ModalExportdialogExportprofileLockUserInput
{
get
{
if (modalExportdialogExportprofile != null)
{
return modalExportdialogExportprofile.LockUserInputs;
}
return false;
}
}

protected override async Task OnInitializedAsync()
{
_localizationService.LocalizationChanged += LocalizationService_LocalizationChanged;
Expand Down
35 changes: 13 additions & 22 deletions AudioCuesheetEditor/Shared/ModalExportdialog.razor
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ along with Foobar. If not, see
<CloseButton Clicked="() => ControlModalDialog(modalExportdialog, false)" />
</ModalHeader>
<ModalBody>
<Steps @bind-SelectedStep="selectedStep" NavigationAllowed="NavigationAllowed">
<Steps @ref="stepsRef" @bind-SelectedStep="selectedStep" NavigationAllowed="NavigationAllowed">
<Items>
<Step Name="prepareExport" Completed="prepareExportCompleted">@_localizer["Prepare export"]</Step>
<Step Name="displayExportResult">@_localizer["Result"]</Step>
Expand Down Expand Up @@ -84,26 +84,16 @@ along with Foobar. If not, see
</Steps>
</ModalBody>
<ModalFooter>
@if (exportProgress != null)
@if (selectedStep != "displayExportResult")
{
<Paragraph Width="Width.Is100">
@_localizer["Generation in progress, please stand by ..."]
</Paragraph>
<Progress Value="@exportProgress" Width="Width.Is100" Striped />
<Tooltip Placement="TooltipPlacement.Top" Text="@ExportPossibleTooltip">
<Button Color="Color.Primary" Clicked="GenerateExportfiles_Clicked" Disabled="!ExportPossible">@_localizer["Generate export files"]</Button>
</Tooltip>
<Button Color="Color.Secondary" Clicked="() => ControlModalDialog(modalExportdialog, false)">@_localizer["Abort"]</Button>
}
else
{
@if (selectedStep != "displayExportResult")
{
<Tooltip Placement="TooltipPlacement.Top" Text="@ExportPossibleTooltip">
<Button Color="Color.Primary" Clicked="GenerateExportfiles_Clicked" Disabled="!ExportPossible">@_localizer["Generate export files"]</Button>
</Tooltip>
<Button Color="Color.Secondary" Clicked="() => ControlModalDialog(modalExportdialog, false)">@_localizer["Abort"]</Button>
}
else
{
<Button Color="Color.Secondary" Clicked="() => ControlModalDialog(modalExportdialog, false)">@_localizer["Close"]</Button>
}
<Button Color="Color.Secondary" Clicked="() => ControlModalDialog(modalExportdialog, false)">@_localizer["Close"]</Button>
}
</ModalFooter>
</ModalContent>
Expand All @@ -128,15 +118,14 @@ along with Foobar. If not, see

public Boolean IsVisible { get; private set; }
public Validations? Validations { get; private set; }
public Boolean LockUserInputs { get => exportProgress != null; }

Modal? modalExportdialog;
String selectedStep = "prepareExport";
IReadOnlyCollection<Exportfile>? exportfiles;
Boolean prepareExportCompleted = false;
HotKeysContext? hotKeysContext;
int? exportProgress;
ApplicationOptions? applicationOptions;
Steps? stepsRef;

Boolean StepNavigationAllowed
{
Expand Down Expand Up @@ -213,13 +202,17 @@ along with Foobar. If not, see

public async Task Show()
{
Reset();
await ControlModalDialog(modalExportdialog, true);
}

public void Reset()
{
prepareExportCompleted = false;
selectedStep = "prepareExport";
if (stepsRef != null)
{
stepsRef.SelectStep("prepareExport");
}
exportfiles = null;
}

Expand All @@ -244,12 +237,10 @@ along with Foobar. If not, see
if (ExportPossible)
{
GenerateExportfilesClicked?.Invoke(this, EventArgs.Empty);
exportProgress = 0;
var generator = new ExportfileGenerator(ExportType, _sessionStateContainer.Cuesheet, SelectedExportProfile, applicationOptions);
exportfiles = generator.GenerateExportfiles();
selectedStep = "displayExportResult";
prepareExportCompleted = true;
exportProgress = null;
}
return Task.CompletedTask;
}
Expand Down

0 comments on commit 4ae9030

Please sign in to comment.