Przeglądaj źródła

PRS MOBILE - share task function

Nick-PRSDigital@bitbucket.org 2 lat temu
rodzic
commit
47bfebdb65

+ 1 - 1
prs.mobile/comal.timesheets/Grids/KanbanGrid.cs

@@ -76,7 +76,7 @@ namespace comal.timesheets
             return shells;
         }
 
-        private string GenerateDetail(CoreRow row)
+        public static string GenerateDetail(CoreRow row)
         {
             string detail = "";
 

+ 3 - 0
prs.mobile/comal.timesheets/Tasks/AddEditTask.xaml

@@ -20,6 +20,9 @@
                 <StackLayout Spacing="10">
                     <!--Inner StackLayout start-->
 
+                    <Button  Text="Share" FontSize="Medium"  x:Name="shareBtn" Clicked="ShareBtn_Clicked" IsVisible="false"
+                             HorizontalOptions="CenterAndExpand" Padding="3" TextColor="White" BackgroundColor="#15C7C1" FontAttributes="Bold"/>
+
                     <!--Row 0 Title-->
                     <Label Text="Title:" FontSize="Medium" FontAttributes="Bold" Margin="5" HorizontalTextAlignment="Start" VerticalTextAlignment="Center"/>
                     <Frame Padding="10" BorderColor="#15C7C1" CornerRadius="5">

+ 24 - 0
prs.mobile/comal.timesheets/Tasks/AddEditTask.xaml.cs

@@ -19,6 +19,9 @@ using InABox.Mobile;
 using System.IO;
 using comal.timesheets.QAForms;
 using comal.timesheets.CustomControls;
+using PRSSecurity = InABox.Core.Security;
+using static Android.Content.ClipData;
+using Xamarin.Essentials;
 //using static Android.Provider.MediaStore;
 
 namespace comal.timesheets.Tasks
@@ -56,6 +59,8 @@ namespace comal.timesheets.Tasks
             else
             {
                 ExistingKanbanTrack();
+                if (PRSSecurity.IsAllowed<CanShareTaskDetails>())
+                    shareBtn.IsVisible = true;
             }
 
         }
@@ -246,6 +251,25 @@ namespace comal.timesheets.Tasks
         #endregion
 
         #region Fields Changed
+        private async void ShareBtn_Clicked(object sender, EventArgs e)
+        {
+            try
+            {
+                CoreTable table = new Client<Kanban>().Query(new Filter<Kanban>(x => x.ID).IsEqualTo(kanbanID));
+                if (table.Rows.Any())
+                {
+                    var detail = KanbanGrid.GenerateDetail(table.Rows.First());
+                    var message = new EmailMessage
+                    {
+                        Subject = "Task Details shared from: " + GlobalVariables.EmpName,
+                        Body = detail,
+                    };
+
+                    await Xamarin.Essentials.Email.ComposeAsync(message);
+                }
+            }
+            catch { }
+        }
         private void TitleEdt_Changed(object sender, EventArgs e)
         {
             kanban.Title = titleEdt.Text;