Automatic refiltering now works on chardonnay

This commit is contained in:
Michael Bucari-Tovo 2022-12-31 19:50:49 -07:00
parent 28802c8279
commit 613cfdd903
2 changed files with 21 additions and 10 deletions

View File

@ -27,14 +27,22 @@ namespace LibationAvalonia.Controls
IsEnabled = false
};
if (ToolTip.GetTip(cell) is null)
ToolTip.SetTip(cell, "Click to change ratings");
//Create a panel that fills the cell to host the rating tool tip
var panel = new Panel
{
Background = Avalonia.Media.Brushes.Transparent,
HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Stretch,
VerticalAlignment = Avalonia.Layout.VerticalAlignment.Stretch,
};
panel.Children.Add(myRatingElement);
ToolTip.SetTip(panel, "Click to change ratings");
if (Binding != null)
{
myRatingElement.Bind(BindingTarget, Binding);
}
return myRatingElement;
return panel;
}
protected override IControl GenerateEditingElementDirect(DataGridCell cell, object dataItem)
@ -48,8 +56,6 @@ namespace LibationAvalonia.Controls
Margin = new Thickness(3)
};
ToolTip.SetTip(cell, null);
return myRatingElement;
}

View File

@ -10,6 +10,8 @@ using ApplicationServices;
using AudibleUtilities;
using LibationAvalonia.Dialogs.Login;
using Avalonia.Collections;
using LibationSearchEngine;
using Octokit.Internal;
namespace LibationAvalonia.ViewModels
{
@ -157,12 +159,12 @@ namespace LibationAvalonia.ViewModels
{
if (string.IsNullOrEmpty(searchString)) return null;
var SearchResults = SearchEngineCommands.Search(searchString);
var searchResultSet = SearchEngineCommands.Search(searchString);
var booksFilteredIn = entries.BookEntries().Join(SearchResults.Docs, lbe => lbe.AudibleProductId, d => d.ProductId, (lbe, d) => (GridEntry)lbe);
var booksFilteredIn = entries.BookEntries().Join(searchResultSet.Docs, lbe => lbe.AudibleProductId, d => d.ProductId, (lbe, d) => (GridEntry)lbe);
//Find all series containing children that match the search criteria
var seriesFilteredIn = entries.SeriesEntries().Where(s => s.Children.Join(SearchResults.Docs, lbe => lbe.AudibleProductId, d => d.ProductId, (lbe, d) => lbe).Any());
var seriesFilteredIn = entries.SeriesEntries().Where(s => s.Children.Join(searchResultSet.Docs, lbe => lbe.AudibleProductId, d => d.ProductId, (lbe, d) => lbe).Any());
return booksFilteredIn.Concat(seriesFilteredIn).ToList();
}
@ -171,10 +173,13 @@ namespace LibationAvalonia.ViewModels
{
var filterResults = QueryResults(SOURCE, FilterString);
if (filterResults.Except(FilteredInGridEntries).Any())
if (filterResults is not null && FilteredInGridEntries.Intersect(filterResults).Count() != FilteredInGridEntries.Count)
{
FilteredInGridEntries = filterResults;
if (GridEntries.IsEditingItem)
GridEntries.CommitEdit();
await Dispatcher.UIThread.InvokeAsync(GridEntries.Refresh);
}
}