|
@@ -30,14 +30,14 @@ namespace comal.timesheets
|
|
|
UnbookedJobs,
|
|
|
Tasks
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public partial class AssignmentList : ContentPage
|
|
|
{
|
|
|
|
|
|
private AssignmentEdit _editor = null;
|
|
|
|
|
|
private Guid[] _employeeids = new Guid[] { };
|
|
|
-
|
|
|
+
|
|
|
private AssignmentModuleSettings _settings = null;
|
|
|
|
|
|
private AssignmentView _view = AssignmentView.Day;
|
|
@@ -56,11 +56,11 @@ namespace comal.timesheets
|
|
|
|
|
|
_jobs = new AssignmentJobDataModel();
|
|
|
_kanbans = new AssignmentKanbanDataModel();
|
|
|
-
|
|
|
+
|
|
|
DatePicker.Date = _settings.Date.IsEmpty() ? DateTime.Today : _settings.Date;
|
|
|
-
|
|
|
+
|
|
|
_view = _settings.View;
|
|
|
-
|
|
|
+
|
|
|
_employeeids = (_settings.Employees != null)
|
|
|
? _settings.Employees
|
|
|
: new Guid[] { App.Data.Employee.ID };
|
|
@@ -71,20 +71,20 @@ namespace comal.timesheets
|
|
|
_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),
|
|
|
+ new Filter<Kanban>(x => x.Completed).IsEqualTo(DateTime.MinValue),
|
|
|
() => Dispatcher.BeginInvokeOnMainThread(() =>
|
|
|
{
|
|
|
Lookups.ItemsSource = new ObservableCollection<AssignmentKanbanItem>(_kanbans.Items);
|
|
@@ -93,32 +93,32 @@ namespace comal.timesheets
|
|
|
else if (_lookuptype == AssignmentLookupType.ActiveJobs)
|
|
|
{
|
|
|
_jobs.Load(
|
|
|
- new Filter<Job>(x=>x.JobStatus.Active).IsEqualTo(true),
|
|
|
+ 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),
|
|
|
+ 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;
|
|
|
-
|
|
|
+ DayView.DataSource = null;
|
|
|
+ TimeLineView.DataSource = null;
|
|
|
+
|
|
|
ScheduleType.Text = _teamname;
|
|
|
-
|
|
|
+
|
|
|
if (_view == AssignmentView.Day)
|
|
|
{
|
|
|
DayViewColumn.Width = new GridLength(1, GridUnitType.Star);
|
|
@@ -130,10 +130,10 @@ 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(16, _employeeids.Length));
|
|
|
+ TimeLineView.ResourceViewSettings.VisibleResourceCount = Math.Max(1, Math.Min(16, _employeeids.Length));
|
|
|
TimeLineView.TimelineViewSettings.AppointmentHeight =
|
|
|
(this.Height / TimeLineView.ResourceViewSettings.VisibleResourceCount) + 100;
|
|
|
-
|
|
|
+
|
|
|
var resources = new ObservableCollection<object>();
|
|
|
foreach (var empid in _employeeids)
|
|
|
{
|
|
@@ -158,33 +158,43 @@ namespace comal.timesheets
|
|
|
}
|
|
|
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),
|
|
|
() =>
|
|
|
{
|
|
|
- Dispatcher.BeginInvokeOnMainThread(() =>{
|
|
|
+ Dispatcher.BeginInvokeOnMainThread(() =>
|
|
|
+ {
|
|
|
if (_view == AssignmentView.Day)
|
|
|
+ {
|
|
|
DayView.DataSource = new ObservableCollection<AssignmentListDataModelItem>(DataModel.Items);
|
|
|
+ DayView.MoveToDate = ShowRelevantTime();
|
|
|
+ }
|
|
|
else
|
|
|
+ {
|
|
|
TimeLineView.DataSource = new ObservableCollection<AssignmentListDataModelItem>(DataModel.Items);
|
|
|
+ TimeLineView.MoveToDate = ShowRelevantTime();
|
|
|
+ }
|
|
|
});
|
|
|
-
|
|
|
}
|
|
|
);
|
|
|
+ }
|
|
|
+
|
|
|
+ private DateTime ShowRelevantTime()
|
|
|
+ {
|
|
|
+ return (DataModel.Items.Count > 0 ? (DataModel.Items.First() as AssignmentListDataModelItem).StartTime : DateTime.Now).AddMinutes(-30);
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
private void SelectedDate_Tapped(object sender, EventArgs e)
|
|
|
{
|
|
|
DatePicker.Focus();
|
|
@@ -199,7 +209,7 @@ namespace comal.timesheets
|
|
|
}
|
|
|
DayView.MoveToDate = DatePicker.Date;
|
|
|
TimeLineView.MoveToDate = DatePicker.Date;
|
|
|
- Dispatcher.BeginInvokeOnMainThread(()=>
|
|
|
+ Dispatcher.BeginInvokeOnMainThread(() =>
|
|
|
{
|
|
|
Refresh();
|
|
|
});
|
|
@@ -210,9 +220,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.Select(x=>x.TeamName).Distinct());
|
|
|
+ actions.AddRange(GlobalVariables.TeamEmployeeShells.Select(x => x.TeamName).Distinct());
|
|
|
|
|
|
- var result = await MaterialDialog.Instance.SelectActionAsync(title: "Select a Team",
|
|
|
+ var result = await MaterialDialog.Instance.SelectActionAsync(title: "Select a Team",
|
|
|
actions: actions);
|
|
|
|
|
|
if (result == 0)
|
|
@@ -233,13 +243,13 @@ namespace comal.timesheets
|
|
|
_settings.View = _view;
|
|
|
_settings.TeamName = _teamname;
|
|
|
new LocalConfiguration<AssignmentModuleSettings>().Save(_settings);
|
|
|
-
|
|
|
- Dispatcher.BeginInvokeOnMainThread(()=>
|
|
|
+
|
|
|
+ Dispatcher.BeginInvokeOnMainThread(() =>
|
|
|
{
|
|
|
Reload();
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private void Lookups_OnItemTapped(object sender, ItemTappedEventArgs e)
|
|
|
{
|
|
|
if (e.Item is AssignmentLookupItem lookup)
|
|
@@ -269,10 +279,10 @@ namespace comal.timesheets
|
|
|
: AssignmentLookupType.Tasks;
|
|
|
_settings.LookupType = _lookuptype;
|
|
|
LookupType.Text = CoreUtils.Neatify(_lookuptype.ToString());
|
|
|
- new LocalConfiguration<AssignmentModuleSettings>().Save(_settings);
|
|
|
+ new LocalConfiguration<AssignmentModuleSettings>().Save(_settings);
|
|
|
RefreshLookups();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private async void Schedule_OnCellTapped(object sender, CellTappedEventArgs e)
|
|
|
{
|
|
|
if (e.Appointment is AssignmentListDataModelItem item)
|
|
@@ -281,7 +291,7 @@ namespace comal.timesheets
|
|
|
Navigation.PushAsync(editor);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private async void Schedule_OnCellLongPressed(object sender, CellTappedEventArgs e)
|
|
|
{
|
|
|
if (e.Appointment == null)
|
|
@@ -295,7 +305,7 @@ namespace comal.timesheets
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
- else if (InABox.Core.Security.CanDelete<Assignment>()
|
|
|
+ else if (InABox.Core.Security.CanDelete<Assignment>()
|
|
|
&& e.Appointment is AssignmentListDataModelItem assignment)
|
|
|
{
|
|
|
await DeleteAssignment(assignment.Id);
|
|
@@ -303,7 +313,7 @@ namespace comal.timesheets
|
|
|
}
|
|
|
|
|
|
private void CreateAssignment(DateTime date, ScheduleResource resource)
|
|
|
- {
|
|
|
+ {
|
|
|
var assignment = new Assignment()
|
|
|
{
|
|
|
Date = date.Date,
|
|
@@ -316,7 +326,7 @@ namespace comal.timesheets
|
|
|
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;
|
|
@@ -329,10 +339,10 @@ namespace comal.timesheets
|
|
|
assignment.Title = job.Name;
|
|
|
job.Selected = false;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
var task = _lookuptype == AssignmentLookupType.Tasks
|
|
|
? _kanbans.Items.FirstOrDefault(x => x.Selected)
|
|
|
- : null;
|
|
|
+ : null;
|
|
|
if (task != null)
|
|
|
{
|
|
|
assignment.Task.ID = task.Id;
|
|
@@ -341,12 +351,12 @@ namespace comal.timesheets
|
|
|
assignment.Title = task.Name;
|
|
|
assignment.Description = task.Description;
|
|
|
task.Selected = false;
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
var editor = new AssignmentEdit(assignment);
|
|
|
- Navigation.PushAsync(editor);
|
|
|
+ Navigation.PushAsync(editor);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private async Task DeleteAssignment(Guid id)
|
|
|
{
|
|
|
var confirm = await MaterialDialog.Instance.ConfirmAsync(
|