Add back button to create report view; fix change title not warning about unsaved

This commit is contained in:
2026-04-21 11:31:33 +09:00
parent d99fefe74d
commit 14fc5b29ee
3 changed files with 22 additions and 18 deletions
@@ -114,6 +114,7 @@ class CreatePDFReportViewModel : BaseViewModel, ICanCheckShutdown, ILogger
NotifyPropertyChanged(); NotifyPropertyChanged();
NotifyPropertyChanged(nameof(IsTitleBoxVisible)); NotifyPropertyChanged(nameof(IsTitleBoxVisible));
NotifyPropertyChanged(nameof(CanAddItem)); NotifyPropertyChanged(nameof(CanAddItem));
HasUnsavedWork = true;
} }
} }
@@ -341,19 +342,6 @@ class CreatePDFReportViewModel : BaseViewModel, ICanCheckShutdown, ILogger
NotifyPropertyChanged(nameof(IsCreatePDFButtonEnabled)); NotifyPropertyChanged(nameof(IsCreatePDFButtonEnabled));
} }
public async Task ShowSettings()
{
var updatedSettings = await DialogHost.Show(new SettingsViewModel(_settings, TopLevelGrabber));
if (updatedSettings != null)
{
_settings = (Settings)updatedSettings;
await _settings.SaveSettingsAsync();
LogInfo("Saved updated settings!");
NotifyPropertyChanged(nameof(DataGridDateFormat));
NotifyPropertyChanged(nameof(DataGridDateFormatWatermark));
}
}
// https://github.com/AvaloniaUI/Avalonia/issues/10075 // https://github.com/AvaloniaUI/Avalonia/issues/10075
public void EditFileProperties(object f) => EditFilePropertiesImpl((ReportFile)f); public void EditFileProperties(object f) => EditFilePropertiesImpl((ReportFile)f);
public async void EditFilePropertiesImpl(ReportFile file) public async void EditFilePropertiesImpl(ReportFile file)
@@ -634,6 +622,15 @@ class CreatePDFReportViewModel : BaseViewModel, ICanCheckShutdown, ILogger
IsCreatingPDF = false; IsCreatingPDF = false;
} }
public async void ReturnToMainMenu()
{
bool isSafeToReturn = await CheckIsSafeToShutdown();
if (isSafeToReturn)
{
PopViewModel();
}
}
public async Task<bool> CheckIsSafeToShutdown() public async Task<bool> CheckIsSafeToShutdown()
{ {
if (!HasUnsavedWork || string.IsNullOrWhiteSpace(WorkingFolder)) if (!HasUnsavedWork || string.IsNullOrWhiteSpace(WorkingFolder))
@@ -15,6 +15,13 @@
</UserControl.Resources> </UserControl.Resources>
<Grid ColumnDefinitions="*" <Grid ColumnDefinitions="*"
RowDefinitions="Auto, 2*, Auto, Auto, *"> RowDefinitions="Auto, 2*, Auto, Auto, *">
<Button Command="{Binding ReturnToMainMenu}"
Grid.Row="0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="4,4,0,4">
<TextBlock><Run Text="&#xf060;" FontFamily="{StaticResource FontAwesomeSolid}"/> Return to Main Menu</TextBlock>
</Button>
<StackPanel Orientation="Vertical" <StackPanel Orientation="Vertical"
Spacing="2" Spacing="2"
Margin="0,4,0,0"> Margin="0,4,0,0">
@@ -18,7 +18,7 @@
FontWeight="Bold" FontWeight="Bold"
TextWrapping="Wrap" TextWrapping="Wrap"
FontSize="14" FontSize="14"
Text="Do you want to save your data before the program is closed?"/> Text="Do you want to save your data before closing?"/>
<StackPanel Orientation="Horizontal" <StackPanel Orientation="Horizontal"
Spacing="8"> Spacing="8">
<Button Command="{Binding SaveAndShutdown}" <Button Command="{Binding SaveAndShutdown}"
@@ -31,7 +31,7 @@
HorizontalAlignment="Right" HorizontalAlignment="Right"
Margin="0,4,0,4"/> Margin="0,4,0,4"/>
<Button Command="{Binding CancelShutdown}" <Button Command="{Binding CancelShutdown}"
Content="Cancel Program Shutdown" Content="Cancel"
HorizontalAlignment="Right" HorizontalAlignment="Right"
Margin="0,4,0,4"/> Margin="0,4,0,4"/>
</StackPanel> </StackPanel>