ui(manager): improve search bindings
This commit is contained in:
@@ -11,13 +11,13 @@ public class MainWindowViewModel : INotifyPropertyChanged
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
private ObservableCollection<MainWindowTreeNode>? currentTreeNodes;
|
||||
private ObservableCollection<MainWindowGridRow>? currentGridRows;
|
||||
private MainWindowTreeNode? selectedTreeNode;
|
||||
private IWorkspace? currentWorkspace;
|
||||
|
||||
public bool IsUpdate => selectedTreeNode is ActionSetTreeNode node && node.Infos is UpdateInfo;
|
||||
public ProgressInfos Progress { get; } = new();
|
||||
public MainWindowGridRow? SelectedGridRow { get; set; }
|
||||
public DynamicDataView<MainWindowGridRow> CurrentGridRows { get; } = new(FilterGridRows);
|
||||
|
||||
[AlsoNotifyFor(nameof(CurrentTreeNodes))]
|
||||
public IWorkspace? CurrentWorkspace
|
||||
@@ -48,24 +48,23 @@ public class MainWindowViewModel : INotifyPropertyChanged
|
||||
}
|
||||
}
|
||||
|
||||
[AlsoNotifyFor(nameof(CurrentGridRows))]
|
||||
public MainWindowTreeNode? SelectedTreeNode
|
||||
{
|
||||
get => selectedTreeNode;
|
||||
set
|
||||
{
|
||||
currentGridRows = null;
|
||||
selectedTreeNode = value;
|
||||
CurrentGridRows.List.Edit(list =>
|
||||
{
|
||||
list.Clear();
|
||||
if (CurrentWorkspace?.InstallInfos != null && selectedTreeNode is ActionSetTreeNode node)
|
||||
list.AddRange(node.Infos.Actions.Select(n => new MainWindowGridRow(n, CurrentWorkspace.InstallInfos)));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<MainWindowGridRow>? CurrentGridRows
|
||||
private static Func<MainWindowGridRow, bool> FilterGridRows(string? searchText)
|
||||
{
|
||||
get
|
||||
{
|
||||
if (currentGridRows == null && CurrentWorkspace?.InstallInfos != null && selectedTreeNode is ActionSetTreeNode node)
|
||||
currentGridRows = [.. node.Infos.Actions.Select(n => new MainWindowGridRow(n, CurrentWorkspace.InstallInfos))];
|
||||
return currentGridRows;
|
||||
}
|
||||
return n => string.IsNullOrWhiteSpace(searchText) || true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user