|
@@ -1,5 +1,8 @@
|
|
|
-using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
+using Comal.Classes;
|
|
|
+using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
+using InABox.Avalonia.Components;
|
|
|
+using PRS.Avalonia.DigitalForms;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
@@ -10,7 +13,7 @@ namespace PRS.Avalonia.Modules;
|
|
|
|
|
|
public partial class SiteITPFormsViewModel : ModuleViewModel
|
|
|
{
|
|
|
- public override string Title => ITPs.FirstOrDefault(x => x.ID == ItpID)?.Description ?? "No ITP Selected";
|
|
|
+ public override string Title => ITP?.Description ?? "No ITP Selected";
|
|
|
|
|
|
[ObservableProperty]
|
|
|
private Guid _itpID;
|
|
@@ -21,6 +24,28 @@ public partial class SiteITPFormsViewModel : ModuleViewModel
|
|
|
[ObservableProperty]
|
|
|
private JobITPFormModel _forms;
|
|
|
|
|
|
+ public JobITPShell? ITP => ITPs.FirstOrDefault(x => x.ID == ItpID);
|
|
|
+
|
|
|
+ public SiteITPFormsViewModel()
|
|
|
+ {
|
|
|
+ PrimaryMenu.Add(new AvaloniaMenuItem(Images.plus, AddForm));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void AddForm()
|
|
|
+ {
|
|
|
+ var itp = ITP;
|
|
|
+ if (itp is null) return;
|
|
|
+
|
|
|
+ var newForm = Forms.AddItem();
|
|
|
+ newForm.ParentID = itp.ID;
|
|
|
+ newForm.FormID = itp.FormID;
|
|
|
+ newForm.FormCode = itp.FormCode;
|
|
|
+ newForm.FormDescription = itp.FormName;
|
|
|
+ newForm.Save("Created on Mobile Device");
|
|
|
+
|
|
|
+ Forms.Search();
|
|
|
+ }
|
|
|
+
|
|
|
protected override async Task<TimeSpan> OnRefresh()
|
|
|
{
|
|
|
await Task.WhenAll([
|
|
@@ -33,6 +58,8 @@ public partial class SiteITPFormsViewModel : ModuleViewModel
|
|
|
[RelayCommand]
|
|
|
private void FormClicked(JobITPFormShell shell)
|
|
|
{
|
|
|
+ if (ITP is not JobITPShell itp) return;
|
|
|
|
|
|
+ DigitalFormsHostViewModel.EditForm<JobITP, JobITPLink, JobITPForm>(shell, itp.Entity);
|
|
|
}
|
|
|
}
|