Sfoglia il codice sorgente

Moved Employee Qualifications Export button

Kenric Nugteren 2 anni fa
parent
commit
3163984597

+ 27 - 11
prs.desktop/Dashboards/HumanResources/EmployeeQualificationDashboard.xaml.cs

@@ -97,7 +97,7 @@ namespace PRSDesktop
     /// <summary>
     /// Interaction logic for EmployeeQualificationDashboard.xaml
     /// </summary>
-    public partial class EmployeeQualificationDashboard : UserControl, IDashboardWidget<HumanResources, EmployeeQualificationDashboardProperties>, IRequiresCanView<EmployeeQualification>, IActionsDashboard
+    public partial class EmployeeQualificationDashboard : UserControl, IDashboardWidget<HumanResources, EmployeeQualificationDashboardProperties>, IRequiresCanView<EmployeeQualification>, IHeaderDashboard
     {
         private DataTable DataTable;
         private CoreTable CoreTable;
@@ -124,6 +124,9 @@ namespace PRSDesktop
                 .Or(x => x.FinishDate).IsGreaterThan(DateTime.Now));
         
         public EmployeeQualificationDashboardProperties Properties { get; set; }
+
+        public DashboardHeader Header { get; set; } = new();
+
         public event LoadSettings<EmployeeQualificationDashboardProperties>? LoadSettings;
         public event SaveSettings<EmployeeQualificationDashboardProperties>? SaveSettings;
 
@@ -261,7 +264,7 @@ namespace PRSDesktop
 
             var employees = results[nameof(Employee)].ToObjects<Employee>().ToDictionary(
                 x => x.ID,
-                x => IsEmployeeActive(x));
+                IsEmployeeActive);
             if (Properties.Employees is not null)
             {
                 employees = employees
@@ -283,6 +286,8 @@ namespace PRSDesktop
             Qualifications = qualifications;
 
             DataGrid.CellDoubleTapped += DataGrid_CellDoubleTapped;
+
+            SetupHeader();
         }
 
         public void Shutdown()
@@ -291,7 +296,26 @@ namespace PRSDesktop
 
         #endregion
 
-        #region Actions
+        #region Header
+
+        public void SetupHeader()
+        {
+            var exportButton = new Button
+            {
+                Content = "Export",
+                Padding = new Thickness(5)
+            };
+            exportButton.Click += (o, e) =>
+            {
+                DoExport();
+            };
+
+            Header.BeginUpdate()
+                .Clear()
+                .AddRight(exportButton);
+
+            Header.EndUpdate();
+        }
 
         private void DoExport()
         {
@@ -328,14 +352,6 @@ namespace PRSDesktop
             ExcelExporter.DoExport(newTable, "EmployeeQualifications");
         }
 
-        public void BuildActionsMenu(ContextMenu menu)
-        {
-            if (Security.CanExport<EmployeeQualification>())
-            {
-                menu.AddItem("Export", null, DoExport);
-            }
-        }
-
         #endregion
 
         #region Grid Events