From 169e7c8e3a3ce5f01bd162af733759cea0ce4bb5 Mon Sep 17 00:00:00 2001 From: Flaky Date: Wed, 29 Apr 2026 15:07:28 +0100 Subject: [PATCH] fix some dialog issues, finish off adding a warning for unique tag names --- UI/Assets/Resources.resx | 2 +- UI/ViewModels/TagEditorViewModel.cs | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/UI/Assets/Resources.resx b/UI/Assets/Resources.resx index 718f1b1..5e7bcd1 100644 --- a/UI/Assets/Resources.resx +++ b/UI/Assets/Resources.resx @@ -294,6 +294,6 @@ Are you sure you want to delete this tag? - A tag already exists with this name and tag binding/s. Are you sure you want to save this tag? + A tag already exists with this name. Are you sure you want to save this tag? \ No newline at end of file diff --git a/UI/ViewModels/TagEditorViewModel.cs b/UI/ViewModels/TagEditorViewModel.cs index c1af082..1e3fc29 100644 --- a/UI/ViewModels/TagEditorViewModel.cs +++ b/UI/ViewModels/TagEditorViewModel.cs @@ -39,8 +39,13 @@ public partial class TagEditorViewModel : ViewModelBase, IDisposable [RelayCommand(AllowConcurrentExecutions = false)] internal async Task NewTag() { - var userWantsToSave = await this._dialogService.ShowDialog(new UnsavedCancelDialog()); - if (userWantsToSave is null) return; + if (!this.TagDatabaseService.IsDatabaseOpen || !this._mainWindow.IsDbEnabled) return; + + if (this._mainWindow.SelectedTag is not null && this.UnsavedChanges) + { + var userWantsToSave = await this._dialogService.ShowDialog(new UnsavedChangesDialog()); + if (userWantsToSave is null) return; + } this._mainWindow.SelectedTag = new TagItemViewModel( new Tag @@ -64,7 +69,7 @@ public partial class TagEditorViewModel : ViewModelBase, IDisposable var validatedUnique = this.TagDatabaseService.ValidateUnique(this._mainWindow.SelectedTag); if (!validatedUnique) { - // warn user + if (!await this._dialogService.ShowDialog(new UniqueWarnDialog())) return; } await this.TagDatabaseService.WriteTagsToDatabase([this._mainWindow.SelectedTag]); this._mainWindow.SelectedTag.RefreshParentsString(); -- 2.51.2