|
@@ -1,11 +1,14 @@
|
|
|
using System;
|
|
|
using System.Linq;
|
|
|
using System.Threading.Tasks;
|
|
|
+using Avalonia.Controls;
|
|
|
+using Comal.Classes;
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
using InABox.Avalonia;
|
|
|
using InABox.Avalonia.Components;
|
|
|
using InABox.Configuration;
|
|
|
+using InABox.Core;
|
|
|
using PRS.Avalonia.Components;
|
|
|
using PRS.Avalonia.Dialogs;
|
|
|
|
|
@@ -35,6 +38,24 @@ public partial class SiteViewModel : ModuleViewModel
|
|
|
Modules.Add<SiteTasksViewModel>("Job Tasks", "Manage Tasks for this Job", Images.task, LaunchSiteModule);
|
|
|
Modules.Add<SiteRequisitionsViewModel>("Site Requisitions", "Create/Edit Site Requis for this Job", Images.trolley, LaunchSiteModule);
|
|
|
Modules.Add<SiteDeliveriesViewModel>("Deliveries", "View Deliveries for this Job", Images.delivery, LaunchSiteModule);
|
|
|
+
|
|
|
+ foreach(var module in Modules.Items)
|
|
|
+ {
|
|
|
+ module.IsEnabled = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private async Task<bool> HasJob()
|
|
|
+ {
|
|
|
+ if(SelectedJob is null)
|
|
|
+ {
|
|
|
+ await MessageDialog.ShowMessage("Please select a job first.");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void LaunchSiteModule(SiteModuleViewModel model)
|
|
@@ -52,17 +73,42 @@ public partial class SiteViewModel : ModuleViewModel
|
|
|
await Task.CompletedTask;
|
|
|
}
|
|
|
|
|
|
+ partial void OnSelectedJobChanged(JobShell? value)
|
|
|
+ {
|
|
|
+ foreach(var module in Modules.Items)
|
|
|
+ {
|
|
|
+ module.IsEnabled = value != null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
[RelayCommand]
|
|
|
- private void SelectJob()
|
|
|
+ private async Task SelectJob()
|
|
|
{
|
|
|
- Navigation.Navigate<SelectJobDialogViewModel>((vm) =>
|
|
|
+ var job = (await SelectionViewModel.ExecutePopup<JobShell>(model =>
|
|
|
+ {
|
|
|
+ model.Columns.BeginUpdate()
|
|
|
+ .Add(new AvaloniaDataGridTextColumn<JobShell>
|
|
|
+ {
|
|
|
+ Column = x => x.JobNumber,
|
|
|
+ Caption = "Number",
|
|
|
+ Width = GridLength.Auto
|
|
|
+ })
|
|
|
+ .Add(new AvaloniaDataGridTextColumn<JobShell>
|
|
|
+ {
|
|
|
+ Column = x => x.Name,
|
|
|
+ Caption = "Name",
|
|
|
+ Width = GridLength.Star
|
|
|
+ })
|
|
|
+ .EndUpdate();
|
|
|
+ model.AddFilters(Repositories.Jobs.AvailableFilters.Select(x => x.Name).NotNull());
|
|
|
+ }, args =>
|
|
|
{
|
|
|
- vm.JobSelectedCommand = new RelayCommand<JobShell>((job) =>
|
|
|
- {
|
|
|
- Settings.JobID = job?.ID ?? Guid.Empty;
|
|
|
- new LocalConfiguration<SiteModuleSettings>().Save(Settings);
|
|
|
- Navigation.Back();
|
|
|
- });
|
|
|
- });
|
|
|
+ Repositories.Jobs.SelectFilter(args.Filter);
|
|
|
+ return Repositories.Jobs.Refresh(args.Force);
|
|
|
+ }))?.FirstOrDefault();
|
|
|
+ if (job is null) return;
|
|
|
+
|
|
|
+ Settings.JobID = job.ID;
|
|
|
+ SelectedJob = job;
|
|
|
}
|
|
|
}
|