SiteTasks.xaml.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System.Linq;
  2. using Comal.Classes;
  3. using Xamarin.Forms.Xaml;
  4. using SelectionChangedEventArgs = Syncfusion.XForms.Buttons.SelectionChangedEventArgs;
  5. namespace comal.timesheets
  6. {
  7. [XamlCompilation(XamlCompilationOptions.Compile)]
  8. public partial class SiteTasks : SitePage
  9. {
  10. public SiteTasks()
  11. {
  12. InitializeComponent();
  13. Tasks.Columns
  14. .BeginUpdate()
  15. .Add(new MobileGridIntegerColumn<JobKanbanShell>() { Column = x=>x.Number })
  16. .Add(new MobileGridTextColumn<JobKanbanShell>() { Column = x=>x.Title })
  17. .Add(new MobileGridTextColumn<JobKanbanShell>() { Column = x=>x.Type })
  18. .Add(new MobileGridDateColumn<JobKanbanShell>() { Column = x=>x.DueDate, Format = "dd MMM yy"})
  19. .Clear()
  20. .EndUpdate();
  21. }
  22. protected override void JobLoaded()
  23. {
  24. ReloadData(false);
  25. }
  26. private void ReloadData(bool force)
  27. {
  28. if (force)
  29. Job.Refresh(true, () => Dispatcher.BeginInvokeOnMainThread(KanbansLoaded));
  30. else
  31. KanbansLoaded();
  32. }
  33. private void KanbansLoaded()
  34. {
  35. Tasks.ItemsSource = Job.Kanbans.Where(kanban => kanban.Category == Kanban.ALL[TaskType.SelectedIndex]);
  36. }
  37. private void Tasks_OnRefreshRequested(object sender, MobileGridRefreshRequestArgs args)
  38. {
  39. ReloadData(true);
  40. }
  41. private void Tasks_OnSelectionChanged(object sender, MobileGridSelectionArgs args)
  42. {
  43. // Edit the Task Here (single)
  44. // Alternatively, assign to someone (bulk)
  45. }
  46. private void TaskType_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
  47. {
  48. ReloadData(false);
  49. }
  50. }
  51. }