mirror of
https://github.com/BlossomiShymae/Needlework.Net.git
synced 2025-12-06 10:10:48 +01:00
56 lines
1.7 KiB
C#
56 lines
1.7 KiB
C#
using Avalonia;
|
|
using AvaloniaEdit.Utils;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
|
|
namespace Needlework.Net.ViewModels.Pages.Endpoints;
|
|
|
|
public partial class PluginViewModel : ObservableObject
|
|
{
|
|
public PluginViewModel(Services.NotificationService notificationService, string endpoint, Models.Document document, Tab tab)
|
|
{
|
|
Endpoint = endpoint;
|
|
PathOperations = document.Plugins[endpoint].Select(x => new PathOperationViewModel(notificationService, x, document, tab)).ToList();
|
|
FilteredPathOperations = new ObservableCollection<PathOperationViewModel>(PathOperations);
|
|
}
|
|
|
|
public string Endpoint { get; }
|
|
|
|
public string Title => Endpoint;
|
|
|
|
public List<PathOperationViewModel> PathOperations { get; }
|
|
|
|
[ObservableProperty]
|
|
private ObservableCollection<PathOperationViewModel> _filteredPathOperations;
|
|
|
|
[ObservableProperty]
|
|
private PathOperationViewModel? _selectedPathOperation;
|
|
|
|
[ObservableProperty]
|
|
private string? _search;
|
|
|
|
[ObservableProperty]
|
|
private Vector _offset = new();
|
|
|
|
[ObservableProperty]
|
|
private Vector _paramsOffset = new();
|
|
|
|
[ObservableProperty]
|
|
private Vector _schemasOffset = new();
|
|
|
|
partial void OnSearchChanged(string? value)
|
|
{
|
|
FilteredPathOperations.Clear();
|
|
|
|
if (string.IsNullOrWhiteSpace(value))
|
|
{
|
|
FilteredPathOperations.AddRange(PathOperations);
|
|
return;
|
|
}
|
|
FilteredPathOperations.AddRange(PathOperations.Where(o => o.Path.Contains(value, StringComparison.InvariantCultureIgnoreCase)));
|
|
}
|
|
}
|