|
@@ -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(() =>
|