123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Comal.Classes;
- using InABox.Clients;
- using InABox.Core;
- using Syncfusion.SfSchedule.XForms;
- using Xamarin.Forms;
- using Xamarin.Forms.Xaml;
- using XF.Material.Forms;
- using XF.Material.Forms.UI.Dialogs;
- using XF.Material.Forms.UI.Dialogs.Configurations;
- namespace comal.timesheets.iOS.Assignments
- {
- public class AssignmentColumnChangedArgs : EventArgs
- {
-
- }
-
- public delegate void AssignmentColumnChangedDelegate(object sender, AssignmentColumnChangedArgs args);
-
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class AssignmentColumn : ContentView
- {
- public event AssignmentColumnChangedDelegate OnChanged;
-
- public Guid EmployeeID { get; set; }
- public string EmployeeName
- {
- get { return Header.Text; }
- set { Header.Text = value; }
- }
- public DateTime Date
- {
- get { return Schedule.SelectedDate ?? DateTime.MinValue; }
- set { Schedule.MoveToDate = value; }
- }
- public bool ShowTime
- {
- get { return Schedule.DayViewSettings.TimeRulerSize > 0.0F; }
- set { Schedule.DayViewSettings.TimeRulerSize = value ? 50F : 0F; }
- }
- public void Load(IEnumerable<AssignmentListDataModelItem> items)
- {
- Header.Margin = ShowTime ? new Thickness(45F, 0F, -5F, -5F) : new Thickness(-5F, 0F, -5F, -5F);
- Schedule.DataSource = new ObservableCollection<AssignmentListDataModelItem>(items);
- }
- public AssignmentColumn()
- {
- InitializeComponent();
- Schedule.DayViewSettings.DayLabelSettings = new DayLabelSettings() { TimeFormat = "HH:mm" };
- }
- private async void Schedule_OnCellTapped(object sender, CellTappedEventArgs e)
- {
- if (e.Appointment is AssignmentListDataModelItem item)
- {
- var editor = new AssignmentEdit(item);
- Navigation.PushAsync(editor);
- }
- }
-
- private async void Schedule_OnCellLongPressed(object sender, CellTappedEventArgs e)
- {
- if (e.Appointment == null)
- {
- if (InABox.Core.Security.CanEdit<Assignment>())
- {
- var assignment = new Assignment()
- {
- Date = e.Datetime.Date,
- Title = "New Assignment"
- };
- assignment.Booked.Start = e.Datetime.TimeOfDay;
- assignment.Booked.Finish = e.Datetime.TimeOfDay.Add(new TimeSpan(1, 0, 0));
- assignment.Booked.Duration = new TimeSpan(1, 0, 0);
- assignment.EmployeeLink.ID = App.Data.Employee.ID;
- var editor = new AssignmentEdit(assignment);
- Navigation.PushAsync(editor);
- }
- }
- else if (InABox.Core.Security.CanDelete<Assignment>())
- {
- var confirm = await MaterialDialog.Instance.ConfirmAsync(
- "Are you sure you wish to delete this assignment?",
- "Confirm Deletion",
- "Yes, Delete",
- "Cancel",
- new MaterialAlertDialogConfiguration()
- {
- ButtonFontFamily = Material.FontFamily.Body2
- }
- );
- if (confirm == true)
- {
- using(await MaterialDialog.Instance.LoadingDialogAsync(message: "Deleting Assignment"))
- {
- var assignment = new Assignment() { ID = (e.Appointment as AssignmentListDataModelItem).Id };
- new Client<Assignment>().Delete(assignment, "Deleted on Mobile Device");
- }
- OnChanged?.Invoke(this, new AssignmentColumnChangedArgs());
- }
- }
- }
- private void Schedule_OnFocusChangeRequested(object sender, FocusRequestArgs e)
- {
- e.Focus = false;
- e.Result = true;
- }
- private void Schedule_OnFocused(object sender, FocusEventArgs e)
- {
-
- }
- }
- }
|