LeaveRequestPanel.xaml.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Windows.Controls;
  5. using Comal.Classes;
  6. using InABox.Core;
  7. using InABox.DynamicGrid;
  8. using System.ComponentModel;
  9. namespace PRSDesktop;
  10. /// <summary>
  11. /// Interaction logic for LeaveRequestPanel.xaml
  12. /// </summary>
  13. public partial class LeaveRequestPanel : UserControl, IPanel<LeaveRequest>
  14. {
  15. public LeaveRequestPanel()
  16. {
  17. InitializeComponent();
  18. }
  19. public bool IsReady { get; set; }
  20. public event DataModelUpdateEvent? OnUpdateDataModel;
  21. public void CreateToolbarButtons(IPanelHost host)
  22. {
  23. }
  24. public string SectionName => "Leave Requests";
  25. public DataModel DataModel(Selection selection)
  26. {
  27. var ids = LeaveRequests.ExtractValues(x => x.ID, selection).ToArray();
  28. return new LeaveRequestDataModel(new Filter<LeaveRequest>(x => x.ID).InList(ids));
  29. }
  30. public void Heartbeat(TimeSpan time)
  31. {
  32. }
  33. public void Refresh()
  34. {
  35. if (LeavePages.SelectedIndex == 0)
  36. LeaveCalendar.Refresh();
  37. else if (LeavePages.SelectedIndex == 1)
  38. LeaveRequests.Refresh(false, true);
  39. }
  40. public Dictionary<string, object[]> Selected()
  41. {
  42. return LeaveRequests.Selected();
  43. }
  44. public void Setup()
  45. {
  46. LeaveRequests.Refresh(true, false);
  47. }
  48. public void Shutdown(CancelEventArgs? cancel)
  49. {
  50. }
  51. private void LeavePages_SelectionChanged(object sender, SelectionChangedEventArgs e)
  52. {
  53. if (e.Source is DynamicTabControl)
  54. Refresh();
  55. }
  56. }