|  | @@ -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);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 |