HumanResourcesSetupActions.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. using Comal.Classes;
  2. using InABox.Configuration;
  3. using InABox.Core;
  4. using InABox.DynamicGrid;
  5. using InABox.Wpf;
  6. using PRSDesktop.Components.Spreadsheet;
  7. using PRSStores.AssignmentCosting;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. namespace PRSDesktop;
  13. public static class HumanResourcesSetupActions
  14. {
  15. public static void SecurityGroups(IPanelHost host)
  16. {
  17. host.CreateSetupActionIfCanView<SecurityGroup>("Security Groups", PRSDesktop.Resources.securitygroup, (action) =>
  18. {
  19. var list = new MasterList(typeof(SecurityGroup));
  20. list.ShowDialog();
  21. Security.Reset();
  22. });
  23. }
  24. public static void EmployeeGroups(IPanelHost host)
  25. {
  26. host.CreateSetupActionIfCanView<EmployeeGroup>("Employee Groups", PRSDesktop.Resources.employees, (action) =>
  27. {
  28. var list = new MasterList(typeof(EmployeeGroup));
  29. list.ShowDialog();
  30. });
  31. }
  32. public static void EmployeePositions(IPanelHost host)
  33. {
  34. host.CreateSetupActionIfCanView<EmployeePosition>("Positions", PRSDesktop.Resources.position, (action) =>
  35. {
  36. var list = new MasterList(typeof(EmployeePosition));
  37. list.ShowDialog();
  38. });
  39. }
  40. public static void EmployeeRoles(IPanelHost host)
  41. {
  42. host.CreateSetupActionIfCanView<EmployeeRole>("Roles", PRSDesktop.Resources.employeerole, (action) =>
  43. {
  44. var list = new MasterList(typeof(Role));
  45. list.ShowDialog();
  46. });
  47. }
  48. public static void EmployeeTeams(IPanelHost host)
  49. {
  50. host.CreateSetupActionIfCanView<EmployeeTeam>("Teams", PRSDesktop.Resources.team, (action) =>
  51. {
  52. var list = new MasterList(typeof(Team));
  53. list.ShowDialog();
  54. });
  55. }
  56. public static void EmployeeActivities(IPanelHost host)
  57. {
  58. host.CreateSetupActionIfCanView<Activity>("Activities", PRSDesktop.Resources.quality, (action) =>
  59. {
  60. var list = new MasterList(typeof(Activity));
  61. list.ShowDialog();
  62. });
  63. }
  64. public static void EmployeeQualifications(IPanelHost host)
  65. {
  66. host.CreateSetupActionIfCanView<Qualification>("Qualifications", PRSDesktop.Resources.certificate, (action) =>
  67. {
  68. var list = new MasterList(typeof(Qualification));
  69. list.ShowDialog();
  70. });
  71. }
  72. public static void EmployeeRosters(IPanelHost host)
  73. {
  74. host.CreateSetupActionIfCanView<EmployeeRoster>("Rosters", PRSDesktop.Resources.assignments, (action) =>
  75. {
  76. var list = new MasterList(typeof(EmployeeRoster));
  77. list.ShowDialog();
  78. });
  79. }
  80. public static void EmployeeOvertimeRules(IPanelHost host)
  81. {
  82. host.CreateSetupActionIfCanView<OvertimeRule>("Overtime Rules", PRSDesktop.Resources.overtime, (action) =>
  83. {
  84. var list = new MasterList(typeof(OvertimeRule));
  85. list.ShowDialog();
  86. });
  87. }
  88. public static void EmployeeOvertime(IPanelHost host)
  89. {
  90. host.CreateSetupActionIfCanView<Overtime>("Overtime", PRSDesktop.Resources.overtime, (action) =>
  91. {
  92. var list = new MasterList(typeof(Overtime));
  93. list.ShowDialog();
  94. });
  95. }
  96. public static void LeaveRequestApprovals(IPanelHost host)
  97. {
  98. host.CreateSetupActionIfCanView<StandardLeave>("Leave Request Approvals", PRSDesktop.Resources.leave, (action) =>
  99. {
  100. var list = new MasterList(typeof(LeaveRequestApprovalSet));
  101. list.ShowDialog();
  102. });
  103. }
  104. public static void EmployeeStandardLeave(IPanelHost host)
  105. {
  106. host.CreateSetupActionIfCanView<StandardLeave>("Standard Leave", PRSDesktop.Resources.fireworks, (action) =>
  107. {
  108. var list = new MasterList(typeof(StandardLeave));
  109. list.ShowDialog();
  110. });
  111. }
  112. public static void EmployeeSpreadsheetTemplates(IPanelHost host)
  113. {
  114. host.CreateSetupActionIfCanView<EmployeeSpreadsheet>("Spreadsheet Templates", PRSDesktop.Resources.box, (action) =>
  115. {
  116. SpreadsheetTemplateGrid.ViewSpreadsheetTemplates<Employee>();
  117. });
  118. }
  119. public static void AssignmentCostingSettings(IPanelHost host)
  120. {
  121. host.CreateSetupActionIf<CanConfigureAssignmentCosting>("Assignment Costing Settings", PRSDesktop.Resources.edit, (action) =>
  122. {
  123. var settings = new GlobalConfiguration<AssignmentCostSettings>().Load();
  124. if (DynamicGridUtils.EditObject(settings, customiseGrid: grid =>
  125. {
  126. grid.OnCustomiseEditor += Grid_OnCustomiseEditor;
  127. }))
  128. {
  129. new GlobalConfiguration<AssignmentCostSettings>().Save(settings);
  130. }
  131. });
  132. }
  133. private static void Grid_OnCustomiseEditor(IDynamicEditorForm sender, AssignmentCostSettings[]? items, DynamicGridColumn column, BaseEditor editor)
  134. {
  135. if (items?.FirstOrDefault() is not AssignmentCostSettings settings) return;
  136. if(column.ColumnName == nameof(AssignmentCostSettings.Script) && editor is ScriptEditor scriptEditor)
  137. {
  138. scriptEditor.Type = ScriptEditorType.TemplateEditor;
  139. scriptEditor.OnEditorClicked += () =>
  140. {
  141. var script = settings.Script.NotWhiteSpaceOr()
  142. ?? AssignmentCostingUtils.DefaultScript();
  143. var editor = new ScriptEditorWindow(script, SyntaxLanguage.CSharp);
  144. if (editor.ShowDialog() == true)
  145. {
  146. sender.SetEditorValue(column.ColumnName, editor.Script);
  147. settings.Script = editor.Script;
  148. }
  149. };
  150. }
  151. }
  152. }