JobScopeFormGrid.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using System.Threading;
  3. using Comal.Classes;
  4. using InABox.Core;
  5. using InABox.DynamicGrid;
  6. namespace PRSDesktop;
  7. public class JobScopeFormGrid : DynamicEntityFormGrid<JobForm, Job, JobLink>, IJobScopeGrid
  8. {
  9. public JobScope? Scope { get; set; }
  10. private readonly Column<JobForm> ScopeColumn = new Column<JobForm>(x => x.JobScope);
  11. public JobScopeFormGrid(Job job): base(job)
  12. {
  13. }
  14. protected override void CustomiseEditor(JobForm[] items, DynamicGridColumn column, BaseEditor editor)
  15. {
  16. base.CustomiseEditor(items, column, editor);
  17. if(ScopeColumn.IsEqualTo(column.ColumnName) || ScopeColumn.IsParentOf(column.ColumnName))
  18. {
  19. editor.Editable = Editable.Hidden;
  20. }
  21. }
  22. protected override void DoReconfigure(DynamicGridOptions options)
  23. {
  24. base.DoReconfigure(options);
  25. options.AddRows = false;
  26. }
  27. protected override void Reload(
  28. Filters<JobForm> criteria, Columns<JobForm> columns, ref SortOrder<JobForm>? sort,
  29. CancellationToken token, Action<CoreTable?, Exception?> action)
  30. {
  31. if ((Scope == null) || (Scope.ID == Guid.Empty))
  32. criteria.Add(new Filter<JobForm>(x => x.ID).None());
  33. else
  34. criteria.Add(new Filter<JobForm>(x => x.JobScope.ID).IsEqualTo(Scope.ID));
  35. base.Reload(criteria, columns, ref sort, token, action);
  36. }
  37. }