LeaveSelectionPage.cs 1.6 KB

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