瀏覽代碼

PRS MOBILE - view leave form from notification

Nick-PRSDigital@bitbucket.org 2 年之前
父節點
當前提交
0d61fe675e

+ 0 - 1
prs.mobile/comal.timesheets/Assignments/AssignmentList.xaml.cs

@@ -8,7 +8,6 @@ using Xamarin.Forms;
 using System.Linq;
 using System.Threading.Tasks;
 using System.Windows.Input;
-using ARKit;
 using InABox.Configuration;
 using Syncfusion.SfSchedule.XForms;
 using WebSocketSharp;

+ 68 - 37
prs.mobile/comal.timesheets/NotificationsManager/NotificationList.xaml.cs

@@ -1,26 +1,12 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using System.Text;
 using System.Threading.Tasks;
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using System.Threading;
-using System.Linq;
 using Xamarin.Forms;
-using XF.Material.Forms.UI;
-using XF.Material.Forms.UI.Dialogs;
 using InABox.Core;
 using InABox.Clients;
 using Comal.Classes;
-using System.IO;
-using Plugin.Media;
-using InABox.Mobile;
-using System.Linq.Expressions;
-using Xamarin.Forms;
 using Xamarin.Forms.Xaml;
-using comal.timesheets.CustomControls;
 using comal.timesheets.Tasks;
 
 namespace comal.timesheets
@@ -44,9 +30,9 @@ namespace comal.timesheets
             LoadData();
             base.OnAppearing();
         }
-        private async void LoadData()
+        private void LoadData()
         {
-            await Task.Run(() =>
+            Task.Run(() =>
             {
                 notificationShells.Clear();
                 var table = new Client<Notification>().Query(
@@ -92,7 +78,7 @@ namespace comal.timesheets
                 }
             });
         }
-        void LoadPaperClips()
+        private void LoadPaperClips()
         {
             Task.Run(() =>
             {
@@ -118,44 +104,89 @@ namespace comal.timesheets
         #endregion
 
         #region Buttons / Taps
-        async void NotificationListView_Tapped(object sender, EventArgs e)
+        private void NotificationListView_Tapped(object sender, EventArgs e)
         {
             NotificationShell shell = notificationListView.SelectedItem as NotificationShell;
-            string extra = "";
-            if (!string.IsNullOrWhiteSpace(shell.EntityType))
-            {
-                if (shell.EntityType == "Comal.Classes.Kanban")
-                    extra = "View Task";
-                if (shell.EntityType == "Comal.Classes.LeaveRequest")
-                    extra = "View Leave";
-            }
-            string chosenOption = await DisplayActionSheet(shell.Description, "Cancel", null, "View / Reply Message", "Dismiss Message", extra);
+            string extra = CreateOption(shell);
+            string chosenOption = ChooseOption(extra, shell).Result;
+            ProcessOption(chosenOption, shell);
+        }
+
+        private void ProcessOption(string chosenOption, NotificationShell shell)
+        {
             switch (chosenOption)
             {
                 case "Cancel":
                     return;
                 case "View / Reply Message":
-                    using (await MaterialDialog.Instance.LoadingDialogAsync(message: "Loading"))
-                    {
-                        NewReplyNotification newReplyNotification = new NewReplyNotification(shell.ID);
-                        Navigation.PushAsync(newReplyNotification);
-                    }
+                    ReplyNotification(shell);
                     break;
                 case "Dismiss Message":
                     DismissNotification(shell);
                     break;
                 case "View Task":
-                    AddEditTask taskPage = new AddEditTask(shell.EntityID);
-                    Navigation.PushAsync(taskPage);
+                    ViewTask(shell);
                     break;
                 case "View Leave":
-                    LeaveRequestList leaveRequestList = new LeaveRequestList();
-                    Navigation.PushAsync(leaveRequestList);
+                    OpenLeaveList();
+                    break;
+                case "View Request Form":
+                    ViewRequestForm(shell);
                     break;
                 default:
                     return;
             }
         }
+
+        private void ViewRequestForm(NotificationShell shell)
+        {
+            DigitalFormHostModel<LeaveRequest, LeaveRequestLink, LeaveRequestForm> model = new DigitalFormHostModel<LeaveRequest, LeaveRequestLink, LeaveRequestForm>();
+            LeaveRequest request = new LeaveRequest();
+            request.ID = shell.EntityID;
+            LeaveRequestForm form = new Client<LeaveRequestForm>().Query(new Filter<LeaveRequestForm>(x => x.Parent.ID).IsEqualTo(shell.EntityID)).Rows.FirstOrDefault().ToObject<LeaveRequestForm>();
+            DigitalFormLayout digitalFormLayout = new Client<DigitalFormLayout>().Query(new Filter<DigitalFormLayout>(x => x.Form.ID).IsEqualTo(form.Form.ID).And(x => x.Type).IsEqualTo(DFLayoutType.Mobile)).Rows.FirstOrDefault().ToObject<DigitalFormLayout>();
+            model.LoadItems(request, form, digitalFormLayout);
+            DigitalFormHost host = new DigitalFormHost(model);
+            Navigation.PushAsync(host);
+        }
+
+        private void ReplyNotification(NotificationShell shell)
+        {
+            NewReplyNotification newReplyNotification = new NewReplyNotification(shell.ID);
+            Navigation.PushAsync(newReplyNotification);
+        }
+
+        private void ViewTask(NotificationShell shell)
+        {
+            AddEditTask taskPage = new AddEditTask(shell.EntityID);
+            Navigation.PushAsync(taskPage);
+        }
+
+        private void OpenLeaveList()
+        {
+            LeaveRequestList leaveRequestList = new LeaveRequestList();
+            Navigation.PushAsync(leaveRequestList);
+        }
+
+        private string CreateOption(NotificationShell shell)
+        {
+            if (!string.IsNullOrWhiteSpace(shell.EntityType))
+                return "";
+            if (shell.EntityType == "Comal.Classes.Kanban")
+                return "View Task";
+            if (shell.EntityType == "Comal.Classes.LeaveRequest")
+                return "View Leave";
+            if (shell.EntityType == "Comal.Classes.LeaveRequestLink")
+                return "View Request Form";
+            else
+                return "";
+        }
+
+        private async Task<string> ChooseOption(string extra, NotificationShell shell)
+        {
+            string chosenOption = await DisplayActionSheet(shell.Description, "Cancel", null, "View / Reply Message", "Dismiss Message", extra);
+            return chosenOption;
+        }
         protected override void OnDisappearing()
         {
             NotificationsClosed?.Invoke(notificationShells.Count());
@@ -199,7 +230,7 @@ namespace comal.timesheets
                 notification.Closed = DateTime.Now;
                 new Client<Notification>().Save(notification, "Dismissed on mobile device");
             });
-        }      
+        }
         void RefreshListOnMainThread()
         {
             Device.BeginInvokeOnMainThread(() =>

+ 1 - 1
prs.mobile/comal.timesheets/StoreRequis/StoreRequiConfirmationPage.xaml.cs

@@ -478,7 +478,7 @@ namespace comal.timesheets.StoreRequis
                 item.Product.ID = itemShell.ProductID;
                 item.Product.Code = itemShell.ProductCode;
                 item.Product.Name = itemShell.ProductName;
-                item.Holding.ID = itemShell.HoldingID;
+                item.Location.ID = itemShell.HoldingID;
                 item.Quantity = itemShell.Quantity;
                 item.Description = item.Product.Name;
                 item.Code = item.Product.Code;

+ 2 - 5
prs.mobile/comal.timesheets/StoreRequis/StoreRequiScannerPage.xaml.cs

@@ -5,9 +5,6 @@ using System.Text;
 using System.Threading.Tasks;
 using Xamarin.Essentials;
 using Xamarin.Forms;
-using ZXing;
-using ZXing;
-using Xamarin.Forms;
 using Xamarin.Forms.Xaml;
 using comal.timesheets.CustomControls;
 using Comal.Classes;
@@ -141,8 +138,8 @@ namespace comal.timesheets
                        x => x.Product.Name, //2
                        x => x.Product.Code, //3
                        x => x.Quantity, //4
-                       x => x.Holding.ID, //5
-                       x => x.Holding.Location.Description //6
+                       x => x.Location.ID, //5
+                       x => x.Location.Description //6
                        )
                    );
                 if (table.Rows.Any())

+ 2 - 2
prs.mobile/comal.timesheets/StoreRequis/StoreRequisMainPage.xaml.cs

@@ -249,8 +249,8 @@ namespace comal.timesheets.StoreRequis
                 }
                 else
                 {
-                    itemLocation = requisitionItem.Holding.Location.Description;
-                    holdingID = requisitionItem.Holding.ID;
+                    itemLocation = requisitionItem.Location.Description;
+                    holdingID = requisitionItem.Location.ID;
                 }
 
                 StoreRequiItem storeRequiItem = new StoreRequiItem(product, processedResultQtyTuple.Item2, itemLocation, holdingID) //default qty is 1