Skip to content

Commit

Permalink
Merge branch 'develop' into bugfix/RDMP-281-cohort-override
Browse files Browse the repository at this point in the history
  • Loading branch information
JFriel authored Feb 4, 2025
2 parents 25b01fe + ae3ae66 commit 1371d0b
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Simplify DB Patching Interface
- Fix issue with Simple File Extractor pipeline component checking
- Improve cohort deprecation override test
- Add Filters for CatalogueItems to Dashboard graphs

## [8.4.2] - 2024-12-18

Expand Down
80 changes: 79 additions & 1 deletion Rdmp.UI/SimpleDialogs/SelectDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public partial class SelectDialog<T> : Form, IVirtualListDataSource where T : cl
private HashSet<string> _typeNames;

private List<Type> showOnlyTypes = new();
private readonly Dictionary<Type, List<string>> showOnlyEnums = new();
private Type _alwaysFilterOn;
private ToolStripTextBox _lblId;
private readonly DialogArgs _args;
Expand Down Expand Up @@ -366,6 +367,7 @@ private void BuildToolStripForDatabaseObjects(RDMPCollection focusedCollection)

foreach (var t in StartingEasyFilters.SelectMany(v => v.Value)) _typeNames.Add(t.Name);
Type[] startingFilters = null;
string[] startingFilterEnumValues = [];

if (focusedCollection != RDMPCollection.None &&
StartingEasyFilters.TryGetValue(focusedCollection, out var filter))
Expand All @@ -392,6 +394,32 @@ private void BuildToolStripForDatabaseObjects(RDMPCollection focusedCollection)

toolStrip1.Items.Add(b);
}
else if (_types.Length == 1)
switch (_types.First().Name)
{
case "CatalogueItem":
foreach (var t in Enum.GetValues(typeof(ExtractionCategory)))
{
if (t.ToString() == ExtractionCategory.Any.ToString()) continue;
var b = new ToolStripButton
{
Checked = startingFilterEnumValues?.Contains(t) == true,
Image = _activator.CoreIconProvider.GetImage(t).ImageToBitmap(),
DisplayStyle = ToolStripItemDisplayStyle.Image,
CheckOnClick = true,
Text = $"{t}",
Tag = typeof(CatalogueItem)
};

b.CheckedChanged += EnumCheckedChanged;

toolStrip1.Items.Add(b);
}
break;
default:
toolStripLabel1.Visible = false;
break;
}
else
toolStripLabel1.Visible = false;

Expand Down Expand Up @@ -504,10 +532,32 @@ private void FetchMatches(string text, CancellationToken cancellationToken)
};

if (_lblId != null && int.TryParse(_lblId.Text, out var requireId)) scorer.ID = requireId;
var _filtered = new Dictionary<IMapsDirectlyToDatabaseTable,DescendancyList>(_searchables);
foreach(var key in showOnlyEnums.Keys)
{
switch (key.Name)
{
case "CatalogueItem":
foreach(var k in _filtered.Keys)
{
showOnlyEnums.TryGetValue(k.GetType(), out var v1);
if (showOnlyEnums.TryGetValue(k.GetType(),out var v) &&
(v.Count >0 &&!v.Contains(((CatalogueItem)k).ExtractionInformation.ExtractionCategory.ToString()))

)
{
_filtered.Remove(k);
}
}
break;
default:
break;
}

}
if (AlwaysFilterOn != null) showOnlyTypes = new List<Type>(new[] { AlwaysFilterOn });

var scores = scorer.ScoreMatches(_searchables, text, showOnlyTypes, cancellationToken);
var scores = scorer.ScoreMatches(_filtered, text, showOnlyTypes, cancellationToken);

if (scores == null)
{
Expand Down Expand Up @@ -611,6 +661,34 @@ private void CollectionCheckedChanged(object sender, EventArgs e)
tbFilter_TextChanged(null, null);
}

private void EnumCheckedChanged(object sender, EventArgs e)
{
var button = (ToolStripButton)sender;

var togglingType = (Type)button.Tag; ;

if (button.Checked)
if (showOnlyEnums.TryGetValue(togglingType, out var value))
{
value.Add(button.Text);
showOnlyEnums[togglingType] = value;
}
else
{
showOnlyEnums[togglingType] = new List<string>() { button.Text };
}
else
if (showOnlyEnums.TryGetValue(togglingType, out var value))
{
value = value.Where(v => v != button.Text).ToList();
showOnlyEnums[togglingType] = value;

}

//refresh the objects showing
tbFilter_TextChanged(null, null);
}

private static bool IsDatabaseObjects() => typeof(IMapsDirectlyToDatabaseTable).IsAssignableFrom(typeof(T));

private void tbFilter_TextChanged(object sender, EventArgs e)
Expand Down

0 comments on commit 1371d0b

Please sign in to comment.