LeaveRequestPanel.xaml.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. }
  29. public string SectionName => "Leave Requests";
  30. public DataModel DataModel(Selection selection)
  31. {
  32. var ids = LeaveRequests.ExtractValues(x => x.ID, selection).ToArray();
  33. return new LeaveRequestDataModel(new Filter<LeaveRequest>(x => x.ID).InList(ids));
  34. }
  35. public void Heartbeat(TimeSpan time)
  36. {
  37. }
  38. public void Refresh()
  39. {
  40. if (LeavePages.SelectedIndex == 0)
  41. LeaveCalendar.Refresh();
  42. else if (LeavePages.SelectedIndex == 1)
  43. LeaveRequests.Refresh(false, true);
  44. }
  45. public Dictionary<string, object[]> Selected()
  46. {
  47. return LeaveRequests.Selected();
  48. }
  49. public void Setup()
  50. {
  51. LeaveRequests.Refresh(true, false);
  52. }
  53. public void Shutdown(CancelEventArgs? cancel)
  54. {
  55. }
  56. private void LeavePages_SelectionChanged(object sender, SelectionChangedEventArgs e)
  57. {
  58. if (e.Source is DynamicTabControl)
  59. Refresh();
  60. }
  61. }