|
@@ -7,12 +7,11 @@ using Comal.Classes;
|
|
|
using Xamarin.Forms;
|
|
|
using System.Linq;
|
|
|
using System.Threading.Tasks;
|
|
|
-using comal.timesheets.CustomControls;
|
|
|
-using comal.timesheets.iOS.Assignments;
|
|
|
+using System.Windows.Input;
|
|
|
+using ARKit;
|
|
|
using InABox.Configuration;
|
|
|
-using Syncfusion.Office;
|
|
|
using Syncfusion.SfSchedule.XForms;
|
|
|
-using Xamarin.Forms.Xaml;
|
|
|
+using WebSocketSharp;
|
|
|
using XF.Material.Forms;
|
|
|
using XF.Material.Forms.UI.Dialogs;
|
|
|
using XF.Material.Forms.UI.Dialogs.Configurations;
|
|
@@ -25,6 +24,13 @@ namespace comal.timesheets
|
|
|
Day,
|
|
|
TimeLine
|
|
|
}
|
|
|
+
|
|
|
+ public enum AssignmentLookupType
|
|
|
+ {
|
|
|
+ ActiveJobs,
|
|
|
+ UnbookedJobs,
|
|
|
+ Tasks
|
|
|
+ }
|
|
|
|
|
|
public partial class AssignmentList : ContentPage
|
|
|
{
|
|
@@ -37,11 +43,21 @@ namespace comal.timesheets
|
|
|
|
|
|
private AssignmentView _view = AssignmentView.Day;
|
|
|
|
|
|
+ private AssignmentLookupType _lookuptype = AssignmentLookupType.UnbookedJobs;
|
|
|
+
|
|
|
+ private String _teamname = "";
|
|
|
+
|
|
|
+ private AssignmentJobDataModel _jobs = null;
|
|
|
+ private AssignmentKanbanDataModel _kanbans = null;
|
|
|
+
|
|
|
public AssignmentList()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
_settings = new LocalConfiguration<AssignmentModuleSettings>().Load();
|
|
|
|
|
|
+ _jobs = new AssignmentJobDataModel();
|
|
|
+ _kanbans = new AssignmentKanbanDataModel();
|
|
|
+
|
|
|
DatePicker.Date = _settings.Date.IsEmpty() ? DateTime.Today : _settings.Date;
|
|
|
|
|
|
_view = _settings.View;
|
|
@@ -49,22 +65,61 @@ namespace comal.timesheets
|
|
|
_employeeids = (_settings.Employees != null)
|
|
|
? _settings.Employees
|
|
|
: new Guid[] { App.Data.Employee.ID };
|
|
|
-
|
|
|
+
|
|
|
+ _lookuptype = _settings.LookupType;
|
|
|
+ LookupType.Text = CoreUtils.Neatify(_lookuptype.ToString());
|
|
|
+
|
|
|
+ _teamname = _settings.TeamName;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-
|
|
|
protected override void OnAppearing()
|
|
|
{
|
|
|
base.OnAppearing();
|
|
|
+ RefreshLookups();
|
|
|
Reload();
|
|
|
}
|
|
|
|
|
|
+ private void RefreshLookups()
|
|
|
+ {
|
|
|
+ if (_lookuptype == AssignmentLookupType.Tasks)
|
|
|
+ {
|
|
|
+ _kanbans.Load(
|
|
|
+ new Filter<Kanban>(x=>x.Completed).IsEqualTo(DateTime.MinValue),
|
|
|
+ () => Dispatcher.BeginInvokeOnMainThread(() =>
|
|
|
+ {
|
|
|
+ Lookups.ItemsSource = new ObservableCollection<AssignmentKanbanItem>(_kanbans.Items);
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ else if (_lookuptype == AssignmentLookupType.ActiveJobs)
|
|
|
+ {
|
|
|
+ _jobs.Load(
|
|
|
+ new Filter<Job>(x=>x.JobStatus.Active).IsEqualTo(true),
|
|
|
+ () => Dispatcher.BeginInvokeOnMainThread(() =>
|
|
|
+ {
|
|
|
+ Lookups.ItemsSource = new ObservableCollection<AssignmentJobItem>(_jobs.Items);
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ else if (_lookuptype == AssignmentLookupType.UnbookedJobs)
|
|
|
+ {
|
|
|
+ _jobs.Load(
|
|
|
+ new Filter<Job>(x=>x.JobStatus.Active).IsEqualTo(true)
|
|
|
+ .And(x=>x.OpenAssignments).IsEqualTo(0),
|
|
|
+ () => Dispatcher.BeginInvokeOnMainThread(() =>
|
|
|
+ {
|
|
|
+ Lookups.ItemsSource = new ObservableCollection<AssignmentJobItem>(_jobs.Items);
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void Reload()
|
|
|
{
|
|
|
|
|
|
DayView.DataSource = null;
|
|
|
TimeLineView.DataSource = null;
|
|
|
|
|
|
+ ScheduleType.Text = _teamname;
|
|
|
+
|
|
|
if (_view == AssignmentView.Day)
|
|
|
{
|
|
|
DayViewColumn.Width = new GridLength(1, GridUnitType.Star);
|
|
@@ -76,7 +131,7 @@ namespace comal.timesheets
|
|
|
DayViewColumn.Width = new GridLength(0, GridUnitType.Absolute);
|
|
|
TimeLineViewColumn.Width = new GridLength(1, GridUnitType.Star);
|
|
|
|
|
|
- TimeLineView.ResourceViewSettings.VisibleResourceCount = Math.Max(1,Math.Min(8, _employeeids.Length));
|
|
|
+ TimeLineView.ResourceViewSettings.VisibleResourceCount = Math.Max(1,Math.Min(16, _employeeids.Length));
|
|
|
TimeLineView.TimelineViewSettings.AppointmentHeight =
|
|
|
(this.Height / TimeLineView.ResourceViewSettings.VisibleResourceCount) + 100;
|
|
|
|
|
@@ -84,29 +139,37 @@ namespace comal.timesheets
|
|
|
foreach (var empid in _employeeids)
|
|
|
{
|
|
|
var empname = GlobalVariables.EmployeeShells.FirstOrDefault(x => x.ID == empid)?.Name ?? empid.ToString();
|
|
|
+ if (_employeeids.Length > 10)
|
|
|
+ empname = String.Join("", empname.Split(' ').Select(x => x.Substring(0, 1)));
|
|
|
+ else if (_employeeids.Length > 6)
|
|
|
+ {
|
|
|
+ var comps = empname.Split(' ').ToArray();
|
|
|
+ empname = $"{comps.First()} {String.Join("", comps.Skip(1).Select(x => x.Substring(0, 1)))}";
|
|
|
+ }
|
|
|
+
|
|
|
resources.Add(
|
|
|
new ScheduleResource()
|
|
|
{
|
|
|
- Name = empname, //String.Join("", empname.Split(' ').Select(x=>x.Substring(0,1))),
|
|
|
+ Name = empname,
|
|
|
Id = empid,
|
|
|
- Color = Color.Red,
|
|
|
+ Color = Color.Transparent,
|
|
|
Image = ""
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
TimeLineView.ScheduleResources = resources;
|
|
|
TimeLineView.ShowResourceView = true;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
+ }
|
|
|
Refresh();
|
|
|
}
|
|
|
|
|
|
private void Refresh()
|
|
|
{
|
|
|
Title.Text = $"{DatePicker.Date:dd MMMM yyyy}";
|
|
|
+
|
|
|
DataModel.Load(
|
|
|
new Filter<Assignment>(x => x.Date).IsEqualTo(DatePicker.Date).And(x => x.EmployeeLink.ID).InList(_employeeids),
|
|
|
() =>
|
|
@@ -123,11 +186,6 @@ namespace comal.timesheets
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void BackButton_OnClicked(object sender, EventArgs e)
|
|
|
- {
|
|
|
- Navigation.PopAsync();
|
|
|
- }
|
|
|
-
|
|
|
private void SelectedDate_Tapped(object sender, EventArgs e)
|
|
|
{
|
|
|
DatePicker.Focus();
|
|
@@ -152,8 +210,9 @@ namespace comal.timesheets
|
|
|
{
|
|
|
|
|
|
var actions = new List<string>() { "Only Me" };
|
|
|
- actions.AddRange(GlobalVariables.TeamEmployeeShells.Where(x=>x.ID == App.Data.Employee.ID).Select(x=>x.TeamName).Distinct());
|
|
|
-
|
|
|
+ //actions.AddRange(GlobalVariables.TeamEmployeeShells.Where(x=>x.ID == App.Data.Employee.ID).Select(x=>x.TeamName).Distinct());
|
|
|
+ actions.AddRange(GlobalVariables.TeamEmployeeShells.Select(x=>x.TeamName).Distinct());
|
|
|
+
|
|
|
var result = await MaterialDialog.Instance.SelectActionAsync(title: "Select a Team",
|
|
|
actions: actions);
|
|
|
|
|
@@ -161,16 +220,19 @@ namespace comal.timesheets
|
|
|
{
|
|
|
_view = AssignmentView.Day;
|
|
|
_employeeids = new Guid[] { App.Data.Employee.ID };
|
|
|
+ _teamname = App.Data.Employee.Name;
|
|
|
}
|
|
|
else if (result > 0)
|
|
|
{
|
|
|
_view = AssignmentView.TimeLine;
|
|
|
_employeeids = GlobalVariables.TeamEmployeeShells.Where(x => String.Equals(x.TeamName, actions[result]))
|
|
|
.Select(x => x.ID).Distinct().ToArray();
|
|
|
+ _teamname = actions[result];
|
|
|
}
|
|
|
|
|
|
_settings.Employees = _employeeids;
|
|
|
_settings.View = _view;
|
|
|
+ _settings.TeamName = _teamname;
|
|
|
new LocalConfiguration<AssignmentModuleSettings>().Save(_settings);
|
|
|
|
|
|
Dispatcher.BeginInvokeOnMainThread(()=>
|
|
@@ -179,6 +241,39 @@ namespace comal.timesheets
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ private void Lookups_OnItemTapped(object sender, ItemTappedEventArgs e)
|
|
|
+ {
|
|
|
+ if (e.Item is AssignmentLookupItem lookup)
|
|
|
+ {
|
|
|
+ if (lookup.Selected)
|
|
|
+ lookup.Selected = false;
|
|
|
+ else
|
|
|
+ {
|
|
|
+ IList<AssignmentLookupItem> lookups = _lookuptype == AssignmentLookupType.Tasks
|
|
|
+ ? _kanbans.Items.ToArray<AssignmentLookupItem>()
|
|
|
+ : _jobs.Items.ToArray<AssignmentLookupItem>();
|
|
|
+ {
|
|
|
+ foreach (var other in lookups.Where(x => x.Selected).ToArray())
|
|
|
+ other.Selected = false;
|
|
|
+ }
|
|
|
+ lookup.Selected = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void LookupsType_Tapped(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ _lookuptype = _lookuptype == AssignmentLookupType.Tasks
|
|
|
+ ? AssignmentLookupType.ActiveJobs
|
|
|
+ : _lookuptype == AssignmentLookupType.ActiveJobs
|
|
|
+ ? AssignmentLookupType.UnbookedJobs
|
|
|
+ : AssignmentLookupType.Tasks;
|
|
|
+ _settings.LookupType = _lookuptype;
|
|
|
+ LookupType.Text = CoreUtils.Neatify(_lookuptype.ToString());
|
|
|
+ new LocalConfiguration<AssignmentModuleSettings>().Save(_settings);
|
|
|
+ RefreshLookups();
|
|
|
+ }
|
|
|
+
|
|
|
private async void Schedule_OnCellTapped(object sender, CellTappedEventArgs e)
|
|
|
{
|
|
|
if (e.Appointment is AssignmentListDataModelItem item)
|
|
@@ -192,47 +287,93 @@ namespace comal.timesheets
|
|
|
{
|
|
|
if (e.Appointment == null)
|
|
|
{
|
|
|
+
|
|
|
if (InABox.Core.Security.CanEdit<Assignment>())
|
|
|
{
|
|
|
- var assignment = new Assignment()
|
|
|
- {
|
|
|
- Date = e.Datetime.Date,
|
|
|
- Start = new TimeSpan(e.Datetime.TimeOfDay.Hours,0,0),
|
|
|
- Finish = e.Datetime.TimeOfDay.Add(new TimeSpan(1, 0, 0)),
|
|
|
- Duration = new TimeSpan(1, 0, 0),
|
|
|
- Title = "New Assignment"
|
|
|
- };
|
|
|
- assignment.EmployeeLink.ID = (e.Resource is ScheduleResource sr)
|
|
|
- ? (Guid)sr.Id
|
|
|
- : App.Data.Employee.ID;
|
|
|
-
|
|
|
- var editor = new AssignmentEdit(assignment);
|
|
|
- Navigation.PushAsync(editor);
|
|
|
+ CreateAssignment(
|
|
|
+ e.Datetime,
|
|
|
+ e.Resource as ScheduleResource
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
- 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)
|
|
|
+ else if (InABox.Core.Security.CanDelete<Assignment>()
|
|
|
+ && e.Appointment is AssignmentListDataModelItem assignment)
|
|
|
+ {
|
|
|
+ await DeleteAssignment(assignment.Id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CreateAssignment(DateTime date, ScheduleResource resource)
|
|
|
+ {
|
|
|
+
|
|
|
+ var assignment = new Assignment()
|
|
|
+ {
|
|
|
+ Date = date.Date,
|
|
|
+ Start = new TimeSpan(date.TimeOfDay.Hours, 0, 0),
|
|
|
+ Finish = date.TimeOfDay.Add(new TimeSpan(1, 0, 0)),
|
|
|
+ Duration = new TimeSpan(1, 0, 0),
|
|
|
+ Title = "New Assignment",
|
|
|
+ };
|
|
|
+
|
|
|
+ assignment.EmployeeLink.ID = (resource is ScheduleResource sr)
|
|
|
+ ? (Guid)sr.Id
|
|
|
+ : App.Data.Employee.ID;
|
|
|
+
|
|
|
+ var job = (_lookuptype == AssignmentLookupType.ActiveJobs) || (_lookuptype == AssignmentLookupType.UnbookedJobs)
|
|
|
+ ? _jobs.Items.FirstOrDefault(x => x.Selected)
|
|
|
+ : null;
|
|
|
+ if (job != null)
|
|
|
+ {
|
|
|
+ assignment.JobLink.ID = job.Id;
|
|
|
+ assignment.JobLink.JobNumber = job.Number;
|
|
|
+ assignment.JobLink.Name = job.Name;
|
|
|
+ assignment.Description = job.Description;
|
|
|
+ assignment.Title = job.Name;
|
|
|
+ job.Selected = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ var task = _lookuptype == AssignmentLookupType.Tasks
|
|
|
+ ? _kanbans.Items.FirstOrDefault(x => x.Selected)
|
|
|
+ : null;
|
|
|
+ if (task != null)
|
|
|
+ {
|
|
|
+ assignment.Task.ID = task.Id;
|
|
|
+ assignment.Task.Number = int.Parse(task.Number);
|
|
|
+ assignment.Task.Title = task.Name;
|
|
|
+ assignment.Title = task.Name;
|
|
|
+ assignment.Description = task.Description;
|
|
|
+ task.Selected = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ var editor = new AssignmentEdit(assignment);
|
|
|
+ Navigation.PushAsync(editor);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private async Task DeleteAssignment(Guid id)
|
|
|
+ {
|
|
|
+ var confirm = await MaterialDialog.Instance.ConfirmAsync(
|
|
|
+ "Are you sure you wish to delete this assignment?",
|
|
|
+ "Confirm Deletion",
|
|
|
+ "Yes, Delete",
|
|
|
+ "Cancel",
|
|
|
+ new MaterialAlertDialogConfiguration()
|
|
|
{
|
|
|
- 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");
|
|
|
- }
|
|
|
- Refresh();
|
|
|
+ ButtonFontFamily = Material.FontFamily.Body2
|
|
|
+ }
|
|
|
+ );
|
|
|
+ if (confirm == true)
|
|
|
+ {
|
|
|
+ using (await MaterialDialog.Instance.LoadingDialogAsync(message: "Deleting Assignment"))
|
|
|
+ {
|
|
|
+ var assignment = new Assignment() { ID = id };
|
|
|
+ new Client<Assignment>().Delete(assignment, "Deleted on Mobile Device");
|
|
|
}
|
|
|
+
|
|
|
+ Refresh();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|