浏览代码

PRS MOBILE - Digital Forms allow delete, corrected sorting of multiple list of forms

Nick 2 年之前
父节点
当前提交
539d031a9a

+ 1 - 2
prs.mobile/comal.timesheets.Android/Resources/Resource.designer.cs

@@ -2,7 +2,6 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     This code was generated by a tool.
-//     Runtime Version:4.0.30319.42000
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     the code is regenerated.
@@ -15,7 +14,7 @@ namespace comal.timesheets.Droid
 {
 	
 	
-	[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "13.2.0.93")]
+	[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "13.1.0.5")]
 	public partial class Resource
 	{
 		

+ 27 - 9
prs.mobile/comal.timesheets.iOS/comal.timesheets.iOS.csproj

@@ -1265,15 +1265,33 @@
     <ImageAsset Include="Assets.xcassets\shoppingcart.imageset\shoppingcart-1.pdf">
       <Visible>false</Visible>
     </ImageAsset>
-    <ImageAsset Include="Assets.xcassets\Contents.json" />
-    <ImageAsset Include="Assets.xcassets\rightarrowwhite.imageset\rightarrowwhite 2.pdf" />
-    <ImageAsset Include="Assets.xcassets\rightarrowwhite.imageset\rightarrowwhite 1.pdf" />
-    <ImageAsset Include="Assets.xcassets\rightarrowwhite.imageset\rightarrowwhite.pdf" />
-    <ImageAsset Include="Assets.xcassets\rightarrowwhite.imageset\Contents.json" />
-    <ImageAsset Include="Assets.xcassets\downarrowwhite.imageset\downarrowwhite 1.pdf" />
-    <ImageAsset Include="Assets.xcassets\downarrowwhite.imageset\downarrowwhite 2.pdf" />
-    <ImageAsset Include="Assets.xcassets\downarrowwhite.imageset\downarrowwhite.pdf" />
-    <ImageAsset Include="Assets.xcassets\downarrowwhite.imageset\Contents.json" />
+    <ImageAsset Include="Assets.xcassets\Contents.json">
+      <Visible>false</Visible>
+    </ImageAsset>
+    <ImageAsset Include="Assets.xcassets\rightarrowwhite.imageset\rightarrowwhite 2.pdf">
+      <Visible>false</Visible>
+    </ImageAsset>
+    <ImageAsset Include="Assets.xcassets\rightarrowwhite.imageset\rightarrowwhite 1.pdf">
+      <Visible>false</Visible>
+    </ImageAsset>
+    <ImageAsset Include="Assets.xcassets\rightarrowwhite.imageset\rightarrowwhite.pdf">
+      <Visible>false</Visible>
+    </ImageAsset>
+    <ImageAsset Include="Assets.xcassets\rightarrowwhite.imageset\Contents.json">
+      <Visible>false</Visible>
+    </ImageAsset>
+    <ImageAsset Include="Assets.xcassets\downarrowwhite.imageset\downarrowwhite 1.pdf">
+      <Visible>false</Visible>
+    </ImageAsset>
+    <ImageAsset Include="Assets.xcassets\downarrowwhite.imageset\downarrowwhite 2.pdf">
+      <Visible>false</Visible>
+    </ImageAsset>
+    <ImageAsset Include="Assets.xcassets\downarrowwhite.imageset\downarrowwhite.pdf">
+      <Visible>false</Visible>
+    </ImageAsset>
+    <ImageAsset Include="Assets.xcassets\downarrowwhite.imageset\Contents.json">
+      <Visible>false</Visible>
+    </ImageAsset>
   </ItemGroup>
   <ItemGroup>
     <Reference Include="System" />

+ 11 - 11
prs.mobile/comal.timesheets/DigitalForms/DataModels/FormPickerQueryLoader.cs

@@ -49,21 +49,21 @@ namespace comal.timesheets
                 {
                     shells.Add(CreateShell(row));
                 }
-                OrderShells(shells, filter);
+                //OrderShells(shells, filter);
             }
             return shells;
         }
 
-        private List<ExistingFormShell> OrderShells(List<ExistingFormShell> shells, Filter<TInstance> filter)
-        {
-            if (filter == completeFilter)
-                shells.Sort((x, y) => y.DateCompleted.CompareTo(x.DateCompleted)); //descending
-            else if (filter == incompleteFilter)
-                shells.Sort((x, y) => x.DateStarted.CompareTo(y.DateStarted));
+        //private List<ExistingFormShell> OrderShells(List<ExistingFormShell> shells, Filter<TInstance> filter)
+        //{
+        //    if (filter == completeFilter)
+        //        shells.Sort((x, y) => y.DateCompleted.CompareTo(x.DateCompleted)); //descending
+        //    else if (filter == incompleteFilter)
+        //        shells.Sort((x, y) => x.DateStarted.CompareTo(y.DateStarted));
+
+        //    return shells;
+        //}
 
-            return shells;
-        }
-     
         private ExistingFormShell CreateShell(CoreRow row)
         {
             var instance = row.ToObject<TInstance>();
@@ -83,4 +83,4 @@ namespace comal.timesheets
             return shell;
         }
     }
-}
+}

+ 13 - 2
prs.mobile/comal.timesheets/DigitalForms/DigitalFormPickerScreen/DigitalFormsPicker.xaml

@@ -150,8 +150,19 @@
                                                     <RowDefinition Height="auto"/>
                                                     <RowDefinition Height="auto"/>
                                                 </Grid.RowDefinitions>
-                                                <Label Grid.Row="0" Text="{Binding Description}" FontAttributes="Bold"/>
-                                                <Label Grid.Row="1" Text="{Binding Started}"/>
+                                                <Grid.ColumnDefinitions>
+                                                    <ColumnDefinition Width="*"/>
+                                                    <ColumnDefinition Width="auto"/>
+                                                </Grid.ColumnDefinitions>
+                                                <Label Grid.Row="0" Grid.Column="0" Text="{Binding Description}" FontAttributes="Bold"/>
+                                                <Label Grid.Row="1" Grid.Column="0" Text="{Binding Started}"/>
+
+                                                <Image Grid.Row="0" Grid.Column="1" VerticalOptions="Start" HorizontalOptions="End"
+                                                       HeightRequest="20" WidthRequest="20" Source="closee.png" Margin="5, 5, 7, 5">
+                                                    <Image.GestureRecognizers>
+                                                        <TapGestureRecognizer Tapped="Delete_Tapped" CommandParameter="{Binding .}"/>
+                                                    </Image.GestureRecognizers>
+                                                </Image>
                                             </Grid>
                                         </Frame>
                                     </ViewCell>

+ 56 - 2
prs.mobile/comal.timesheets/DigitalForms/DigitalFormPickerScreen/DigitalFormsPicker.xaml.cs

@@ -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)
         {