From 31ab9f01714748aae62386a8091fbb0eaaf48d4b Mon Sep 17 00:00:00 2001 From: "Victor D. Sandiego" Date: Tue, 31 Jan 2023 13:18:47 -0600 Subject: [PATCH 1/3] Basics of directory filter --- src/Panama/Core/Filter/TitleRowFilter.cs | 9 +++++++++ src/Panama/View/Title/TitleCustomFilter.xaml | 20 +++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/Panama/Core/Filter/TitleRowFilter.cs b/src/Panama/Core/Filter/TitleRowFilter.cs index 448a52e2..3e899636 100644 --- a/src/Panama/Core/Filter/TitleRowFilter.cs +++ b/src/Panama/Core/Filter/TitleRowFilter.cs @@ -35,6 +35,15 @@ public class TitleRowFilter : RowFilter /// public override bool IsAnyFilterActive => base.IsAnyFilterActive || IsAnyEvaluatorActive(); + /// + /// Gets or sets a partial or whole directory name + /// + public string Directory + { + get; + set; + } + /// /// Gets or sets the filter state for whether a title is flagged as ready /// diff --git a/src/Panama/View/Title/TitleCustomFilter.xaml b/src/Panama/View/Title/TitleCustomFilter.xaml index 2faf8cd3..686cf372 100644 --- a/src/Panama/View/Title/TitleCustomFilter.xaml +++ b/src/Panama/View/Title/TitleCustomFilter.xaml @@ -33,6 +33,7 @@ tk:Property.RowHeights="Auto,Auto,Auto,Auto,*" Style="{StaticResource DataEntryPanelStyle}"> + - + + + + + + + + - + - - + + tk:Property.ColumnWidths="340,340"> From 39cfa326424b796c9932a89a08b0240c71de0893 Mon Sep 17 00:00:00 2001 From: "Victor D. Sandiego" Date: Tue, 31 Jan 2023 13:47:36 -0600 Subject: [PATCH 2/3] Implement directory filter --- src/Panama/Core/Filter/TitleFilterEvaluator.cs | 9 +++++++++ src/Panama/Core/Filter/TitleRowFilter.cs | 14 ++++++++++++-- src/Panama/Core/Filter/TitleRowFilterType.cs | 4 ++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Panama/Core/Filter/TitleFilterEvaluator.cs b/src/Panama/Core/Filter/TitleFilterEvaluator.cs index e2ae1cfe..4d2e16e5 100644 --- a/src/Panama/Core/Filter/TitleFilterEvaluator.cs +++ b/src/Panama/Core/Filter/TitleFilterEvaluator.cs @@ -38,6 +38,7 @@ private Predicate GetEvaluator(TitleRowFilterType filterType) { TitleRowFilterType.Id => EvaluateId, TitleRowFilterType.Text => EvaluateText, + TitleRowFilterType.Directory => EvaluateDirectory, TitleRowFilterType.Ready => EvaluateReady, TitleRowFilterType.Flagged => EvaluateFlagged, TitleRowFilterType.CurrentlySubmitted => EvaluateCurrentlySubmitted, @@ -54,6 +55,7 @@ private bool GetIsEvaluatorActive() { return filterType switch { + TitleRowFilterType.Directory => !string.IsNullOrWhiteSpace(Filter.Directory), TitleRowFilterType.WordCount => Filter.WordCount != 0, TitleRowFilterType.Tag => Filter.Tags.Count > 0, _ => base.IsActive @@ -73,6 +75,13 @@ private bool EvaluateText(DataRow item) item[Columns.Title].ToString().Contains(Filter.Text, StringComparison.InvariantCultureIgnoreCase); } + private bool EvaluateDirectory(DataRow item) + { + return + string.IsNullOrWhiteSpace(Filter.Directory) || + item[Columns.Calculated.LastestVersionPath].ToString().Contains(Filter.Directory, StringComparison.InvariantCultureIgnoreCase); + } + private bool EvaluateReady(DataRow item) { return State == ThreeWayState.Neutral || EvaluateBoolColumn(item[Columns.Ready]); diff --git a/src/Panama/Core/Filter/TitleRowFilter.cs b/src/Panama/Core/Filter/TitleRowFilter.cs index 3e899636..dd3682ad 100644 --- a/src/Panama/Core/Filter/TitleRowFilter.cs +++ b/src/Panama/Core/Filter/TitleRowFilter.cs @@ -18,6 +18,7 @@ public class TitleRowFilter : RowFilter private ThreeWayState everSubmittedState; private ThreeWayState publishedState; private ThreeWayState selfPublishedState; + private string directory; private int wordCount; private bool isTagFilterAny; private bool isTagFilterAll; @@ -40,8 +41,14 @@ public class TitleRowFilter : RowFilter /// public string Directory { - get; - set; + get => directory; + set + { + if (SetProperty(ref directory, value)) + { + ApplyFilter(); + } + } } /// @@ -193,6 +200,7 @@ public TitleRowFilter() { { TitleRowFilterType.Id, new TitleFilterEvaluator(this, TitleRowFilterType.Id) }, { TitleRowFilterType.Text, new TitleFilterEvaluator(this, TitleRowFilterType.Text) }, + { TitleRowFilterType.Directory, new TitleFilterEvaluator(this, TitleRowFilterType.Directory) }, { TitleRowFilterType.Ready, new TitleFilterEvaluator(this, TitleRowFilterType.Ready) }, { TitleRowFilterType.Flagged, new TitleFilterEvaluator(this, TitleRowFilterType.Flagged) }, { TitleRowFilterType.CurrentlySubmitted, new TitleFilterEvaluator(this, TitleRowFilterType.CurrentlySubmitted) }, @@ -219,6 +227,7 @@ public override void ClearAll() IncreaseSuspendLevel(); base.ClearAll(); ClearAllPropertyState(); + Directory = null; WordCount = 0; Tags.Clear(); IsTagFilterAny = true; @@ -271,6 +280,7 @@ public override bool OnDataRowFilter(DataRow item) return filterEvaluators[TitleRowFilterType.Id].Evaluate(item) && filterEvaluators[TitleRowFilterType.Text].Evaluate(item) && + filterEvaluators[TitleRowFilterType.Directory].Evaluate(item) && filterEvaluators[TitleRowFilterType.Ready].Evaluate(item) && filterEvaluators[TitleRowFilterType.Flagged].Evaluate(item) && filterEvaluators[TitleRowFilterType.CurrentlySubmitted].Evaluate(item) && diff --git a/src/Panama/Core/Filter/TitleRowFilterType.cs b/src/Panama/Core/Filter/TitleRowFilterType.cs index 375a0975..c4a41b65 100644 --- a/src/Panama/Core/Filter/TitleRowFilterType.cs +++ b/src/Panama/Core/Filter/TitleRowFilterType.cs @@ -14,6 +14,10 @@ public enum TitleRowFilterType /// Text, /// + /// Filter according to the directory where a title is stored + /// + Directory, + /// /// Title is flagged as ready /// Ready, From 1907e4535a15e5b1eb7be3b41ab449f682ece469 Mon Sep 17 00:00:00 2001 From: "Victor D. Sandiego" Date: Tue, 31 Jan 2023 14:24:44 -0600 Subject: [PATCH 3/3] Update TitleCustomFilter.xaml Change text of the label because the filter examines the full path to the file, which means that the filter could match the name of the file, not just the directory. --- src/Panama/View/Title/TitleCustomFilter.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Panama/View/Title/TitleCustomFilter.xaml b/src/Panama/View/Title/TitleCustomFilter.xaml index 686cf372..92b6b5f1 100644 --- a/src/Panama/View/Title/TitleCustomFilter.xaml +++ b/src/Panama/View/Title/TitleCustomFilter.xaml @@ -44,7 +44,7 @@ - +