From 7061741537cfba4a32d8a563a3febf7f4038affe Mon Sep 17 00:00:00 2001 From: "Victor D. Sandiego" Date: Thu, 5 Sep 2024 16:48:13 -0600 Subject: [PATCH 1/6] Basics of queue indicator in title flags --- src/Panama.Database/Tables/TitleTable.cs | 16 +++++++++++++++ src/Panama/Core/Config/ConfigColors.cs | 5 +++++ src/Panama/Core/Other/FixedWidth.cs | 5 +++++ src/Panama/View/Title/TitleFlagsToolTip.xaml | 21 ++++++++++++-------- src/Panama/ViewModel/Title/TitleViewModel.cs | 3 ++- 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/src/Panama.Database/Tables/TitleTable.cs b/src/Panama.Database/Tables/TitleTable.cs index bd06bad2..8f4b8473 100644 --- a/src/Panama.Database/Tables/TitleTable.cs +++ b/src/Panama.Database/Tables/TitleTable.cs @@ -113,6 +113,16 @@ public static class Calculated /// public const string RelatedCount = "CalcRelatedCount"; + /// + /// Calculated column that holds the number of queues this title belongs to. + /// + public const string QueuedCount = "CalcQueuedCount"; + + /// + /// Calculated column that indicates if this title belongs to at least one queue. + /// + public const string IsQueued = "CalcIsQueued"; + /// /// The name of the submission count column. This calculated column /// holds the number of related records from the . @@ -303,6 +313,12 @@ protected override void UseDataRelations() expr = string.Format("Count(Child({0}).{1})", Defs.Relations.ToTitleRelated, TitleRelatedTable.Defs.Columns.TitleId); CreateExpressionColumn(Defs.Columns.Calculated.RelatedCount, expr); + expr = string.Format("Count(Child({0}).{1})", Defs.Relations.ToQueueTitle, QueueTitleTable.Defs.Columns.TitleId); + CreateExpressionColumn(Defs.Columns.Calculated.QueuedCount, expr); + + expr = string.Format("Count(Child({0}).{1}) > 0", Defs.Relations.ToQueueTitle, QueueTitleTable.Defs.Columns.TitleId); + CreateExpressionColumn(Defs.Columns.Calculated.IsQueued, expr); + expr = string.Format("Count(Child({0}).{1})", Defs.Relations.ToSubmission, SubmissionTable.Defs.Columns.Id); CreateExpressionColumn(Defs.Columns.Calculated.SubCount, expr); diff --git a/src/Panama/Core/Config/ConfigColors.cs b/src/Panama/Core/Config/ConfigColors.cs index 040e93ed..14e28a72 100644 --- a/src/Panama/Core/Config/ConfigColors.cs +++ b/src/Panama/Core/Config/ConfigColors.cs @@ -23,7 +23,9 @@ private static class Values public static readonly Color DataGridAlternationDefault = (Color)ColorConverter.ConvertFromString("#FFCBE4EC"); public static readonly Color TitleReadyDefault = SystemColors.Green; + public static readonly Color TitleQueuedDefault = SystemColors.DodgerBlue; public static readonly Color TitleFlaggedDefault = SystemColors.Blue; + public static readonly Color TitlePublishedDefault = SystemColors.Red; public static readonly Color TitleSelfPublishedDefault = SystemColors.Coral; public static readonly Color TitleSubmittedDefault = SystemColors.Black; @@ -47,7 +49,9 @@ private static class Values #region Public properties public ConfigColor DataGridAlternation { get; } + public ConfigColor TitleReady { get; } + public ConfigColor TitleQueued { get; } public ConfigColor TitleFlagged { get; } public ConfigColor TitlePublished { get; } public ConfigColor TitleSelfPublished { get; } @@ -75,6 +79,7 @@ internal ConfigColors() DataGridAlternation = new ConfigColor(nameof(DataGridAlternation), Values.DataGridAlternationDefault); TitleReady = new ConfigColor(nameof(TitleReady), Values.TitleReadyDefault); + TitleQueued = new ConfigColor(nameof(TitleQueued), Values.TitleQueuedDefault); TitleFlagged = new ConfigColor(nameof(TitleFlagged), Values.TitleFlaggedDefault); TitlePublished = new ConfigColor(nameof(TitlePublished), Values.TitlePublishedDefault); TitleSelfPublished = new ConfigColor(nameof(TitleSelfPublished), Values.TitleSelfPublishedDefault); diff --git a/src/Panama/Core/Other/FixedWidth.cs b/src/Panama/Core/Other/FixedWidth.cs index d926b466..d2a234e9 100644 --- a/src/Panama/Core/Other/FixedWidth.cs +++ b/src/Panama/Core/Other/FixedWidth.cs @@ -51,6 +51,11 @@ public class FixedWidth /// Fixed width of 76. /// public const int W076 = 76; + + /// + /// Fixed width of 86. + /// + public const int W086 = 86; /// /// Fixed width of 96 diff --git a/src/Panama/View/Title/TitleFlagsToolTip.xaml b/src/Panama/View/Title/TitleFlagsToolTip.xaml index 11553f60..ef626a51 100644 --- a/src/Panama/View/Title/TitleFlagsToolTip.xaml +++ b/src/Panama/View/Title/TitleFlagsToolTip.xaml @@ -9,7 +9,7 @@ d:DataContext="{d:DesignInstance Type=vm:TitleViewModel}" mc:Ignorable="d" tk:Property.ColumnWidths="Auto,*" - tk:Property.RowHeights="Auto,Auto,Auto,Auto,Auto,Auto" + tk:Property.RowHeights="Auto,Auto,Auto,Auto,Auto,Auto,Auto" d:DesignHeight="135" d:DesignWidth="180"> @@ -23,18 +23,22 @@ + + - - - - + + + + + \ No newline at end of file diff --git a/src/Panama/ViewModel/Title/TitleViewModel.cs b/src/Panama/ViewModel/Title/TitleViewModel.cs index 7c05817d..351ffc34 100644 --- a/src/Panama/ViewModel/Title/TitleViewModel.cs +++ b/src/Panama/ViewModel/Title/TitleViewModel.cs @@ -186,7 +186,7 @@ public TitleViewModel() Columns.Add(CreateFlagsColumn("Flags", GetFlagGridColumns()) .MakeCentered() - .MakeFixedWidth(FixedWidth.W076) + .MakeFixedWidth(FixedWidth.W086) .AddToolTip(TitleFlagsToolTip.Create(this))); Columns.Create("Title", TableColumns.Title).MakeFlexWidth(4); @@ -576,6 +576,7 @@ private FlagGridColumnCollection GetFlagGridColumns() return new FlagGridColumnCollection(this) { { TableColumns.Ready, Config.Colors.TitleReady.ToBindingPath() }, + { TableColumns.Calculated.IsQueued, Config.Colors.TitleQueued.ToBindingPath() }, { TableColumns.QuickFlag, Config.Colors.TitleFlagged.ToBindingPath() }, { TableColumns.Calculated.IsPublished, Config.Colors.TitlePublished.ToBindingPath() }, { TableColumns.Calculated.IsSelfPublished, Config.Colors.TitleSelfPublished.ToBindingPath() }, From 737454f3ca0133b1935a8e4a53d0554047119f4f Mon Sep 17 00:00:00 2001 From: "Victor D. Sandiego" Date: Thu, 5 Sep 2024 16:58:49 -0600 Subject: [PATCH 2/6] Set queued color Enable setting of queued color flag in settings. Include queued color in reset to default --- src/Panama/Core/Config/ConfigColors.cs | 1 + src/Panama/View/Tool/SettingsWindow.xaml | 25 ++++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Panama/Core/Config/ConfigColors.cs b/src/Panama/Core/Config/ConfigColors.cs index 14e28a72..3014bdd2 100644 --- a/src/Panama/Core/Config/ConfigColors.cs +++ b/src/Panama/Core/Config/ConfigColors.cs @@ -108,6 +108,7 @@ public void Reset() DataGridAlternation.ResetToDefault(); TitleReady.ResetToDefault(); + TitleQueued.ResetToDefault(); TitleFlagged.ResetToDefault(); TitlePublished.ResetToDefault(); TitleSelfPublished.ResetToDefault(); diff --git a/src/Panama/View/Tool/SettingsWindow.xaml b/src/Panama/View/Tool/SettingsWindow.xaml index e7ddacd2..3d80d8fb 100644 --- a/src/Panama/View/Tool/SettingsWindow.xaml +++ b/src/Panama/View/Tool/SettingsWindow.xaml @@ -15,7 +15,7 @@ ResizeMode="NoResize" Title="{x:Static r:Strings.MenuItemSettings}" Style="{StaticResource DefaultAppWindowStyle}" - Height="702" Width="602"> + Height="702" Width="622"> - + - + + + @@ -146,7 +151,7 @@ Header="Publisher" IsExpanded="{Binding Config.IsSettingPublisherColorExpanded}"> - + - + - + Date: Thu, 5 Sep 2024 19:14:41 -0600 Subject: [PATCH 3/6] Add strings --- src/Panama/Resources/Strings.Designer.cs | 18 ++++++++++++++++++ src/Panama/Resources/Strings.resx | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/src/Panama/Resources/Strings.Designer.cs b/src/Panama/Resources/Strings.Designer.cs index 21dda373..f1eabada 100644 --- a/src/Panama/Resources/Strings.Designer.cs +++ b/src/Panama/Resources/Strings.Designer.cs @@ -484,6 +484,15 @@ public static string ConfirmationRemoveSubmissionPeriod { } } + /// + /// Looks up a localized string similar to This operation removes the title from the selected queue. It does not affect the title itself.. + /// + public static string ConfirmationRemoveTitleFromQueue { + get { + return ResourceManager.GetString("ConfirmationRemoveTitleFromQueue", resourceCulture); + } + } + /// /// Looks up a localized string similar to Remove title from this submission?. /// @@ -1579,6 +1588,15 @@ public static string MenuItemRemoveExclusion { } } + /// + /// Looks up a localized string similar to Remove title from selected queue. + /// + public static string MenuItemRemoveFromQueue { + get { + return ResourceManager.GetString("MenuItemRemoveFromQueue", resourceCulture); + } + } + /// /// Looks up a localized string similar to Remove this published record. /// diff --git a/src/Panama/Resources/Strings.resx b/src/Panama/Resources/Strings.resx index e26131e4..5df320f3 100644 --- a/src/Panama/Resources/Strings.resx +++ b/src/Panama/Resources/Strings.resx @@ -1194,4 +1194,10 @@ Changes will take effect after you restart the application. Auto sort title list on updated (requires restart) + + This operation removes the title from the selected queue. It does not affect the title itself. + + + Remove title from selected queue + \ No newline at end of file From d365038acf6315da1a912dce9337c0485b225e26 Mon Sep 17 00:00:00 2001 From: "Victor D. Sandiego" Date: Thu, 5 Sep 2024 19:16:31 -0600 Subject: [PATCH 4/6] Add queue section to title Add section of title edit / view to see which queue(s) the title belongs to, and provide ability to remove from queue. --- src/Panama/View/Title/TitleEditContainer.xaml | 21 +++-- src/Panama/View/Title/TitleEditQueue.xaml | 25 ++++++ src/Panama/View/Title/TitleEditQueue.xaml.cs | 15 ++++ .../ViewModel/Title/TitleQueueController.cs | 79 +++++++++++++++++++ src/Panama/ViewModel/Title/TitleViewModel.cs | 46 ++++------- 5 files changed, 149 insertions(+), 37 deletions(-) create mode 100644 src/Panama/View/Title/TitleEditQueue.xaml create mode 100644 src/Panama/View/Title/TitleEditQueue.xaml.cs create mode 100644 src/Panama/ViewModel/Title/TitleQueueController.cs diff --git a/src/Panama/View/Title/TitleEditContainer.xaml b/src/Panama/View/Title/TitleEditContainer.xaml index 54a13f24..43c9b075 100644 --- a/src/Panama/View/Title/TitleEditContainer.xaml +++ b/src/Panama/View/Title/TitleEditContainer.xaml @@ -14,16 +14,17 @@ - - - + + + + @@ -50,17 +51,23 @@ tk:Property.IsLongVisible="{Binding SelectedEditSection}" tk:Property.IsLongVisibleValue="4"/> + + + + tk:Property.IsLongVisibleValue="6"/> + tk:Property.IsLongVisibleValue="7"/> + tk:Property.IsLongVisibleValue="8"/> \ No newline at end of file diff --git a/src/Panama/View/Title/TitleEditQueue.xaml b/src/Panama/View/Title/TitleEditQueue.xaml new file mode 100644 index 00000000..3cf2a684 --- /dev/null +++ b/src/Panama/View/Title/TitleEditQueue.xaml @@ -0,0 +1,25 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Panama/View/Title/TitleEditQueue.xaml.cs b/src/Panama/View/Title/TitleEditQueue.xaml.cs new file mode 100644 index 00000000..fa8539b6 --- /dev/null +++ b/src/Panama/View/Title/TitleEditQueue.xaml.cs @@ -0,0 +1,15 @@ +using System.Windows.Controls; + +namespace Restless.Panama.View +{ + /// + /// Interaction logic for TitleEditQueue.xaml + /// + public partial class TitleEditQueue : Grid + { + public TitleEditQueue() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/src/Panama/ViewModel/Title/TitleQueueController.cs b/src/Panama/ViewModel/Title/TitleQueueController.cs new file mode 100644 index 00000000..83049e5d --- /dev/null +++ b/src/Panama/ViewModel/Title/TitleQueueController.cs @@ -0,0 +1,79 @@ +using Restless.Panama.Database.Tables; +using Restless.Panama.Resources; +using Restless.Toolkit.Controls; +using System.Data; +using TableColumns = Restless.Panama.Database.Tables.QueueTitleTable.Defs.Columns; + +namespace Restless.Panama.ViewModel +{ + public class TitleQueueController : BaseController + { + private QueueTitleRow selectedQueue; + + #region Public properties + /// + public override bool DeleteCommandEnabled => IsSelectedRowAccessible; + + /// + /// Gets the selected queue row + /// + public QueueTitleRow SelectedQueue + { + get => selectedQueue; + private set => SetProperty(ref selectedQueue, value); + } + #endregion + + /************************************************************************/ + + #region Constructor + /// + /// Initializes a new instance of the class. + /// + /// The view model that owns this controller. + public TitleQueueController(TitleViewModel owner) : base(owner) + { + Columns.Create("Queue", TableColumns.Joined.QueueName) + .MakeInitialSortAscending(); + + Columns.Create("Status", TableColumns.Joined.Status); + + MenuItems.AddItem(Strings.MenuItemRemoveFromQueue, DeleteCommand).AddIconResource(ResourceKeys.Icon.XMediumIconKey); + } + #endregion + + /************************************************************************/ + + #region Protected methods + /// + protected override void OnSelectedItemChanged() + { + base.OnSelectedItemChanged(); + SelectedQueue = QueueTitleRow.Create(SelectedRow); + } + + /// + protected override int OnDataRowCompare(DataRow item1, DataRow item2) + { + return DataRowCompareString(item1, item2, TableColumns.Joined.QueueName); + } + + /// + protected override bool OnDataRowFilter(DataRow item) + { + return (long)item[TableColumns.TitleId] == (Owner?.SelectedTitle?.Id ?? 0); + } + + /// + protected override void RunDeleteCommand() + { + if (IsSelectedRowAccessible && MessageWindow.ShowContinueCancel(Strings.ConfirmationRemoveTitleFromQueue)) + { + SelectedQueue.Row.Delete(); + Table.Save(); + ListView.Refresh(); + } + } + #endregion + } +} \ No newline at end of file diff --git a/src/Panama/ViewModel/Title/TitleViewModel.cs b/src/Panama/ViewModel/Title/TitleViewModel.cs index 351ffc34..87abd62b 100644 --- a/src/Panama/ViewModel/Title/TitleViewModel.cs +++ b/src/Panama/ViewModel/Title/TitleViewModel.cs @@ -37,7 +37,7 @@ public class TitleViewModel : DataRowViewModel private TitleRow selectedTitle; private PreviewMode previewMode; private string previewText; - private const int SectionPreviewId = 7; + private const int SectionPreviewId = 8; private readonly int queueTitleMenuIndex; private bool haveQueueTitleItems; private QueueTable QueueTable => DatabaseController.Instance.GetTable(); @@ -81,58 +81,42 @@ public TitleRow SelectedTitle /// /// Gets the controller for the title versions. /// - public TitleVersionController Versions - { - get; - } + public TitleVersionController Versions { get; } /// /// Gets the controller for the related titles /// - public TitleRelatedController Related - { - get; - } + public TitleRelatedController Related { get;} + + /// + /// Gets the controller for the queues + /// + public TitleQueueController Queue { get; } /// /// Gets the controller for the title submissions. /// - public TitleSubmissionController Submissions - { - get; - } + public TitleSubmissionController Submissions { get; } /// /// Gets the controller for title published records. /// - public TitlePublishedController Published - { - get; - } + public TitlePublishedController Published { get; } /// /// Gets the controller for title published records. /// - public TitleSelfPublishedController SelfPublished - { - get; - } + public TitleSelfPublishedController SelfPublished { get; } /// /// Gets the controller for the title tags. /// - public TitleTagController TitleTags - { - get; - } + public TitleTagController TitleTags { get; } /// /// Gets the controller for the title filter tags /// - public TitleTagFilterController FilterTags - { - get; - } + public TitleTagFilterController FilterTags { get; } /// /// Gets the title filter object. @@ -276,6 +260,7 @@ public TitleViewModel() Versions = new TitleVersionController(this); Related = new TitleRelatedController(this); + Queue = new TitleQueueController(this); Submissions = new TitleSubmissionController(this); Published = new TitlePublishedController(this); SelfPublished = new TitleSelfPublishedController(this); @@ -350,6 +335,7 @@ protected override void OnSelectedItemChanged() TitleTags.PopulateAssigned(); Versions.Update(); Related.Update(); + Queue.Update(); Submissions.Update(); Published.Update(); SelfPublished.Update(); @@ -368,7 +354,6 @@ protected override int OnDataRowCompare(DataRow item1, DataRow item2) int value = DataRowCompareDateTime(item2, item1, TableColumns.Written); if (value == 0) { - //value = DataRowCompareLong(item2, item1, TableColumns.Id); value = DataRowCompareString(item1, item2, TableColumns.Title); } return value; @@ -548,6 +533,7 @@ private void RunAddTitleToQueueCommand(object parm) { QueueTitleTable.AddTitle(queue.Id, SelectedTitle.Id); QueueTable.Save(); + Queue.Update(); } } From 397c5b49044d539be4cabcb07b201e97c2407b7f Mon Sep 17 00:00:00 2001 From: "Victor D. Sandiego" Date: Fri, 27 Sep 2024 10:21:13 -0600 Subject: [PATCH 5/6] Sync title queue visibility section When toggling the title queue visibility option, ensure that the section within the title screen is visible / collapsed as needed. If queue visibility is turned off while the selected section is on the queues, select the main section. --- src/Panama/Core/Config/Config.cs | 1 + src/Panama/View/Title/TitleEditContainer.xaml | 2 +- src/Panama/ViewModel/Title/TitleViewModel.cs | 10 ++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Panama/Core/Config/Config.cs b/src/Panama/Core/Config/Config.cs index 34dee5cb..950d366c 100644 --- a/src/Panama/Core/Config/Config.cs +++ b/src/Panama/Core/Config/Config.cs @@ -1118,6 +1118,7 @@ protected override void OnRowValueChanged(string propertyId) PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyId)); break; case nameof(IsTitleQueueVisible): + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyId)); MainWindowViewModel.Instance.SynchronizeTitleQueue(); break; default: diff --git a/src/Panama/View/Title/TitleEditContainer.xaml b/src/Panama/View/Title/TitleEditContainer.xaml index 43c9b075..c51d1af9 100644 --- a/src/Panama/View/Title/TitleEditContainer.xaml +++ b/src/Panama/View/Title/TitleEditContainer.xaml @@ -21,7 +21,7 @@ - + diff --git a/src/Panama/ViewModel/Title/TitleViewModel.cs b/src/Panama/ViewModel/Title/TitleViewModel.cs index 87abd62b..f181ba50 100644 --- a/src/Panama/ViewModel/Title/TitleViewModel.cs +++ b/src/Panama/ViewModel/Title/TitleViewModel.cs @@ -37,6 +37,8 @@ public class TitleViewModel : DataRowViewModel private TitleRow selectedTitle; private PreviewMode previewMode; private string previewText; + // The next two must correspond to the defs in TitleEditContainer.xaml + private const int SectionQueueId = 5; private const int SectionPreviewId = 8; private readonly int queueTitleMenuIndex; private bool haveQueueTitleItems; @@ -309,6 +311,14 @@ public void SynchronizeQueueTitleMenuItems() } haveQueueTitleItems = true; } + + // Set selected section to main (1) if title queue turned off + // and selected section is currently Queues + // The visibility of the section item itself is handled by property changed event in Config + if (!Config.IsTitleQueueVisible && SelectedEditSection == SectionQueueId) + { + SelectedEditSection = 1; + } } #endregion From 203dc3df2836c1803eec280c9a43661a0eeda0fa Mon Sep 17 00:00:00 2001 From: "Victor D. Sandiego" Date: Fri, 27 Sep 2024 10:21:26 -0600 Subject: [PATCH 6/6] Bump version --- src/Panama/Panama.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Panama/Panama.csproj b/src/Panama/Panama.csproj index c6aac9d7..e72e0548 100644 --- a/src/Panama/Panama.csproj +++ b/src/Panama/Panama.csproj @@ -14,7 +14,7 @@ Restless.Panama net7.0-windows true - 4.0.38 + 4.0.39