using System; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using Comal.Classes; using InABox.Clients; using InABox.Configuration; using InABox.Core; using InABox.DynamicGrid; using InABox.WPF; namespace PRSDesktop; public class TaskGrid : BaseKanbanGrid, ITaskControl { protected override TaskPanelProperties Properties => Host.Properties; protected override void Reload( Filters criteria, Columns columns, ref SortOrder? sort, CancellationToken token, Action action) { if (Host.Master != null) criteria.Add(new Filter(x => x.JobLink.ID).IsEqualTo(Host.Master.ID)); base.Reload(criteria, columns, ref sort, token, action); } #region ITaskControl Support public KanbanViewType KanbanViewType => KanbanViewType.List; public ITaskHost Host { get; set; } public bool IsReady { get; set; } public string SectionName => "Task List"; public DataModel DataModel(Selection selection) { var ids = ExtractValues(x => x.ID, selection); if (!ids.Any()) ids = [Guid.Empty]; return new AutoDataModel(new Filter(x => x.ID).InList(ids.ToArray())); } public void Refresh() { Refresh(false, true); } public void Refresh(bool resetselection) { Refresh(false, true); // reset selected rows here } public void Setup() { FilterComponent.SetSettings(Host.KanbanSettings.Filters, false); Refresh(true, false); } public IEnumerable SelectedModels(TaskModel? sender = null) { MessageBox.Show("TaskListControl.SelectedModels() is not Implemented!"); return Array.Empty(); } protected override bool CanCreateItems() { return base.CanCreateItems() && (Host.Master?.ID ?? Guid.Empty) != Guid.Empty; } public override Kanban CreateItem() { var result = base.CreateItem(); result.JobLink.ID = Host.Master?.ID ?? Guid.Empty; result.JobLink.Synchronise(Host.Master ?? new Job()); return result; } #endregion }