Browse Source

PRS MOBILE - fixes for Job-only employee view

Nick-PRSDigital@bitbucket.org 2 years ago
parent
commit
9ae4a4081d

+ 1 - 0
prs.mobile/comal.timesheets/CustomControls/Pages/Selection Screens/JobSelectionPage.xaml.cs

@@ -32,6 +32,7 @@ namespace comal.timesheets.CustomControls
             {
                 List<string> descriptions = new List<string>();
                 List<Button> buttons = new List<Button>();
+
                 foreach (JobShell job in GlobalVariables.JobShells)
                 {
                     if (!descriptions.Contains(job.JobStatusDescription))

+ 21 - 2
prs.mobile/comal.timesheets/Data Classes/CacheLoader.cs

@@ -4,6 +4,7 @@ using InABox.Clients;
 using InABox.Core;
 using System;
 using System.Collections.Generic;
+using System.Linq;
 using System.Threading.Tasks;
 using Xamarin.Forms;
 using PRSSecurity = InABox.Core.Security;
@@ -22,8 +23,14 @@ namespace comal.timesheets
                     List<JobShell> jobShells = new List<JobShell>();
 
                     if (GlobalVariables.IsJobOnlyEmployee)
-                        foreach (var job in GlobalVariables.EmployeeJobs)
-                            jobShells.Add(job);
+                    {
+                        CoreTable table = new Client<JobEmployee>().Query(new Filter<JobEmployee>(x => x.EmployeeLink.ID).IsEqualTo(GlobalVariables.EmpID));
+                        if (!table.Rows.Any())
+                            return;
+
+                        foreach (CoreRow row in table.Rows)
+                            jobShells.Add(AddJobShell(row));
+                    }
 
                     else
                         foreach (CoreRow row in DoJobsQuery(AssignFilter()).Rows)
@@ -86,6 +93,7 @@ namespace comal.timesheets
                 JobStatusDescription = job.JobStatus.Description,
                 Color = Color.FromHex(job.Color)
             };
+
             if (jobshell.JobStatusDescription.Equals("Active Projects"))
                 jobshell.JobStatusDescription = "Active";
             else if (jobshell.JobStatusDescription.Equals("Projects - Hidden from View"))
@@ -97,6 +105,17 @@ namespace comal.timesheets
 
             return jobshell;
         }
+
+        private static JobShell AddJobShell(CoreRow row)
+        {
+            JobShell job = new JobShell();
+            job.ID = row.Get<JobEmployee, Guid>(x => x.JobLink.ID);
+            job.JobNumber = row.Get<JobEmployee, string>(x => x.JobLink.JobNumber);
+            job.Name = row.Get<JobEmployee, string>(x => x.JobLink.Name);
+            job.JobStatusDescription = row.Get<JobEmployee, string>(x => x.JobLink.JobStatus.Description);
+            job.DisplayName = "(" + job.JobNumber + ") " + job.Name;
+            return job;
+        }
         #endregion
     }
 }

+ 1 - 0
prs.mobile/comal.timesheets/Main/MainPageUtils.cs

@@ -80,6 +80,7 @@ namespace comal.timesheets
             job.ID = row.Get<JobEmployee, Guid>(x => x.JobLink.ID);
             job.JobNumber = row.Get<JobEmployee, string>(x => x.JobLink.JobNumber);
             job.Name = row.Get<JobEmployee, string>(x => x.JobLink.Name);
+            job.JobStatusDescription = row.Get<JobEmployee, string>(x => x.JobLink.JobStatus.Description);
             return job;
         }