Explorar o código

PRS MOBILE - Grid enhancements

Nick-PRSDigital@bitbucket.org %!s(int64=2) %!d(string=hai) anos
pai
achega
3314cc627f

+ 31 - 19
prs.mobile/comal.timesheets/Assignments/AssignmentForms.xaml.cs

@@ -4,19 +4,21 @@ using System.Linq;
 using System.Linq.Expressions;
 using System.Text;
 using System.Threading.Tasks;
+using comal.timesheets.QAForms;
 using Comal.Classes;
 using InABox.Clients;
 using InABox.Core;
 using Xamarin.Forms;
 using Xamarin.Forms.Xaml;
 using XF.Material.Forms.UI;
+using XF.Material.Forms.UI.Dialogs;
 
 namespace comal.timesheets
 {
     [XamlCompilation(XamlCompilationOptions.Compile)]
     public partial class AssignmentForms : ContentView, IAssignmentPage
     {
-        
+        List<Log> logs = new List<Log>();
         public AssignmentEditDataModel DataModel => BindingContext as AssignmentEditDataModel;
         
         public AssignmentForms()
@@ -31,27 +33,37 @@ namespace comal.timesheets
             Forms.ItemsSource = DataModel.Forms.ToArray();
         }
 
-        private void MaterialCard_OnClicked(object sender, EventArgs e)
+        private async void MaterialCard_OnClicked(object sender, EventArgs e)
         {
-            var instance = (sender as MaterialCard).BindingContext as AssignmentFormInstance;
-
-            var form = new Client<AssignmentForm>()
-                .Query(new Filter<AssignmentForm>(x => x.ID).IsEqualTo(instance.ID))
-                .Rows
-                .Select(x => x.ToObject<AssignmentForm>())
-                .FirstOrDefault();
-            
-            var model = new DigitalFormHostModel<Assignment, AssignmentLink, AssignmentForm>();
-            model.LoadItems(DataModel.Item.Entity, form, null);
-            var host = new DigitalFormHost(model);
-            host.OnClosing += (o, args) =>
+            logs.Add(new Log("Clicked", QAForms.MobileLogType.START));
+            using (await MaterialDialog.Instance.LoadingDialogAsync(message: "Loading"))
             {
-                if (args.Changed)
+                var instance = (sender as MaterialCard).BindingContext as AssignmentFormInstance;
+
+                var form = new Client<AssignmentForm>()
+                    .Query(new Filter<AssignmentForm>(x => x.ID).IsEqualTo(instance.ID))
+                    .Rows
+                    .Select(x => x.ToObject<AssignmentForm>())
+                    .FirstOrDefault();
+
+                
+                var model = new DigitalFormHostModel<Assignment, AssignmentLink, AssignmentForm>();
+                logs.Add(new Log("Load Items", QAForms.MobileLogType.START));
+                model.LoadItems(DataModel.Item.Entity, form, null);
+                logs.Add(new Log("Load Items", QAForms.MobileLogType.END));
+                var host = new DigitalFormHost(model);
+
+                host.OnClosing += (o, args) =>
                 {
-                    instance.Completed = !model.DigitalFormDataModel.Instance.FormCompleted.IsEmpty();
-                }
-            };
-            Navigation.PushAsync(host);           
+                    if (args.Changed)
+                    {
+                        instance.Completed = !model.DigitalFormDataModel.Instance.FormCompleted.IsEmpty();
+                    }
+                };
+                Navigation.PushAsync(host);
+            }
+            logs.Add(new Log("Clicked", QAForms.MobileLogType.END));
+            var log = Log.ProduceLog(logs);
         }
 
         private void AddForm_OnClicked(object sender, EventArgs e)

+ 25 - 0
prs.mobile/comal.timesheets/DataGridHost.xaml

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
+             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+             x:Class="comal.timesheets.DataGridHost">
+    <NavigationPage.TitleView>
+        <Grid Margin="0" Padding="0">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="*"/>
+                <ColumnDefinition Width="*"/>
+                <ColumnDefinition Width="*"/>
+            </Grid.ColumnDefinitions>
+            <Button Grid.Column="0" HorizontalOptions="Start" VerticalOptions="Center" TextColor="White" BackgroundColor="Transparent" Margin="0" Padding="0"
+                Text="Exit" Clicked="CancelBtn_Clicked"/>
+            <Label Grid.Column="1" VerticalOptions="Center" x:Name="titleLbl"
+                   HorizontalOptions="Center" HorizontalTextAlignment="Center" TextColor="White" FontSize="Medium" FontAttributes="Bold"/>
+            <Button Grid.Column="2" HorizontalOptions="End" VerticalOptions="Center" TextColor="White" BackgroundColor="Transparent" Margin="0" Padding="0"
+                    IsVisible="false" x:Name="saveBtn"
+                Text="Accept" Clicked="SaveBtn_Clicked"/>
+        </Grid>
+    </NavigationPage.TitleView>
+    <ContentPage.Content>
+        <StackLayout x:Name="stackLayout">
+        </StackLayout>
+    </ContentPage.Content>
+</ContentPage>

+ 42 - 0
prs.mobile/comal.timesheets/DataGridHost.xaml.cs

@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using Xamarin.Forms;
+using Xamarin.Forms.Xaml;
+
+namespace comal.timesheets
+{
+	[XamlCompilation(XamlCompilationOptions.Compile)]
+	public partial class DataGridHost : ContentPage
+	{
+		public DataGridHost (MobileDataGrid datagrid)
+		{
+			InitializeComponent ();
+            NavigationPage.SetHasBackButton(this, false);
+            datagrid.OnOptionsSet += Datagrid_OnTitleSet;
+            stackLayout.Children.Add(datagrid);
+        }
+
+        private void Datagrid_OnTitleSet(string title, DataGridSaveType savetype)
+        {
+            Device.BeginInvokeOnMainThread(() =>
+            {
+                titleLbl.Text = title + "s";
+                saveBtn.IsVisible = savetype == DataGridSaveType.None? false : true;
+            });
+        }
+
+        private void CancelBtn_Clicked(object sender, EventArgs e)
+        {
+            Navigation.PopAsync();
+        }
+
+        private void SaveBtn_Clicked(object sender, EventArgs e)
+        { 
+        
+        }
+    }
+}

+ 38 - 16
prs.mobile/comal.timesheets/DigitalForms/DataModels/DigitalFormHostModel.cs

@@ -23,7 +23,7 @@ namespace comal.timesheets
         public Entity Entity { get; set; }
         public bool ReadOnly { get; set; }
         public bool NewForm { get; set; }
-
+        List<Log> logs = new List<Log>();
         public event OnDigitalFormHostModelSaved OnDigitalFormHostModelSaved;
         public event OnDigitalFormHostModelBeforeSave OnDigitalFormHostModelBeforeSave;
 
@@ -62,7 +62,7 @@ namespace comal.timesheets
             var loadDFDataModel = Task.Run(() =>
             {
                 DigitalFormDataModel = new DigitalFormDataModel<TEntity, TEntityLink, TInstance>(parent.ID, form.ID);
-                DigitalFormDataModel.Load(null);
+                DigitalFormDataModel.Instance = GetInstance(form.ID);
                 Entity = DigitalFormDataModel.Entity;
             });
             Task.WaitAll(getLayout, loadDFDataModel);
@@ -87,7 +87,15 @@ namespace comal.timesheets
                 CheckEntity(SaveType.AfterSave);
                 OnDigitalFormHostModelSaved?.Invoke();
             };
+        }
 
+        private IDigitalFormInstance GetInstance(Guid iD)
+        {
+            return new Client<TInstance>().Query
+                (
+                new Filter<TInstance>(x => x.ID).IsEqualTo(iD)
+                )
+                .Rows.FirstOrDefault().ToObject<TInstance>();
         }
 
         public DigitalFormLayout QueryDigitalFormLayout(Entity form)
@@ -97,9 +105,15 @@ namespace comal.timesheets
                 new Filter<DigitalFormLayout>(x => x.Form.ID)
                     .IsEqualTo((form as EntityForm<TEntity, TEntityLink>).Form.ID)
                     //.And(x => x.Type).IsEqualTo(DFLayoutType.Mobile)
-                    .And(x => x.Active).IsEqualTo(true)
+                    .And(x => x.Active).IsEqualTo(true),
+                new Columns<DigitalFormLayout>(
+                    x => x.ID,
+                    x => x.Form.ID,
+                    x => x.Layout,
+                    x => x.Type
+                    )
             );
-            DigitalFormLayout layout = layouts.Rows.FirstOrDefault(r=>r.Get<DigitalFormLayout,DFLayoutType>(c=>c.Type) == DFLayoutType.Mobile)?.ToObject<DigitalFormLayout>();
+            DigitalFormLayout layout = layouts.Rows.FirstOrDefault(r => r.Get<DigitalFormLayout, DFLayoutType>(c => c.Type) == DFLayoutType.Mobile)?.ToObject<DigitalFormLayout>();
             if (layout == null)
                 layout = layouts.Rows.FirstOrDefault()?.ToObject<DigitalFormLayout>();
             return layout;
@@ -108,35 +122,43 @@ namespace comal.timesheets
         public List<DigitalFormVariable> QueryVariables(Entity form)
         {
             List<DigitalFormVariable> variables = new List<DigitalFormVariable>();
+
             var table = new Client<DigitalFormVariable>().Query(
                     new Filter<DigitalFormVariable>(x => x.Form.ID).IsEqualTo((form as EntityForm<TEntity, TEntityLink>).Form.ID),
                     new Columns<DigitalFormVariable>(x => x.Code, x => x.Parameters, x => x.Description, x => x.VariableType),
                     null
                     );
             foreach (CoreRow coreRow in table.Rows)
-            {
-                var variable = coreRow.ToObject<DigitalFormVariable>();
-                variables.Add(variable);
-            }
+                variables.Add(CreateVariable(coreRow));
+
             return variables;
         }
 
         public List<DigitalFormVariable> QueryVariables(DigitalFormLayout layout)
         {
             List<DigitalFormVariable> variables = new List<DigitalFormVariable>();
+
             var table = new Client<DigitalFormVariable>().Query(
                     new Filter<DigitalFormVariable>(x => x.Form.ID).IsEqualTo(layout.Form.ID),
                     new Columns<DigitalFormVariable>(x => x.Code, x => x.Parameters, x => x.Description, x => x.VariableType),
                     null
                     );
             foreach (CoreRow coreRow in table.Rows)
-            {
-                var variable = coreRow.ToObject<DigitalFormVariable>();
-                variables.Add(variable);
-            }
+                variables.Add(CreateVariable(coreRow));
+
             return variables;
         }
 
+        private DigitalFormVariable CreateVariable(CoreRow row)
+        {
+            DigitalFormVariable v = new DigitalFormVariable();
+            v.Code = row.Get<DigitalFormVariable, string>(x => x.Code);
+            v.Parameters = row.Get<DigitalFormVariable, string>(x => x.Parameters);
+            v.Description = row.Get<DigitalFormVariable, string>(x => x.Description);
+            v.VariableType = row.Get<DigitalFormVariable, string>(x => x.VariableType);
+            return v;
+        }
+
         public void SetPropertyValues(QAFormViewer viewer) //currently does not include Employee Forms
         {
             try
@@ -214,10 +236,10 @@ namespace comal.timesheets
 
         private void DoKanbanActions(SaveType saveType)
         {
-                if (saveType == SaveType.BeforeSave)
-                    CheckAndCreateKanban();
-                else if (saveType == SaveType.AfterSave)
-                    CheckSubscriber();
+            if (saveType == SaveType.BeforeSave)
+                CheckAndCreateKanban();
+            else if (saveType == SaveType.AfterSave)
+                CheckSubscriber();
         }
 
         private void CheckAndCreateKanban()

+ 1 - 1
prs.mobile/comal.timesheets/DigitalForms/DigitalFormHost.xaml.cs

@@ -51,7 +51,7 @@ namespace comal.timesheets
 
             Model.OnDigitalFormHostModelSaved += () =>
             {
-                DisplayAlert("Success", "Form completed: " + Model.DigitalFormDataModel.Instance.Form.Description, "OK");
+                DisplayAlert("Success", "Form completed " + Model.DigitalFormDataModel.Instance.Form.Description, "OK");
             };
 
             saveBtn.IsEnabled = !Model.ReadOnly;

+ 43 - 6
prs.mobile/comal.timesheets/DigitalForms/Renderer/QAFormViewer.cs

@@ -13,12 +13,36 @@ using Syncfusion.XForms.SignaturePad;
 using comal.timesheets.Tasks;
 using Comal.Classes;
 using PRSClasses;
-using Newtonsoft.Json;
-using Java.Security.Cert;
-using Xamarin.Essentials;
+using Org.BouncyCastle.Utilities;
 
 namespace comal.timesheets.QAForms
 {
+    public enum MobileLogType
+    {
+        START,
+        END
+    }
+    public class Log
+    {
+        public string Message { get; set; }
+
+        public Log(string message, MobileLogType type)
+        {
+            Message = type + " " + message + "(" + DateTime.Now.ToString("m.s.fffff") + ")";        
+        }
+
+        public static string ProduceLog(List<Log> logs)
+        {
+            string finallog = "";
+            foreach (var log in logs)
+            {
+                finallog = finallog + System.Environment.NewLine + log.Message;
+            }
+            return finallog;
+        }
+    }
+
+    
     public class QAFormViewer : Grid, IDFRenderer
     {
         #region Fields
@@ -49,11 +73,13 @@ namespace comal.timesheets.QAForms
         DateTime timeStarted = DateTime.MinValue;
         List<DigitalFormsHeader> headersToCollapse = new List<DigitalFormsHeader>();
         int collapsedHeaderCount = 1;
+        List<Log> logs = new List<Log>();
         #endregion
 
         #region Constructor
         public QAFormViewer(IDigitalFormDataModel _model, DFLayout _dfLayout, bool newForm, bool _readOnly, Guid _jobid = default(Guid))
         {
+            logs.Add(new Log("constructor", MobileLogType.START));
             GetLocation();
             timeStarted = DateTime.Now;
             userID = ClientFactory.UserGuid;
@@ -86,6 +112,8 @@ namespace comal.timesheets.QAForms
                 }
                 LoadForm();
             }
+            logs.Add(new Log("constructor", MobileLogType.END));
+            
         }
 
         #endregion
@@ -116,10 +144,12 @@ namespace comal.timesheets.QAForms
         #region Load Form Layout
         private async void LoadForm()
         {
+            logs.Add(new Log("LoadForm()", MobileLogType.START));
             {
                 LoadRowsAndColumns();
                 LoadElements();
             }
+            logs.Add(new Log("LoadForm()", MobileLogType.END));
         }
         private void LoadRowsAndColumns()
         {
@@ -128,6 +158,7 @@ namespace comal.timesheets.QAForms
         }
         private void LoadRows()
         {
+            logs.Add(new Log("LoadRows()", MobileLogType.START));
             foreach (var row in dfLayout.RowHeights)
             {
                 RowDefinition def = new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) };
@@ -150,9 +181,11 @@ namespace comal.timesheets.QAForms
                 }
                 Device.BeginInvokeOnMainThread(() => { RowDefinitions.Add(def); });
             }
+            logs.Add(new Log("LoadRows()", MobileLogType.END));
         }
         private void LoadColumns()
         {
+            logs.Add(new Log("LoadColumns()", MobileLogType.START));
             foreach (var col in dfLayout.ColumnWidths)
             {
                 ColumnDefinition def = new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) };
@@ -169,16 +202,20 @@ namespace comal.timesheets.QAForms
                 }
                 Device.BeginInvokeOnMainThread(() => { ColumnDefinitions.Add(def); });
             }
+            logs.Add(new Log("LoadColumns()", MobileLogType.END));
         }
         private void LoadElements()
         {
+            logs.Add(new Log("LoadElements()", MobileLogType.START));
             rbGroup = 0; //used for customboolean - has to be outside of foreach loop
             foreach (DFLayoutControl element in dfLayout.Elements)
             {
+                logs.Add(new Log("Loading Element " + element.Description, MobileLogType.START));
                 if (!string.IsNullOrEmpty(element.Description))
                 {
                     LoadViewAccordingToElement(element);
                 }
+                logs.Add(new Log("Loading Element " + element.Description, MobileLogType.END));
             }
             Task.Run(() =>
             {
@@ -192,7 +229,7 @@ namespace comal.timesheets.QAForms
                     });
                 }
             });
-
+            logs.Add(new Log("LoadElements()", MobileLogType.END));
         }
         #endregion
 
@@ -357,11 +394,11 @@ namespace comal.timesheets.QAForms
             if (collapsed)
             {
                 rowdef.Height = 60;
-                AnimateChildren(i, 0, 250);
+                //AnimateChildren(i, 0, 250);
             }
             else
             {
-                AnimateChildren(i, -60, 500);
+                //AnimateChildren(i, -60, 500);
                 rowdef.Height = 0;
             }
         }

+ 1 - 1
prs.mobile/comal.timesheets/Main/MainPage.xaml.cs

@@ -1587,7 +1587,7 @@ namespace comal.timesheets
                         //    Navigation.PushAsync(products);
                         //}
 
-                        var page = new TestMobileGrid(new ProductsGrid());
+                        var page = new DataGridHost(new ProductsGrid());
                         Navigation.PushAsync(page);
                     });
                     toolEntries.Add(Products);

+ 1 - 1
prs.mobile/comal.timesheets/Main/PINLoginPage.xaml.cs

@@ -158,7 +158,7 @@ namespace comal.timesheets
             }
             catch (Exception ex)
             {
-                string chosenOption = await DisplayActionSheet("Connection error - please check your connection. Try again?", "Cancel", null, "Yes");
+                string chosenOption = await DisplayActionSheet("Connection error - please check your connection. Try again?", "Cancel", null, "Yes", "No");
                 switch (chosenOption)
                 {
                     case "Yes":

+ 2 - 2
prs.mobile/comal.timesheets/MobileDataGrid.xaml

@@ -24,8 +24,8 @@
             <ListView Grid.Row="1" HasUnevenRows="True" x:Name="itemsListView">
                 <ListView.ItemTemplate>
                     <DataTemplate>
-                        <ViewCell>
-                            <Grid>
+                        <ViewCell Tapped="Row_Tapped">
+                            <Grid BackgroundColor="{Binding Color}">
                                 <Grid.ColumnDefinitions>
                                     <ColumnDefinition Width="{Binding ColWidth0}"/>
                                     <ColumnDefinition Width="{Binding ColWidth1}"/>

+ 108 - 65
prs.mobile/comal.timesheets/MobileDataGrid.xaml.cs

@@ -9,11 +9,18 @@ using Xamarin.Forms.Xaml;
 
 namespace comal.timesheets
 {
-    public delegate void DataGridTitleSet(string title);
+    public enum DataGridSaveType
+    {
+        None,
+        Single,
+        Multiple
+    }
+    public delegate void DataGridOptionsSet(string title, DataGridSaveType savetype = DataGridSaveType.None);
     [XamlCompilation(XamlCompilationOptions.Compile)]
     public partial class MobileDataGrid : ContentView
     {
-        public event DataGridTitleSet OnTitleSet;
+        DataGridSaveType SaveType { get; set; }
+        public event DataGridOptionsSet OnOptionsSet;
         bool bSearching = false;
         ObservableCollection<DataGridFilter> Filters = new ObservableCollection<DataGridFilter>();
         List<DataGridViewModelItem> Items = new List<DataGridViewModelItem>();
@@ -28,7 +35,7 @@ namespace comal.timesheets
             Filters.CollectionChanged += Filters_CollectionChanged;
         }
 
-        public void Setup(List<DataGridViewModelItem> items, Type type)
+        public void Setup(List<DataGridViewModelItem> items, Type type, DataGridSaveType savetype = DataGridSaveType.None)
         {
             Type = type;
             Items = items;
@@ -37,10 +44,15 @@ namespace comal.timesheets
                 SetupHeadersAndDataTemplate(items.First());
                 Refresh(Items);
             });
-            OnTitleSet?.Invoke(type.Name);
+            OnOptionsSet?.Invoke(type.Name, savetype);
+            SaveType = savetype;
+            itemsListView.SelectionMode = savetype == DataGridSaveType.None ? ListViewSelectionMode.None : ListViewSelectionMode.Single;
         }
 
-
+        /// <summary>
+        /// Never pass CurrentItems into this function - create an intermediate list first
+        /// </summary>
+        /// <param name="items"></param>
         private void Refresh(List<DataGridViewModelItem> items)
         {
             itemsListView.ItemsSource = items;
@@ -66,8 +78,6 @@ namespace comal.timesheets
                     ChangeHeaderColour(false, count);
                 count++;
             }
-
-
         }
 
         public void SetupHeadersAndDataTemplate(DataGridViewModelItem item)
@@ -130,6 +140,27 @@ namespace comal.timesheets
         }
 
         #region Events
+        private void Row_Tapped(object sender, EventArgs e)
+        {
+            var item = itemsListView.SelectedItem as DataGridViewModelItem;
+            if (item != null)
+            {
+                
+
+                bool selected = item.IsSelected;
+                var foundItem = Items.FirstOrDefault(x => x.ID == item.ID);
+                foundItem.IsSelected = selected ? false : true;
+
+                var currentListFoundItem = CurrentItems.FirstOrDefault(x => x.ID == item.ID);
+                if (currentListFoundItem != null)
+                    currentListFoundItem.IsSelected = selected ? false : true;
+            }
+            List<DataGridViewModelItem> list = new List<DataGridViewModelItem>();
+            foreach (var i in CurrentItems)
+                list.Add(i);
+            Refresh(list);
+        }
+
         private void SearchEnt_OnDataGridSearchEntryChanged(int columnnumber, string value, string colname)
         {
             if (string.IsNullOrWhiteSpace(value))
@@ -142,22 +173,6 @@ namespace comal.timesheets
             }
         }
 
-        private FilterNumber FindNumber(int columnnumber)
-        {
-            switch (columnnumber)
-            {
-                case 0:
-                    return FilterNumber.Zero;
-                case 1:
-                    return FilterNumber.One;
-                case 2:
-                    return FilterNumber.Two;
-                case 3:
-                    return FilterNumber.Three;
-                default:
-                    return FilterNumber.Zero;
-            }
-        }
 
         private void Filters_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
         {
@@ -288,45 +303,9 @@ namespace comal.timesheets
                     }
                 }
             }
-
             Filters.Remove(toRemove.First());
         }
 
-
-        private IEnumerable<DataGridViewModelItem> RunSearch(IEnumerable<DataGridViewModelItem> list, string value, string propertyname)
-        {
-            var intermediatelist = new List<DataGridViewModelItem>();
-            foreach (var property in info)
-            {
-                if (property.Name == propertyname)
-                {
-                    foreach (var item in list)
-                    {
-                        if (GetStringValue(property, item).Contains(value)
-                            || GetStringValue(property, item).Contains(value.ToUpper())
-                            || GetStringValue(property, item).Contains(value.ToLower())
-                            || GetStringValue(property, item).Contains(SearchUtils.LowerCaseFirst(value))
-                            || GetStringValue(property, item).Contains(SearchUtils.UpperCaseFirst(value))
-                            || GetStringValue(property, item).Contains(SearchUtils.UpperCaseSecond(value))
-                            )
-                        {
-                            if (!intermediatelist.Contains(item))
-                                intermediatelist.Add(item);
-                        }
-                    }
-                }
-            }
-            return intermediatelist;
-        }
-
-        private string GetStringValue(PropertyInfo property, object item)
-        {
-            if (property.PropertyType == typeof(string))
-                return (string)property.GetValue(item);
-            else
-                return "";
-        }
-
         private void Header_OnDataGridHeaderTapped(int columnnumber, SearchUtils.SortDirection sortdirection)
         {
             var intermediatelist = new List<DataGridViewModelItem>();
@@ -352,12 +331,12 @@ namespace comal.timesheets
             {
                 filters.Add(list);
             }
-            MultiSelectPage page = new MultiSelectPage(options, filters, columnnumber, columnname);
-            page.OnPageSaved += Page_OnPageSaved;
-            Navigation.PushAsync(page);
+            MultiSelectPage filterpage = new MultiSelectPage(options, filters, columnnumber, columnname);
+            filterpage.OnPageSaved += FilterPage_OnPageSaved;
+            Navigation.PushAsync(filterpage);
         }
 
-        private void Page_OnPageSaved(IEnumerable<MultiSelectPageViewItem> items, int columnnumber, string columnname)
+        private void FilterPage_OnPageSaved(IEnumerable<MultiSelectPageViewItem> items, int columnnumber, string columnname)
         {
             var intermediateList = new List<DataGridFilter>();
             var list = Filters.Where(x => x.ColNumber == "Col" + columnnumber && x.FilterType == FilterType.Selected);
@@ -373,7 +352,32 @@ namespace comal.timesheets
 
             var newlist = Filters.Where(x => x.ColNumber == "Col" + columnnumber);
         }
-
+        #endregion
+        private IEnumerable<DataGridViewModelItem> RunSearch(IEnumerable<DataGridViewModelItem> list, string value, string propertyname)
+        {
+            var intermediatelist = new List<DataGridViewModelItem>();
+            foreach (var property in info)
+            {
+                if (property.Name == propertyname)
+                {
+                    foreach (var item in list)
+                    {
+                        if (GetStringValue(property, item).Contains(value)
+                            || GetStringValue(property, item).Contains(value.ToUpper())
+                            || GetStringValue(property, item).Contains(value.ToLower())
+                            || GetStringValue(property, item).Contains(SearchUtils.LowerCaseFirst(value))
+                            || GetStringValue(property, item).Contains(SearchUtils.UpperCaseFirst(value))
+                            || GetStringValue(property, item).Contains(SearchUtils.UpperCaseSecond(value))
+                            )
+                        {
+                            if (!intermediatelist.Contains(item))
+                                intermediatelist.Add(item);
+                        }
+                    }
+                }
+            }
+            return intermediatelist;
+        }
         private void ChangeHeaderColour(bool filterpresent, int colnumber)
         {
             foreach (var header in headerGrid.Children)
@@ -385,7 +389,30 @@ namespace comal.timesheets
                 }
             }
         }
-        #endregion
+        private string GetStringValue(PropertyInfo property, object item)
+        {
+            if (property.PropertyType == typeof(string))
+                return (string)property.GetValue(item);
+            else
+                return "";
+        }
+
+        private FilterNumber FindNumber(int columnnumber)
+        {
+            switch (columnnumber)
+            {
+                case 0:
+                    return FilterNumber.Zero;
+                case 1:
+                    return FilterNumber.One;
+                case 2:
+                    return FilterNumber.Two;
+                case 3:
+                    return FilterNumber.Three;
+                default:
+                    return FilterNumber.Zero;
+            }
+        }
 
     }
 
@@ -426,6 +453,21 @@ namespace comal.timesheets
     {
         public Guid ID { get; set; }
 
+        private bool isSelected;
+        public bool IsSelected
+        {
+            get
+            {
+                return isSelected;
+            }
+            set
+            {
+                isSelected = value;
+                Color = isSelected == true ? Color.FromHex("#91a3b0") /*Cadet Gray*/ : Color.Default;
+            }
+        }
+        public Color Color { get; set; }
+
         public List<Tuple<string, string>> Data { get; set; }
         public string Col0 { get; set; }
         public string Col1 { get; set; }
@@ -457,6 +499,7 @@ namespace comal.timesheets
             ColWidth1 = data.Count > 1 ? new GridLength(1, GridUnitType.Star) : new GridLength(0, GridUnitType.Absolute);
             ColWidth2 = data.Count > 2 ? new GridLength(1, GridUnitType.Star) : new GridLength(0, GridUnitType.Absolute);
             ColWidth3 = data.Count > 3 ? new GridLength(1, GridUnitType.Star) : new GridLength(0, GridUnitType.Absolute);
+            IsSelected = false;
         }
     }
 }

+ 25 - 0
prs.mobile/comal.timesheets/MobileDataGridPage.xaml

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
+             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+             x:Class="comal.timesheets.MobileDataGridPage">
+    <NavigationPage.TitleView>
+        <Grid Margin="0" Padding="0">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="*"/>
+                <ColumnDefinition Width="*"/>
+                <ColumnDefinition Width="*"/>
+            </Grid.ColumnDefinitions>
+            <Button Grid.Column="0" HorizontalOptions="Start" VerticalOptions="Center" TextColor="White" BackgroundColor="Transparent" Margin="0" Padding="0"
+                Text="Cancel" Clicked="CancelBtn_Clicked"/>
+            <Label Grid.Column="1" VerticalOptions="Center" x:Name="titleLbl"
+                   HorizontalOptions="Center" HorizontalTextAlignment="Center" TextColor="White" FontSize="Medium" FontAttributes="Bold"/>
+            <Button Grid.Column="2" HorizontalOptions="End" VerticalOptions="Center" TextColor="White" BackgroundColor="Transparent" Margin="0" Padding="0"
+                Text="Accept" Clicked="SaveBtn_Clicked" IsVis
+                    />
+        </Grid>
+    </NavigationPage.TitleView>
+    <ContentPage.Content>
+        <StackLayout x:Name="stackLayout">
+        </StackLayout>
+    </ContentPage.Content>
+</ContentPage>

+ 37 - 0
prs.mobile/comal.timesheets/MobileDataGridPage.xaml.cs

@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using Xamarin.Forms;
+using Xamarin.Forms.Xaml;
+
+namespace comal.timesheets
+{
+	[XamlCompilation(XamlCompilationOptions.Compile)]
+	public partial class MobileDataGridPage : ContentPage
+	{
+		public MobileDataGridPage (MobileDataGrid datagrid)
+		{
+			InitializeComponent ();
+            NavigationPage.SetHasBackButton(this, false);
+            datagrid.OnTitleSet += Datagrid_OnTitleSet;
+            stackLayout.Children.Add(datagrid);
+        }
+
+        private void Datagrid_OnTitleSet(string title)
+        {
+            Device.BeginInvokeOnMainThread(() =>
+            {
+                titleLbl.Text = title + "s";
+                
+            });
+        }
+
+        private void CancelBtn_Clicked(object sender, EventArgs e)
+        {
+            Navigation.PopAsync();
+        }
+    }
+}

+ 3 - 3
prs.mobile/comal.timesheets/ProductsGrid.cs

@@ -13,7 +13,7 @@ namespace comal.timesheets
 {
     public class ProductsGrid : MobileDataGrid
     {
-        public ProductsGrid()
+        public ProductsGrid(DataGridSaveType savetype = DataGridSaveType.Multiple)
         {
             Task.Run(async() => 
             {
@@ -32,7 +32,7 @@ namespace comal.timesheets
                                 tuples
                             ));
                     }
-                    Setup(shells, typeof(Product));
+                    Setup(shells, typeof(Product), savetype);
                 }
                 else
                 {
@@ -64,7 +64,7 @@ namespace comal.timesheets
                                 ));
                         }
 
-                        Setup(shells, typeof(Product));
+                        Setup(shells, typeof(Product), savetype); 
                     }
                 }
             });           

+ 1 - 1
prs.mobile/comal.timesheets/TestMobileGrid.xaml.cs

@@ -16,7 +16,7 @@ namespace comal.timesheets
 		{
 			InitializeComponent ();
 			NavigationPage.SetHasBackButton(this, false);
-			datagrid.OnTitleSet += Datagrid_OnTitleSet;
+			
 			stackLayout.Children.Add(datagrid);
 		}
 

+ 9 - 0
prs.mobile/comal.timesheets/comal.timesheets.projitems

@@ -169,6 +169,9 @@
       <DependentUpon>DataGridHeaderRow.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
+    <Compile Include="$(MSBuildThisFileDirectory)DataGridHost.xaml.cs">
+      <SubType>Code</SubType>
+    </Compile>
     <Compile Include="$(MSBuildThisFileDirectory)DataGridSearchEntry.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)DigitalForms\DataModels\DigitalFormsHelper.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)DigitalForms\CustomUserControls\DigitalFormsHeader.xaml.cs">
@@ -1071,4 +1074,10 @@
       <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
     </EmbeddedResource>
   </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="$(MSBuildThisFileDirectory)DataGridHost.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+    </EmbeddedResource>
+  </ItemGroup>
 </Project>