From 14fc5b29eeccd68b6c7fd56d65da1ce1184d1668 Mon Sep 17 00:00:00 2001 From: Michael Babienco Date: Tue, 21 Apr 2026 11:31:33 +0900 Subject: [PATCH] Add back button to create report view; fix change title not warning about unsaved --- .../ViewModels/CreatePDFReportViewModel.cs | 29 +++++++++---------- .../Views/CreatePDFReportView.axaml | 7 +++++ .../Views/ShutdownCheckView.axaml | 4 +-- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/MayShow.Shared/ViewModels/CreatePDFReportViewModel.cs b/src/MayShow.Shared/ViewModels/CreatePDFReportViewModel.cs index 7c360be..a99eb05 100644 --- a/src/MayShow.Shared/ViewModels/CreatePDFReportViewModel.cs +++ b/src/MayShow.Shared/ViewModels/CreatePDFReportViewModel.cs @@ -111,9 +111,10 @@ class CreatePDFReportViewModel : BaseViewModel, ICanCheckShutdown, ILogger set { _pdfReport.Title = value; - NotifyPropertyChanged(); - NotifyPropertyChanged(nameof(IsTitleBoxVisible)); - NotifyPropertyChanged(nameof(CanAddItem)); + NotifyPropertyChanged(); + NotifyPropertyChanged(nameof(IsTitleBoxVisible)); + NotifyPropertyChanged(nameof(CanAddItem)); + HasUnsavedWork = true; } } @@ -341,19 +342,6 @@ class CreatePDFReportViewModel : BaseViewModel, ICanCheckShutdown, ILogger 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 public void EditFileProperties(object f) => EditFilePropertiesImpl((ReportFile)f); public async void EditFilePropertiesImpl(ReportFile file) @@ -634,6 +622,15 @@ class CreatePDFReportViewModel : BaseViewModel, ICanCheckShutdown, ILogger IsCreatingPDF = false; } + public async void ReturnToMainMenu() + { + bool isSafeToReturn = await CheckIsSafeToShutdown(); + if (isSafeToReturn) + { + PopViewModel(); + } + } + public async Task CheckIsSafeToShutdown() { if (!HasUnsavedWork || string.IsNullOrWhiteSpace(WorkingFolder)) diff --git a/src/MayShow.Shared/Views/CreatePDFReportView.axaml b/src/MayShow.Shared/Views/CreatePDFReportView.axaml index 6eb3d22..728ec32 100644 --- a/src/MayShow.Shared/Views/CreatePDFReportView.axaml +++ b/src/MayShow.Shared/Views/CreatePDFReportView.axaml @@ -15,6 +15,13 @@ + diff --git a/src/MayShow.Shared/Views/ShutdownCheckView.axaml b/src/MayShow.Shared/Views/ShutdownCheckView.axaml index 8f929ed..8a2ca9e 100644 --- a/src/MayShow.Shared/Views/ShutdownCheckView.axaml +++ b/src/MayShow.Shared/Views/ShutdownCheckView.axaml @@ -18,7 +18,7 @@ FontWeight="Bold" TextWrapping="Wrap" 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?"/>