Browse Source

Interim Update

Frank van den Bos 2 years ago
parent
commit
845a78c7f6

+ 18 - 3
prs.mobile.new/PRS.Mobile/Data Models/Lists/Notification/NotificationShell.cs

@@ -1,6 +1,7 @@
 using System;
 using Comal.Classes;
 using InABox.Mobile;
+using Xamarin.Forms;
 
 namespace PRS.Mobile
 {
@@ -15,18 +16,32 @@ namespace PRS.Mobile
                 .Map(nameof(Description), x => x.Description)
                 .Map(nameof(EntityType), x => x.EntityType)
                 .Map(nameof(EntityID), x => x.EntityID)
-                .Map(nameof(Attachments), x=>x.DocumentCount);
+                .Map(nameof(Attachments), x=>x.DocumentCount)
+                .Map(nameof(Closed), x =>x.Closed);
         }
         
         public DateTime Created => Get<DateTime>();
+        
         public string Sender => Get<String>();
+        
         public string Title => Get<String>();
+        
         public string Description => Get<String>();
+        
         public string EntityType => Get<String>();
+        
         public Guid EntityID => Get<Guid>();
-        public int Attachments => Get<int>();
         
-        public bool ImageVisible => Attachments > 0;
+        public int Attachments => Get<int>();
+
+        public DateTime Closed
+        {
+            get => Get<DateTime>();
+            set => Set(value);
+        }
+
+
+        public bool Selected { get; set; }
 
     }
 }

+ 3 - 2
prs.mobile.new/PRS.Mobile/Main/DataModel.cs

@@ -244,8 +244,9 @@ namespace PRS.Mobile
             );
             
             Notifications = new NotificationModel(this, 
-                () => new Filter<Notification>(x=>x.Closed).IsEqualTo(DateTime.MinValue)
-                    .And(x=>x.Employee.ID).IsEqualTo(App.Data.Me.ID)
+                () => new Filter<Notification>(x=>x.Employee.ID).IsEqualTo(App.Data.Me.ID)
+                    .And(new Filter<Notification>(x=>x.Closed).IsEqualTo(DateTime.MinValue)
+                        .Or(x=>x.Created).IsGreaterThanOrEqualTo(DateTime.Today.AddDays(-90)))
             );
             
             TimeSheets = new TimeSheetModel(this,

+ 0 - 1
prs.mobile.new/PRS.Mobile/MainPage.xaml

@@ -119,7 +119,6 @@
                         x:Name="Notifications"
                         Text="Notifications"
                         Image="notification"
-                        Indicator="!"
                         Tapped="Notifications_OnTapped"/>  
                                 
                     <mobile:MobileMobileToolItem

+ 7 - 0
prs.mobile.new/PRS.Mobile/MainPage.xaml.cs

@@ -9,6 +9,7 @@ using InABox.Clients;
 using InABox.Mobile;
 using Comal.Classes;
 using InABox.Configuration;
+using Xamarin.Forms.Xaml;
 using XF.Material.Forms.UI.Dialogs;
 
 namespace PRS.Mobile
@@ -94,6 +95,12 @@ namespace PRS.Mobile
                 CheckTimeSheet();
             }
 
+            App.Data.Notifications.Refresh(true, () => Device.BeginInvokeOnMainThread(() =>
+            {
+                var count = App.Data.Notifications.Items.Count(x => x.Closed.IsEmpty());
+                Notifications.Indicator = count > 0 ? count.ToString() : "";
+            }));
+            
             _selectionpage = null;
             MobileLogging.Log("MainPage.refreshScreen");
             RefreshScreen();

+ 1 - 1
prs.mobile.new/PRS.Mobile/Modules/Notifications/NewReplyNotification.xaml

@@ -45,7 +45,7 @@
                     </Frame>
 
                     <!--Row 2 Notification Title-->
-                    <material:MaterialLabel Text="Notificiation Title" TypeScale="H6" HorizontalTextAlignment="Start" Margin="5" />
+                    <material:MaterialLabel Text="Notification Title" TypeScale="H6" HorizontalTextAlignment="Start" Margin="5" />
 
                     <Frame x:Name="notificationTitleFrame" HasShadow="False" BorderColor="#15C7C1" Padding="10">
                         <Editor x:Name="titleEdt" AutoSize="TextChanges" TextChanged="TitleEdt_Changed"/>

+ 169 - 44
prs.mobile.new/PRS.Mobile/Modules/Notifications/NotificationList.xaml

@@ -5,56 +5,181 @@
              x:Class="PRS.Mobile.NotificationList"
              Title="Notifications">
     
+    <mobile:MobilePage.Resources>
+        <mobile:IntToBooleanConverter x:Key="IntToBooleanConverter"/>
+        <local:NotificationTypeConverter x:Key="NotificationTypeConverter"/>
+    </mobile:MobilePage.Resources>
+    
     <mobile:MobilePage.PrimaryMenu>
-        <ImageButton Source="tick" Clicked="DismissAll_Clicked"/>
+        
+        <mobile:MobileMenuButton 
+            x:Name="_options"
+            Image="dots" 
+            Appearing="_options_OnAppearing">
+            <mobile:MobileMenuButton.Items>
+                <mobile:MobileMenuItem 
+                    x:Name="_markAsRead"
+                    Text="Mark As Read" 
+                    Clicked="_markAsRead_Clicked" />
+                <mobile:MobileMenuItem 
+                    x:Name="_markAsUnread"
+                    Text="Mark As Unread" 
+                    IsVisible="False"
+                    Clicked="_markAsUnread_Clicked" />
+                <mobile:MobileMenuSeparator 
+                    x:Name="_separator"/>
+                <mobile:MobileMenuItem 
+                    x:Name="_selectAll"
+                    Text="Select All" 
+                    Clicked="_selectAll_Clicked" />
+                <mobile:MobileMenuItem 
+                    x:Name="_selectNone"
+                    Text="Select None" 
+                    IsVisible="False"
+                    Clicked="_selectNone_Clicked" />
+            </mobile:MobileMenuButton.Items>
+            
+        </mobile:MobileMenuButton>
     </mobile:MobilePage.PrimaryMenu>
     
     <mobile:MobilePage.PageContent>
-        <StackLayout>
-            <Grid Margin="5">
-                <Grid.ColumnDefinitions>
-                    <ColumnDefinition Width="3*"/>
-                    <ColumnDefinition Width="2*"/>
-                </Grid.ColumnDefinitions>
-                <Label Grid.Column="0" x:Name="numberOfItemsLbl" Margin="5,0, 0, 0"
-                       Text="Number of items: 0" LineBreakMode="WordWrap" HorizontalOptions="Start" VerticalOptions="Center" FontAttributes="Bold" FontSize="Medium"/>
-                <Button Grid.Column="1" Clicked="New_Clicked" Margin="0,0, 5, 0"
-                        Text="New" BackgroundColor="#15C7C1" CornerRadius="10" TextColor="White" VerticalOptions="Center" HorizontalOptions="FillAndExpand"/>
-            </Grid>
-            <ListView x:Name="notificationListView" HasUnevenRows="True" BackgroundColor="Transparent" Margin="0,0,0,0">
-                <ListView.ItemTemplate>
-                    <DataTemplate>
-                        <ViewCell Tapped="NotificationListView_Tapped">
-                            <Frame Padding="5" BorderColor="#15C7C1" Margin="1" CornerRadius="10" HasShadow="False">
-                                <StackLayout Orientation="Vertical">
+        <Grid Margin="5">
+            <Grid.RowDefinitions>
+                <RowDefinition Height="Auto"/>
+                <RowDefinition Height="*"/>
+                <RowDefinition Height="Auto"/>
+            </Grid.RowDefinitions>
+            
+            <mobile:MobileSearchBar 
+                x:Name="_search"
+                Grid.Row="0"
+                TextChanged="_search_Changed"/>
+            
+            <mobile:MobileList
+                x:Name="_notifications"
+                Grid.Row="1"
+                PullToRefresh="True"
+                RefreshRequested="_notifications_RefreshRequested"
+                HasUnevenRows="False">
+                <mobile:MobileList.ItemTemplate>
+                    <DataTemplate x:DataType="local:NotificationShell">
+                        <Frame 
+                            Padding="2" 
+                            BorderColor="Gray" 
+                            CornerRadius="5" 
+                            HasShadow="False"
+                            VerticalOptions="StartAndExpand"
+                            HeightRequest="100">
+                            <Frame.GestureRecognizers>
+                                <TapGestureRecognizer Tapped="_notification_Tapped" />
+                            </Frame.GestureRecognizers>
 
-                                    <Grid >
-                                        <Grid.ColumnDefinitions>
-                                            <ColumnDefinition Width="30"/>
-                                            <ColumnDefinition Width="*"/>
-                                            <ColumnDefinition Width="Auto"/>
-                                            <ColumnDefinition Width="Auto"/>
-                                        </Grid.ColumnDefinitions>
-                                        <Image Grid.Column="0" Source="user" HeightRequest="30" WidthRequest="30"/>
-                                        <Label Grid.Column="1" VerticalOptions="Center"
-                                                Text="{Binding Sender}" FontAttributes="Bold"  FontSize="Medium" TextColor="#873260"/>
-                                        <Label  Grid.Column="2"
-                                                Text="{Binding Created, StringFormat='{}{0:dd MMM yy}'}" FontAttributes="Bold" HorizontalTextAlignment="End"/>
-                                        <Image Grid.Column="3" Source="paperclip" HeightRequest="30" WidthRequest="30" IsVisible="{Binding ImageVisible}"
-                                               VerticalOptions="Center" HorizontalOptions="Center"/>
-                                    </Grid>
-                                    
-                                    <Label LineBreakMode="WordWrap" MaxLines="2"
-                                            Text="{Binding Title}" FontAttributes="Bold"/>
-                                    
-                                    <Label LineBreakMode="WordWrap" Text="{Binding Description}" MaxLines="3"/>
+                            <Grid
+                                    RowSpacing="0"
+                                    ColumnSpacing="0"
+                                    VerticalOptions="StartAndExpand">
+                                    
+                                    <Grid.RowDefinitions>
+                                        <RowDefinition Height="Auto"/>
+                                        <RowDefinition Height="*"/>
+                                        <RowDefinition Height="Auto"/>
+                                    </Grid.RowDefinitions>
+                                    
+                                    <Grid.ColumnDefinitions>
+                                        <ColumnDefinition Width="Auto"/>
+                                        <ColumnDefinition Width="*"/>
+                                        <ColumnDefinition Width="Auto"/>
+                                        <ColumnDefinition Width="Auto"/>
+                                    </Grid.ColumnDefinitions>
+                                    
+                                    <mobile:MobileCheckBox
+                                        Grid.Row="0"
+                                        Grid.Column="0"
+                                        IsChecked="{Binding Selected, Mode=TwoWay}"
+                                        VerticalOptions="Center"
+                                    />
+                                    
+                                    <Label 
+                                        Grid.Row="0"
+                                        Grid.Column="1"
+                                        Grid.ColumnSpan="2"
+                                        LineBreakMode="WordWrap" 
+                                        MaxLines="2"
+                                        Text="{Binding Title}" 
+                                        FontAttributes="Bold"
+                                        FontSize="Small"/>
+                                    
+                                    <Image 
+                                        Grid.Row="0"
+                                        Grid.Column="3"
+                                        WidthRequest="30"
+                                        HeightRequest="30"
+                                        Aspect="AspectFit"
+                                        Source="{Binding EntityType, Converter={StaticResource NotificationTypeConverter}}" 
+                                        IsVisible="true"
+                                        Margin="2"
+                                        VerticalOptions="Start" 
+                                        HorizontalOptions="Center"/>
+                                    
+                                    <Label 
+                                        Grid.Row="1"
+                                        Grid.Column="0"
+                                        Grid.ColumnSpan="4"
+                                        LineBreakMode="WordWrap" 
+                                        Text="{Binding Description}" 
+                                        MaxLines="3"
+                                        Margin="5,0"
+                                        FontSize="Small"
+                                        FontAttributes="Italic"/>
 
-                                </StackLayout>
-                            </Frame>
-                        </ViewCell>
+                                    <Label 
+                                        Grid.Row="2"
+                                        Grid.Column="0"
+                                        Grid.ColumnSpan="2"
+                                        VerticalOptions="Center"
+                                        HorizontalTextAlignment="Start"
+                                        Text="{Binding Sender}" 
+                                        Margin="5,0"
+                                        FontSize="Micro" />
+                                    
+                                    <Label
+                                        Grid.Row="2"
+                                        Grid.Column="2"
+                                        Grid.ColumnSpan="2"
+                                        Text="{Binding Created, StringFormat='{}{0:dd MMM yy}'}" 
+                                        FontSize="Micro" 
+                                        VerticalOptions="Center"
+                                        Margin="5,0"
+                                        HorizontalTextAlignment="End"/>
+                                    
+                                </Grid>
+                                    
+                            
+                        </Frame>
                     </DataTemplate>
-                </ListView.ItemTemplate>
-            </ListView>
-        </StackLayout>
+                </mobile:MobileList.ItemTemplate>
+            </mobile:MobileList>
+            
+            <mobile:MobileMenuButton 
+                x:Name="_newmessage"
+                Image="plus"
+                Clicked="_newmessage_OnClicked"
+                Grid.Row="1"
+                VerticalOptions="End"
+                HorizontalOptions="End"
+                Margin="5"
+                HeightRequest="50"
+                WidthRequest="50"/>
+            
+            <mobile:MobileTabStrip
+                x:Name="_view"
+                Grid.Row="2"
+                SelectionChanged="_view_OnSelectionChanged">
+                <mobile:MobileTabStrip.Items>
+                    <mobile:MobileTabStripItem Text="Unread" />
+                    <mobile:MobileTabStripItem Text="History" />
+                </mobile:MobileTabStrip.Items>                
+            </mobile:MobileTabStrip>
+        </Grid>
     </mobile:MobilePage.PageContent>
 </mobile:MobilePage>

+ 269 - 132
prs.mobile.new/PRS.Mobile/Modules/Notifications/NotificationList.xaml.cs

@@ -6,191 +6,328 @@ using Xamarin.Forms;
 using InABox.Core;
 using InABox.Clients;
 using Comal.Classes;
+using InABox.Mobile;
+using Xamarin.CommunityToolkit.UI.Views;
 using Xamarin.Forms.Xaml;
 
 namespace PRS.Mobile
 {
-    public delegate void NotificationsClosedEvent(int numberOfNotifications);
+    //public delegate void NotificationsClosedEvent(int numberOfNotifications);
 
+    public class NotificationTypeConverter : UtilityConverter<String,ImageSource>
+    {
+        private readonly Dictionary<String, ImageSource> _images = new Dictionary<string, ImageSource>()
+        {
+            { "", ImageSource.FromFile("notification") },
+            { typeof(Delivery).EntityName(), ImageSource.FromFile("delivery") },
+            { typeof(Kanban).EntityName(), ImageSource.FromFile("task") },
+            { typeof(KanbanForm).EntityName(), ImageSource.FromFile("task") },
+            { typeof(LeaveRequest).EntityName(), ImageSource.FromFile("holiday") },
+            { typeof(LeaveRequestForm).EntityName(), ImageSource.FromFile("holiday") },
+            { typeof(EmployeeForm).EntityName(), ImageSource.FromFile("person") },
+            { typeof(EmployeeQualification).EntityName(), ImageSource.FromFile("badge") },
+            { typeof(JobForm).EntityName(), ImageSource.FromFile("construction") },
+        };
+        
+        protected override ImageSource Convert(string value)
+        {
+            if (!_images.TryGetValue(value ?? "", out ImageSource result))
+                result = _images[""];
+            return result;
+        }
+    }
+    
     [XamlCompilation(XamlCompilationOptions.Compile)]
     public partial class NotificationList 
     {
 
-        public event NotificationsClosedEvent NotificationsClosed;
-        List<NotificationShell> notificationShells = new List<NotificationShell>();
-
-        #region Constructor + Loading
+        //public event NotificationsClosedEvent NotificationsClosed;
+        
+        //List<NotificationShell> notificationShells = new List<NotificationShell>();
+        
         public NotificationList()
         {
             InitializeComponent();
-            App.Data.Notifications.Load(() =>
+            RefreshData(false, true);
+            // App.Data.Notifications.Load(() =>
+            // {
+            //     Dispatcher.BeginInvokeOnMainThread(() =>
+            //     {
+            //         notificationListView.ItemsSource = App.Data.Notifications;
+            //     });
+            // });
+        }
+
+        private void RefreshData(bool force, bool async)
+        {
+            if (async)
+                App.Data.Notifications.Refresh(force, () => Dispatcher.BeginInvokeOnMainThread(Refresh));
+            else
             {
-                Dispatcher.BeginInvokeOnMainThread(() =>
-                {
-                    notificationListView.ItemsSource = App.Data.Notifications;
-                });
-            });
+                App.Data.Notifications.Refresh(force);
+                Refresh();
+            }
         }
-        
-        protected override void OnDisappearing()
+
+        private void Refresh()
         {
-            NotificationsClosed?.Invoke(notificationShells.Count());
-            base.OnDisappearing();
+            foreach (var shell in App.Data.Notifications.Items.ToArray())
+                shell.Selected = false;
+            App.Data.Notifications.Search(FilterShell);
+            _notifications.ItemsSource = App.Data.Notifications.Items;
         }
-        
 
-        #endregion
+        private String _currentFilter = "";
 
-        #region Buttons / Taps
+        private bool FilterShell(NotificationShell shell)
+        {
+            bool bOK = shell.Closed.IsEmpty() == (_view.SelectedItem.Index == 0);
+
+            bOK =
+                bOK && 
+                (
+                    String.IsNullOrWhiteSpace(_currentFilter)
+                    || shell.Title.ToUpper().Contains(_currentFilter)
+                    || shell.Description.ToUpper().Contains(_currentFilter)
+                    || shell.Sender.ToUpper().Contains(_currentFilter)
+                );
+            
+            return bOK;
+        }
+        
         
-        private async void NotificationListView_Tapped(object sender, EventArgs e)
+        private void _search_Changed(object sender, MobileSearchBarTextChangedArgs args)
         {
-            NotificationShell shell = notificationListView.SelectedItem as NotificationShell;
-            string extra = CreateOption(shell);
-            string chosenOption = await DisplayActionSheet(shell.Description, "Cancel", null, "View / Reply Message", "Dismiss Message", extra);
-            ProcessOption(chosenOption, shell);
+            _currentFilter = args.Text.ToUpper();
         }
-
-        private void ProcessOption(string chosenOption, NotificationShell shell)
+        
+        
+        private void _notifications_RefreshRequested(object sender, MobileListRefreshEventArgs args)
         {
-            switch (chosenOption)
-            {
-                case "Cancel":
-                    return;
-                case "View / Reply Message":
-                    ReplyNotification(shell);
-                    break;
-                case "Dismiss Message":
-                    DismissNotification(shell);
-                    break;
-                case VIEWTASK:
-                    ViewTask(shell);
-                    break;
-                case VIEWLEAVE:
-                    OpenLeaveList();
-                    break;
-                case VIEWLEAVEFORM:
-                    ViewRequestForm(shell);
-                    break;
-                case VIEWDELIVERY:
-                    ViewDelivery(shell);
-                    break;
-                default:
-                    return;
-            }
+            RefreshData(true,false);
         }
-
-        private void ViewDelivery(NotificationShell shell)
+        
+        protected override void OnDisappearing()
         {
-            Task.Run(async () =>
-            {
-                DeliveryEdit page = await DeliveryEdit.Load(shell.EntityID);
-                Navigation.PushAsync(page);
-            });
-
+            //NotificationsClosed?.Invoke(notificationShells.Count());
+            base.OnDisappearing();
         }
+        
 
-        private void ViewRequestForm(NotificationShell shell)
+        #region Buttons / Taps
+        
+        // private async void NotificationListView_Tapped(object sender, EventArgs e)
+        // {
+        //     NotificationShell shell = notificationListView.SelectedItem as NotificationShell;
+        //     string extra = CreateOption(shell);
+        //     string chosenOption = await DisplayActionSheet(shell.Description, "Cancel", null, "View / Reply Message", "Dismiss Message", extra);
+        //     ProcessOption(chosenOption, shell);
+        // }
+        //
+        // private void ProcessOption(string chosenOption, NotificationShell shell)
+        // {
+        //     switch (chosenOption)
+        //     {
+        //         case "Cancel":
+        //             return;
+        //         case "View / Reply Message":
+        //             ReplyNotification(shell);
+        //             break;
+        //         case "Dismiss Message":
+        //             DismissNotification(shell);
+        //             break;
+        //         case VIEWTASK:
+        //             ViewTask(shell);
+        //             break;
+        //         case VIEWLEAVE:
+        //             OpenLeaveList();
+        //             break;
+        //         case VIEWLEAVEFORM:
+        //             ViewRequestForm(shell);
+        //             break;
+        //         case VIEWDELIVERY:
+        //             ViewDelivery(shell);
+        //             break;
+        //         default:
+        //             return;
+        //     }
+        // }
+        //
+        // private void ViewDelivery(NotificationShell shell)
+        // {
+        //     Task.Run(async () =>
+        //     {
+        //         DeliveryEdit page = await DeliveryEdit.Load(shell.EntityID);
+        //         Navigation.PushAsync(page);
+        //     });
+        //
+        // }
+        //
+        // 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);
+        // }
+        //
+        // const string VIEWTASK = "View Task";
+        // const string VIEWLEAVE = "View Leave";
+        // const string VIEWLEAVEFORM = "View Leave Request Form";
+        // const string VIEWDELIVERY = "View Delivery";
+        //
+        // private string CreateOption(NotificationShell shell)
+        // {
+        //     if (string.IsNullOrWhiteSpace(shell.EntityType))
+        //         return "";
+        //     if (shell.EntityType == "Comal.Classes.Kanban")
+        //         return VIEWTASK;
+        //     if (shell.EntityType == "Comal.Classes.LeaveRequest")
+        //         return VIEWLEAVE;
+        //     if (shell.EntityType == "Comal.Classes.LeaveRequestLink")
+        //         return VIEWLEAVEFORM;
+        //     if (shell.EntityType == "Comal.Classes.Delivery")
+        //         return VIEWDELIVERY;
+        //     else
+        //         return "";
+        // }
+        //
+        // void New_Clicked(object sender, EventArgs e)
+        // {
+        //     NewReplyNotification newReplyNotification = new NewReplyNotification();
+        //     Navigation.PushAsync(newReplyNotification);
+        // }
+        //
+
+        #endregion
+        
+        private void UpdateStatus(DateTime timestamp)
         {
-            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);
+            ProgressVisible = true;
+            var task = Task.Run(() =>
+            {
+                foreach (var shell in App.Data.Notifications.Items.Where(x => x.Selected).ToArray())
+                {
+                    shell.Closed = timestamp;
+                    shell.Save("Updated by Mobile Device");
+                }
+            });
+            task.Wait();
+            RefreshData(true,false);
+            ProgressVisible = false;
         }
-
-        private void ReplyNotification(NotificationShell shell)
+        
+        private void _markAsRead_Clicked(object sender, EventArgs e)
         {
-            NewReplyNotification newReplyNotification = new NewReplyNotification(shell.ID);
-            Navigation.PushAsync(newReplyNotification);
+            UpdateStatus(DateTime.Now);
         }
 
-        private void ViewTask(NotificationShell shell)
+        private void _markAsUnread_Clicked(object sender, EventArgs e)
         {
-            AddEditTask taskPage = new AddEditTask(shell.EntityID);
-            Navigation.PushAsync(taskPage);
+            UpdateStatus(DateTime.MinValue);
         }
 
-        private void OpenLeaveList()
+        
+        private void _selectAll_Clicked(object sender, EventArgs e)
         {
-            LeaveRequestList leaveRequestList = new LeaveRequestList();
-            Navigation.PushAsync(leaveRequestList);
+            foreach (var shell in App.Data.Notifications.Items.ToArray())
+                shell.Selected = true;
+            App.Data.Notifications.Search();
         }
 
-        const string VIEWTASK = "View Task";
-        const string VIEWLEAVE = "View Leave";
-        const string VIEWLEAVEFORM = "View Leave Request Form";
-        const string VIEWDELIVERY = "View Delivery";
-
-        private string CreateOption(NotificationShell shell)
+        private void _selectNone_Clicked(object sender, EventArgs e)
         {
-            if (string.IsNullOrWhiteSpace(shell.EntityType))
-                return "";
-            if (shell.EntityType == "Comal.Classes.Kanban")
-                return VIEWTASK;
-            if (shell.EntityType == "Comal.Classes.LeaveRequest")
-                return VIEWLEAVE;
-            if (shell.EntityType == "Comal.Classes.LeaveRequestLink")
-                return VIEWLEAVEFORM;
-            if (shell.EntityType == "Comal.Classes.Delivery")
-                return VIEWDELIVERY;
-            else
-                return "";
+            foreach (var shell in App.Data.Notifications.Items.ToArray())
+                shell.Selected = false;
+            App.Data.Notifications.Search();
         }
 
-        void New_Clicked(object sender, EventArgs e)
+        private void _newmessage_OnClicked(object sender, EventArgs e)
         {
             NewReplyNotification newReplyNotification = new NewReplyNotification();
             Navigation.PushAsync(newReplyNotification);
         }
 
-        void DismissAll_Clicked(object sender, EventArgs e)
+        private void _options_OnAppearing(object sender, EventArgs e)
         {
-            Device.BeginInvokeOnMainThread(() =>
-            {
-                notificationListView.ItemsSource = null;
-                numberOfItemsLbl.Text = "Number of items: 0";
-            });
-            Task.Run(() =>
-            {
-                List<Notification> notifications = new List<Notification>();
-                foreach (NotificationShell shell in notificationShells)
-                {
-                    Notification notification = new Notification { ID = shell.ID };
-                    notification.Closed = DateTime.Now;
-                    notifications.Add(notification);
-                }
-                new Client<Notification>().Save(notifications, "Dismissed on mobile device");
-            });
+            _markAsRead.IsVisible = (_view.SelectedItem.Index == 0) && App.Data.Notifications.Any(x => x.Selected);
+            _markAsUnread.IsVisible = (_view.SelectedItem.Index == 1) && App.Data.Notifications.Any(x => x.Selected);
+            _selectAll.IsVisible = App.Data.Notifications.Any(x => !x.Selected);
+            _selectNone.IsVisible = App.Data.Notifications.Any(x => x.Selected);
+            _separator.IsVisible = (_markAsRead.IsVisible || _markAsUnread.IsVisible) && (_selectAll.IsVisible || _selectNone.IsVisible);
         }
-        #endregion
 
-        #region Utils
-        void DismissNotification(NotificationShell shell)
+        private void _view_OnSelectionChanged(object sender, EventArgs e)
         {
-            Task.Run(() =>
-            {
-                Notification notification = new Notification { ID = shell.ID };
-                notificationShells.Remove(shell);
-                RefreshListOnMainThread();
-                notification.Closed = DateTime.Now;
-                new Client<Notification>().Save(notification, "Dismissed on mobile device");
-            });
+            Refresh();
         }
-        void RefreshListOnMainThread()
+
+        private void _notification_Tapped(object sender, EventArgs e)
         {
-            Device.BeginInvokeOnMainThread(() =>
+            if ((sender as Frame)?.BindingContext is NotificationShell shell)
             {
-                notificationListView.ItemsSource = null;
-                notificationListView.ItemsSource = notificationShells;
-                numberOfItemsLbl.Text = "Number of items: " + notificationShells.Count;
-            });
-        }
-        #endregion
 
+                // if (String.Equals(shell.EntityType, typeof(Delivery).EntityName()))
+                // {
+                //  
+                // }
+                // else if (String.Equals(shell.EntityType, typeof(Kanban).EntityName()))
+                // {
+                //  
+                // }
+                // else if (String.Equals(shell.EntityType, typeof(KanbanForm).EntityName()))
+                // {
+                //  
+                // }
+                // else if (String.Equals(shell.EntityType, typeof(LeaveRequest).EntityName()))
+                // {
+                //  
+                // }
+                // else if (String.Equals(shell.EntityType, typeof(LeaveRequestForm).EntityName()))
+                // {
+                //  
+                // }
+                // else if (String.Equals(shell.EntityType, typeof(EmployeeForm).EntityName()))
+                // {
+                //  
+                // }
+                // else if (String.Equals(shell.EntityType, typeof(EmployeeQualification).EntityName()))
+                // {
+                //  
+                // }
+                // else if (String.Equals(shell.EntityType, typeof(JobForm).EntityName()))
+                // {
+                //  
+                // }
+                // else
+                {
+                    NewReplyNotification newReplyNotification = new NewReplyNotification(shell.ID);
+                    Navigation.PushAsync(newReplyNotification);
+                }
+            }
+        }
     }