|
|
@@ -31,6 +31,7 @@ using PdfGraphics = InABox.Dxf.PdfGraphics;
|
|
|
using PRSDimensionUtils;
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
using InABox.Wpf.Editors;
|
|
|
+using Microsoft.Xaml.Behaviors.Core;
|
|
|
using PRSDesktop.Panels.Staging;
|
|
|
|
|
|
|
|
|
@@ -123,10 +124,12 @@ public class StagingSetoutGrid : DynamicDataGrid<Setout>
|
|
|
private readonly BitmapImage rejected = PRSDesktop.Resources.disabled.AsBitmapImage();
|
|
|
private readonly BitmapImage forms = PRSDesktop.Resources.quality.AsBitmapImage();
|
|
|
|
|
|
+ private Button MultiMenuButton;
|
|
|
private Button CopyPacketsButton;
|
|
|
private Button PastePacketsButton;
|
|
|
private Setout? CopyPacketsSource;
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
private Dictionary<Guid, byte[]?> _formDocuments = new();
|
|
|
|
|
|
public StagingPanellSettings PanelSettings { get; set; } = new StagingPanellSettings();
|
|
|
@@ -163,11 +166,13 @@ public class StagingSetoutGrid : DynamicDataGrid<Setout>
|
|
|
|
|
|
ActionColumns.Add(new DynamicMenuColumn(Menu_Build));
|
|
|
|
|
|
- AddEditButton("Create Group", null, CreateGroup);
|
|
|
+ MultiMenuButton = AddEditButton("", PRSDesktop.Resources.menu.AsBitmapImage(), BuildMultiMenu);
|
|
|
|
|
|
CopyPacketsButton = AddEditButton("Copy Packets", PRSDesktop.Resources.copy.AsBitmapImage(), CopyPackets);
|
|
|
PastePacketsButton = AddEditButton("Paste Packets", InABox.Wpf.Resources.paste.AsBitmapImage(), PastePackets);
|
|
|
PastePacketsButton.Visibility = Visibility.Collapsed;
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
protected override void Reload(Filters<Setout> criteria, Columns<Setout> columns,
|
|
|
@@ -203,7 +208,7 @@ public class StagingSetoutGrid : DynamicDataGrid<Setout>
|
|
|
protected override void SelectItems(CoreRow[]? rows)
|
|
|
{
|
|
|
base.SelectItems(rows);
|
|
|
-
|
|
|
+
|
|
|
if (CopyPacketsSource is null)
|
|
|
{
|
|
|
CopyPacketsButton.IsEnabled = rows?.Length == 1;
|
|
|
@@ -880,14 +885,94 @@ public class StagingSetoutGrid : DynamicDataGrid<Setout>
|
|
|
options.DeleteRows = true;
|
|
|
}
|
|
|
|
|
|
- private bool CreateGroup(Button arg1, CoreRow[] rows)
|
|
|
+ private bool BuildMultiMenu(Button arg1, CoreRow[] rows)
|
|
|
{
|
|
|
- if (!rows.Any())
|
|
|
- {
|
|
|
- MessageWindow.ShowMessage("Please select at least one row to add to group", "No rows selected.");
|
|
|
+ ContextMenu menu = new ContextMenu();
|
|
|
+
|
|
|
+ menu.Items.Add(
|
|
|
+ new MenuItem()
|
|
|
+ {
|
|
|
+ Header = "Create Group",
|
|
|
+ Command = new ActionCommand(
|
|
|
+ () =>
|
|
|
+ {
|
|
|
+ if (CreateGroup(rows))
|
|
|
+ Refresh(false,true);
|
|
|
+ }
|
|
|
+ ),
|
|
|
+ IsEnabled = rows?.Any() == true
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ menu.Items.Add(new Separator());
|
|
|
+
|
|
|
+ menu.Items.Add(
|
|
|
+ new MenuItem()
|
|
|
+ {
|
|
|
+ Header = "Approve Setouts",
|
|
|
+ Command = new ActionCommand(
|
|
|
+ () =>
|
|
|
+ {
|
|
|
+ if (UpdateApproval(rows, SetoutStatus.Approved))
|
|
|
+ Refresh(false,true);
|
|
|
+ }
|
|
|
+ ),
|
|
|
+ IsEnabled = rows?.Any() == true
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ menu.Items.Add(
|
|
|
+ new MenuItem()
|
|
|
+ {
|
|
|
+ Header = "Unapprove Setouts",
|
|
|
+ Command = new ActionCommand(
|
|
|
+ () =>
|
|
|
+ {
|
|
|
+ if (UpdateApproval(rows, SetoutStatus.Unapproved))
|
|
|
+ Refresh(false,true);
|
|
|
+ }
|
|
|
+ ),
|
|
|
+ IsEnabled = rows?.Any() == true
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ menu.Items.Add(
|
|
|
+ new MenuItem()
|
|
|
+ {
|
|
|
+ Header = "Cancel Setouts",
|
|
|
+ Command = new ActionCommand(
|
|
|
+ () =>
|
|
|
+ {
|
|
|
+ if (UpdateApproval(rows, SetoutStatus.Cancelled))
|
|
|
+ Refresh(false,true);
|
|
|
+ }
|
|
|
+ ),
|
|
|
+ IsEnabled = rows?.Any() == true
|
|
|
+ }
|
|
|
+ );
|
|
|
+ menu.IsOpen = true;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool UpdateApproval(CoreRow[] rows, SetoutStatus status)
|
|
|
+ {
|
|
|
+ if (!MessageWindow.ShowOKCancel($"Change status to {status}?", "Proceed?"))
|
|
|
return false;
|
|
|
+ var items = rows.ToList<Setout>();
|
|
|
+ foreach (var item in items)
|
|
|
+ item.Status = status;
|
|
|
+ var updates = items.Where(x => x.IsChanged()).ToArray();
|
|
|
+ if (updates.Any())
|
|
|
+ {
|
|
|
+ new Client<Setout>().Save(updates, $"Updated Status to {status}");
|
|
|
+ return true;
|
|
|
}
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
+ private bool CreateGroup(CoreRow[] rows)
|
|
|
+ {
|
|
|
+
|
|
|
var list = rows.ToList<Setout>();
|
|
|
|
|
|
string message = "";
|