JobSelectionPage.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Linq;
  3. using InABox.Mobile;
  4. using Xamarin.Forms;
  5. namespace PRS.Mobile
  6. {
  7. public class JobSelectionPage : SelectionPage
  8. {
  9. public JobSelectionPage(Action<JobShell> action)
  10. : base(
  11. "Select Job",
  12. SelectionPageMode.Immediate,
  13. (columns, filters) =>
  14. {
  15. columns
  16. .BeginUpdate()
  17. .Clear()
  18. .Add(new MobileGridTextColumn<JobShell>()
  19. { Column = x => x.JobNumber, Width = 100, Alignment = TextAlignment.Center })
  20. .Add(new MobileGridTextColumn<JobShell>()
  21. { Column = x => x.Name, Width = GridLength.Star, Alignment = TextAlignment.Start })
  22. .EndUpdate();
  23. filters.AddRange(App.Data.Jobs.AvailableFilters().Select(x=>x.Name));
  24. },
  25. (args) =>
  26. {
  27. App.Data.Jobs.SelectFilter(args.Filter);
  28. var result = App.Data.Jobs.Refresh(args.Force);
  29. args.LastUpdated = App.Data.Jobs.LastUpdated;
  30. return result;
  31. },
  32. (items) => action?.Invoke(items.FirstOrDefault() as JobShell)
  33. )
  34. {
  35. }
  36. }
  37. }