LeaveRequestPanel.xaml.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 InABox.Wpf;
  9. using System.ComponentModel;
  10. namespace PRSDesktop;
  11. /// <summary>
  12. /// Interaction logic for LeaveRequestPanel.xaml
  13. /// </summary>
  14. public partial class LeaveRequestPanel : UserControl, IPanel<LeaveRequest>
  15. {
  16. public LeaveRequestPanel()
  17. {
  18. InitializeComponent();
  19. }
  20. public bool IsReady { get; set; }
  21. public event DataModelUpdateEvent? OnUpdateDataModel;
  22. public void CreateToolbarButtons(IPanelHost host)
  23. {
  24. HumanResourcesSetupActions.EmployeeTeams(host);
  25. HumanResourcesSetupActions.EmployeeActivities(host);
  26. host.CreateSetupSeparator();
  27. HumanResourcesSetupActions.EmployeeStandardLeave(host);
  28. HumanResourcesSetupActions.LeaveRequestApprovals(host);
  29. }
  30. public string SectionName => "Leave Requests";
  31. public DataModel DataModel(Selection selection)
  32. {
  33. var ids = LeaveRequests.ExtractValues(x => x.ID, selection).ToArray();
  34. return new LeaveRequestDataModel(Filter<LeaveRequest>.Where(x => x.ID).InList(ids));
  35. }
  36. public void Heartbeat(TimeSpan time)
  37. {
  38. }
  39. public void Refresh()
  40. {
  41. if (LeavePages.SelectedIndex == 0)
  42. LeaveCalendar.Refresh();
  43. else if (LeavePages.SelectedIndex == 1)
  44. LeaveRequests.Refresh(false, true);
  45. }
  46. public Dictionary<string, object[]> Selected()
  47. {
  48. return LeaveRequests.Selected();
  49. }
  50. public void Setup()
  51. {
  52. LeaveRequests.Refresh(true, false);
  53. }
  54. public void Shutdown(CancelEventArgs? cancel)
  55. {
  56. }
  57. private void LeavePages_SelectionChanged(object sender, SelectionChangedEventArgs e)
  58. {
  59. if (e.Source is DynamicTabControl)
  60. Refresh();
  61. }
  62. }