TaskGrid.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using Comal.Classes;
  9. using InABox.Clients;
  10. using InABox.Configuration;
  11. using InABox.Core;
  12. using InABox.DynamicGrid;
  13. using InABox.WPF;
  14. namespace PRSDesktop;
  15. public class TaskGrid : BaseKanbanGrid, ITaskControl
  16. {
  17. protected override TaskPanelProperties Properties => Host.Properties;
  18. protected override void Reload(
  19. Filters<Kanban> criteria, Columns<Kanban> columns, ref SortOrder<Kanban>? sort,
  20. CancellationToken token, Action<CoreTable?, Exception?> action)
  21. {
  22. if (Host.Master != null)
  23. criteria.Add(new Filter<Kanban>(x => x.JobLink.ID).IsEqualTo(Host.Master.ID));
  24. base.Reload(criteria, columns, ref sort, token, action);
  25. }
  26. #region ITaskControl Support
  27. public KanbanViewType KanbanViewType => KanbanViewType.List;
  28. public ITaskHost Host { get; set; }
  29. public bool IsReady { get; set; }
  30. public string SectionName => "Task List";
  31. public DataModel DataModel(Selection selection)
  32. {
  33. var ids = ExtractValues<Guid>(x => x.ID, selection);
  34. if (!ids.Any())
  35. ids = [Guid.Empty];
  36. return new AutoDataModel<Kanban>(new Filter<Kanban>(x => x.ID).InList(ids.ToArray()));
  37. }
  38. public void Refresh()
  39. {
  40. Refresh(false, true);
  41. }
  42. public void Refresh(bool resetselection)
  43. {
  44. Refresh(false, true);
  45. // reset selected rows here
  46. }
  47. public void Setup()
  48. {
  49. FilterComponent.SetSettings(Host.KanbanSettings.Filters, false);
  50. Refresh(true, false);
  51. }
  52. public IEnumerable<TaskModel> SelectedModels(TaskModel? sender = null)
  53. {
  54. MessageBox.Show("TaskListControl.SelectedModels() is not Implemented!");
  55. return Array.Empty<TaskModel>();
  56. }
  57. protected override bool CanCreateItems()
  58. {
  59. return base.CanCreateItems() && (Host.Master?.ID ?? Guid.Empty) != Guid.Empty;
  60. }
  61. public override Kanban CreateItem()
  62. {
  63. var result = base.CreateItem();
  64. result.JobLink.ID = Host.Master?.ID ?? Guid.Empty;
  65. result.JobLink.Synchronise(Host.Master ?? new Job());
  66. return result;
  67. }
  68. #endregion
  69. }