|
@@ -78,7 +78,7 @@ namespace comal.timesheets
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- Task.Run(()=>
|
|
|
+ Task.Run(() =>
|
|
|
{
|
|
|
types.Add("All");
|
|
|
|
|
@@ -98,7 +98,7 @@ namespace comal.timesheets
|
|
|
filterOptionsControl.OnFilterOptionChanged += FilterOptionsControl_OnFilterOptionChanged;
|
|
|
|
|
|
firstLoad = false;
|
|
|
- });
|
|
|
+ });
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
@@ -261,6 +261,8 @@ namespace comal.timesheets
|
|
|
completeForms.Add(v);
|
|
|
}
|
|
|
}
|
|
|
+ SortForms(completeForms, FormCompletion.Complete);
|
|
|
+ SortForms(incompleteForms, FormCompletion.Incomplete);
|
|
|
Device.BeginInvokeOnMainThread(() =>
|
|
|
{
|
|
|
ShowOrHideIncompleteFormsNotifications();
|
|
@@ -271,6 +273,20 @@ namespace comal.timesheets
|
|
|
//});
|
|
|
}
|
|
|
|
|
|
+ enum FormCompletion
|
|
|
+ {
|
|
|
+ Incomplete,
|
|
|
+ Complete
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SortForms(List<ExistingFormShell> shells, FormCompletion completion)
|
|
|
+ {
|
|
|
+ if (completion == FormCompletion.Complete && shells.Count > 0)
|
|
|
+ shells.Sort((x, y) => y.DateCompleted.CompareTo(x.DateCompleted)); //descending
|
|
|
+ else if (completion == FormCompletion.Incomplete && shells.Count > 0)
|
|
|
+ shells.Sort((x, y) => x.DateStarted.CompareTo(y.DateStarted)); //ascending
|
|
|
+ }
|
|
|
+
|
|
|
private void ShowOrHideIncompleteFormsNotifications()
|
|
|
{
|
|
|
if (incompleteForms.Count > 0)
|
|
@@ -415,6 +431,44 @@ namespace comal.timesheets
|
|
|
searchEnt.Text = "";
|
|
|
}
|
|
|
|
|
|
+ private async void Delete_Tapped(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ var item = ((TappedEventArgs)e).Parameter as ExistingFormShell;
|
|
|
+ if (item == null) return;
|
|
|
+
|
|
|
+ string chosenOption = await DisplayActionSheet("Delete Form?", "Cancel", null, "Yes", "No");
|
|
|
+ switch (chosenOption)
|
|
|
+ {
|
|
|
+ case "Yes":
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ DeleteForm(item);
|
|
|
+ LoadExistingForms();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void DeleteForm(ExistingFormShell item)
|
|
|
+ {
|
|
|
+ if (item.Type == typeof(KanbanForm))
|
|
|
+ DeleteKanbanForm(item.ID);
|
|
|
+ if (item.Type == typeof(JobForm))
|
|
|
+ DeleteJobForm(item.ID);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void DeleteJobForm(Guid id)
|
|
|
+ {
|
|
|
+ JobForm form = new JobForm { ID = id };
|
|
|
+ new Client<JobForm>().Delete(form, "Deleted from Mobile App - My Forms section");
|
|
|
+ }
|
|
|
+
|
|
|
+ private void DeleteKanbanForm(Guid id)
|
|
|
+ {
|
|
|
+ KanbanForm form = new KanbanForm { ID = id };
|
|
|
+ new Client<KanbanForm>().Delete(form, "Deleted from Mobile App - My Forms section");
|
|
|
+ }
|
|
|
+
|
|
|
#region Loading From History Section
|
|
|
private void LayoutsList_Tapped(object sender, EventArgs e)
|
|
|
{
|