JobScopeFormGrid.cs 1.3 KB

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