mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-04 07:19:24 -05:00
feat(data): store a nest's job number apart from the customer
Job numbers were going into Customer ("GM / 4980-88R"), which breaks
sorting, searching and grouping by customer. A nest now has its own
Job # field: one or several jobs separated by commas, normalized to
"a, b". It is saved in nest.json and the server (schema v21), edited
beside Customer in Edit Nest (WinForms and Avalonia), shown as a
sortable, searchable column in the Open list, and printed on the nest
report and in MCP output.
Deploy the server before the desktop: the open overlay takes the
server's job number, and an older server has none.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
857b88a2c7
commit
bfdfefeb9e
40 files changed
+304
-44
No files matched your search
@@ -19,7 +19,7 @@ namespace OpenNest.Avalonia
|
||||
|
||||
/// <summary>
|
||||
/// Nest > Edit, as the WinForms Edit Nest dialog: the Info tab (name, dates, thickness,
|
||||
/// material and grade, customer, units, status and author), the Defaults tab (the plate
|
||||
/// material and grade, customer, job number, units, status and author), the Defaults tab (the plate
|
||||
/// size, part and edge spacing and quadrant new plates start from, and whether new nests
|
||||
/// start from them too) and the Notes tab. The name is read-only unless renaming is
|
||||
/// allowed (in File mode the name is the file's, set by Save As). Done is enabled while
|
||||
@@ -35,6 +35,7 @@ namespace OpenNest.Avalonia
|
||||
private readonly EditableCombo material = new() { Name = "Material" };
|
||||
private readonly EditableCombo grade = new() { Name = "Grade" };
|
||||
private readonly TextBox customer = new() { Name = "Customer" };
|
||||
private readonly TextBox jobNumber = new() { Name = "JobNumber", Watermark = "Separate several with commas" };
|
||||
private readonly RadioButton inches = new() { Name = "Inches", Content = "Inches", GroupName = "NestUnits" };
|
||||
private readonly RadioButton millimeters = new() { Name = "Millimeters", Content = "Millimeters", GroupName = "NestUnits" };
|
||||
private readonly ComboBox status = new() { Name = "Status", HorizontalAlignment = HorizontalAlignment.Stretch };
|
||||
@@ -85,6 +86,7 @@ namespace OpenNest.Avalonia
|
||||
created.Text = values.DateCreated.ToShortDateString();
|
||||
modified.Text = values.DateLastModified.ToShortDateString();
|
||||
customer.Text = values.Customer;
|
||||
jobNumber.Text = values.JobNumber;
|
||||
madeBy.Text = values.MadeBy;
|
||||
notes.Text = values.Notes;
|
||||
size.Text = values.SizeText;
|
||||
@@ -189,6 +191,7 @@ namespace OpenNest.Avalonia
|
||||
("Material :", material),
|
||||
("Grade :", grade),
|
||||
("Customer :", customer),
|
||||
("Job # :", jobNumber),
|
||||
("Units :", unitsRow),
|
||||
("Status :", status),
|
||||
("Made By :", madeBy));
|
||||
@@ -358,6 +361,7 @@ namespace OpenNest.Avalonia
|
||||
MaterialName = material.Text,
|
||||
MaterialGrade = grade.Text,
|
||||
Customer = customer.Text ?? "",
|
||||
JobNumber = jobNumber.Text ?? "",
|
||||
Units = SelectedUnits,
|
||||
Status = status.SelectedItem is NestStatus value ? value : NestStatus.Quote,
|
||||
MadeBy = madeBy.Text ?? "",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenNest.Clamps;
|
||||
using OpenNest.Collections;
|
||||
using OpenNest.CommonLines;
|
||||
@@ -45,6 +46,33 @@ namespace OpenNest
|
||||
|
||||
public string Customer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The job (or jobs) this nest cuts parts for, such as "4980-88R"; several are separated
|
||||
/// by commas ("4980-88R, 4981-02"). Setting it trims each number, drops empty ones and
|
||||
/// joins them with ", "; blank when the nest has none.
|
||||
/// </summary>
|
||||
public string JobNumber
|
||||
{
|
||||
get { return jobNumber; }
|
||||
set { jobNumber = NormalizeJobNumbers(value); }
|
||||
}
|
||||
|
||||
private string jobNumber = "";
|
||||
|
||||
/// <summary>
|
||||
/// <paramref name="text"/> as <see cref="JobNumber"/> stores it: each comma-separated
|
||||
/// number trimmed, empty ones dropped, joined with ", ".
|
||||
/// </summary>
|
||||
public static string NormalizeJobNumbers(string text)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
return "";
|
||||
var numbers = text.Split(',')
|
||||
.Select(n => n.Trim())
|
||||
.Where(n => n.Length > 0);
|
||||
return string.Join(", ", numbers);
|
||||
}
|
||||
|
||||
public string Notes { get; set; }
|
||||
|
||||
public string AssistGas { get; set; } = "";
|
||||
|
||||
@@ -23,6 +23,12 @@ public sealed class NestRecord
|
||||
|
||||
public string Customer { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// The nest's job number or comma-separated job numbers (<see cref="Nest.JobNumber"/>);
|
||||
/// blank when the nest has none or the server predates job numbers.
|
||||
/// </summary>
|
||||
public string JobNumber { get; set; } = "";
|
||||
|
||||
public DateTime DateCreated { get; set; }
|
||||
|
||||
public DateTime DateModified { get; set; }
|
||||
|
||||
@@ -16,6 +16,7 @@ public static class NestRecordFactory
|
||||
ArgumentNullException.ThrowIfNull(record);
|
||||
nest.Name = record.Name;
|
||||
nest.Customer = record.Customer;
|
||||
nest.JobNumber = record.JobNumber;
|
||||
nest.Notes = record.Comments;
|
||||
nest.Status = record.Status;
|
||||
nest.MadeBy = record.MadeBy;
|
||||
@@ -42,6 +43,7 @@ public static class NestRecordFactory
|
||||
Id = id,
|
||||
Name = nest.Name ?? "",
|
||||
Customer = nest.Customer ?? "",
|
||||
JobNumber = nest.JobNumber ?? "",
|
||||
DateCreated = nest.DateCreated,
|
||||
DateModified = nest.DateLastModified,
|
||||
Material = nest.Material?.Name ?? "",
|
||||
|
||||
@@ -126,7 +126,7 @@ public sealed class NestSaveSession
|
||||
private static string Normalize(string? url) => (url ?? "").Trim().TrimEnd('/');
|
||||
|
||||
private static bool SameEditableMetadata(NestRecord a, NestRecord b) =>
|
||||
a.Name == b.Name && a.Customer == b.Customer && a.DateCreated == b.DateCreated
|
||||
a.Name == b.Name && a.Customer == b.Customer && a.JobNumber == b.JobNumber && a.DateCreated == b.DateCreated
|
||||
&& a.DateModified == b.DateModified && a.Material == b.Material && a.MaterialGrade == b.MaterialGrade
|
||||
&& a.Thickness == b.Thickness && a.ThicknessName == b.ThicknessName && a.Status == b.Status && a.PlateCount == b.PlateCount && a.PartCount == b.PartCount
|
||||
&& a.Comments == b.Comments && a.MadeBy == b.MadeBy;
|
||||
|
||||
@@ -17,4 +17,5 @@ public enum NestSortField
|
||||
Comments,
|
||||
FileSize,
|
||||
MaterialGrade,
|
||||
JobNumber,
|
||||
}
|
||||
@@ -10,6 +10,7 @@ public class NestInfoValuesTests
|
||||
var nest = TestNests.OneSquare();
|
||||
nest.Name = "N-1";
|
||||
nest.Customer = "Acme";
|
||||
nest.JobNumber = "4980-88R";
|
||||
nest.Notes = "rush";
|
||||
nest.Thickness = 0.25;
|
||||
nest.ThicknessName = "1/4\"";
|
||||
@@ -41,6 +42,7 @@ public class NestInfoValuesTests
|
||||
|
||||
Assert.Equal("N-1", target.Name);
|
||||
Assert.Equal("Acme", target.Customer);
|
||||
Assert.Equal("4980-88R", target.JobNumber);
|
||||
Assert.Equal("rush", target.Notes);
|
||||
Assert.Equal(0.25, target.Thickness);
|
||||
Assert.Equal("1/4\"", target.ThicknessName);
|
||||
@@ -105,6 +107,17 @@ public class NestInfoValuesTests
|
||||
Assert.NotEqual(before, NestInfoValues.UndoableKey(nest));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UndoableKey_RecordsAJobNumberEdit()
|
||||
{
|
||||
var nest = InfoNest();
|
||||
var before = NestInfoValues.UndoableKey(nest);
|
||||
|
||||
nest.JobNumber = "4981-02";
|
||||
|
||||
Assert.NotEqual(before, NestInfoValues.UndoableKey(nest));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UndoableKey_RecordsAThicknessNameEdit()
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace OpenNest.Desktop;
|
||||
|
||||
/// <summary>
|
||||
/// What Nest > Edit (the Edit Nest dialog) edits: the nest's name, dates, thickness and its name,
|
||||
/// material and grade, customer, status, author, units, notes and its plate defaults (size,
|
||||
/// material and grade, customer and job number, status, author, units, notes and its plate defaults (size,
|
||||
/// part and edge spacing, quadrant). <see cref="FromNest"/> reads a nest, <see cref="CanApply"/>
|
||||
/// is when the dialog's Done button is enabled and <see cref="ApplyTo"/> writes the nest as
|
||||
/// Done does.
|
||||
@@ -44,6 +44,9 @@ public sealed record NestInfoValues
|
||||
|
||||
public string Customer { get; init; } = "";
|
||||
|
||||
/// <summary>The job number, or several separated by commas; blank when the nest has none.</summary>
|
||||
public string JobNumber { get; init; } = "";
|
||||
|
||||
public NestStatus Status { get; init; } = NestStatus.Quote;
|
||||
|
||||
public string MadeBy { get; init; } = "";
|
||||
@@ -78,6 +81,7 @@ public sealed record NestInfoValues
|
||||
Name = nest.Name,
|
||||
Notes = nest.Notes,
|
||||
Customer = nest.Customer,
|
||||
JobNumber = nest.JobNumber ?? "",
|
||||
DateCreated = nest.DateCreated,
|
||||
DateLastModified = nest.DateLastModified,
|
||||
Thickness = nest.Thickness,
|
||||
@@ -124,6 +128,7 @@ public sealed record NestInfoValues
|
||||
nest.Units = Units;
|
||||
nest.Notes = Notes;
|
||||
nest.Customer = Customer;
|
||||
nest.JobNumber = JobNumber;
|
||||
nest.DateCreated = DateCreated;
|
||||
nest.DateLastModified = DateLastModified;
|
||||
nest.Thickness = Thickness;
|
||||
@@ -156,7 +161,7 @@ public sealed record NestInfoValues
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(nest);
|
||||
var defaults = nest.PlateDefaults;
|
||||
return string.Join("|", nest.Units, nest.Notes, nest.Customer, nest.Thickness, nest.ThicknessName, nest.Material?.Name,
|
||||
return string.Join("|", nest.Units, nest.Notes, nest.Customer, nest.JobNumber, nest.Thickness, nest.ThicknessName, nest.Material?.Name,
|
||||
nest.Material?.Grade, defaults.Size, defaults.PartSpacing, defaults.EdgeSpacing.Left,
|
||||
defaults.EdgeSpacing.Bottom, defaults.EdgeSpacing.Right, defaults.EdgeSpacing.Top, defaults.Quadrant);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,10 @@ namespace OpenNest.IO
|
||||
public string Status { get; init; } = "Quote";
|
||||
public string MadeBy { get; init; } = "";
|
||||
|
||||
/// <summary><c>Nest.JobNumber</c>; omitted when blank, and older files have none.</summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string JobNumber { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// The machine the nest is cut on. Omitted when none is assigned; older files and
|
||||
/// older readers simply have none.
|
||||
|
||||
@@ -734,6 +734,7 @@ namespace OpenNest.IO
|
||||
? status
|
||||
: NestStatus.Quote;
|
||||
nest.MadeBy = dto.MadeBy ?? "";
|
||||
nest.JobNumber = dto.JobNumber ?? "";
|
||||
nest.Machine = dto.Machine is { } machine ? new NestMachine(machine.Id, machine.Name) : null;
|
||||
|
||||
// Nest-level material and thickness (fall back to PlateDefaults for old files)
|
||||
|
||||
@@ -139,6 +139,7 @@ namespace OpenNest.IO
|
||||
AssistGas = nest.AssistGas ?? "",
|
||||
Status = nest.Status.ToString(),
|
||||
MadeBy = nest.MadeBy ?? "",
|
||||
JobNumber = string.IsNullOrEmpty(nest.JobNumber) ? null : nest.JobNumber,
|
||||
Machine = nest.Machine is { } machine
|
||||
? new MachineDto { Id = machine.Id, Name = machine.Name }
|
||||
: null,
|
||||
|
||||
@@ -405,7 +405,7 @@ namespace OpenNest.Mcp.Tools
|
||||
var read = SheetSizeTrials.Read(archive);
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine($"{record.Name} | id {record.Id} | revision {record.Revision} | {record.Status}");
|
||||
sb.AppendLine($"Material: {Material(record.Material, record.MaterialGrade, record.Thickness, read.Units)} | customer {Blank(record.Customer)} | made by {Blank(record.MadeBy)}");
|
||||
sb.AppendLine($"Material: {Material(record.Material, record.MaterialGrade, record.Thickness, read.Units)} | customer {Blank(record.Customer)} | job {Blank(record.JobNumber)} | made by {Blank(record.MadeBy)}");
|
||||
if (record.Comments.Length > 0)
|
||||
sb.AppendLine($"Comments: {record.Comments}");
|
||||
sb.AppendLine($"Plate defaults: {SheetSizes.Format(read.PlateDefaults.Size)}"
|
||||
|
||||
@@ -174,6 +174,7 @@ public static class NestPdfWriter
|
||||
{
|
||||
ReportFonts.ValidateText(snapshot.Name, "Nest name");
|
||||
ReportFonts.ValidateText(snapshot.Customer, "Customer");
|
||||
ReportFonts.ValidateText(snapshot.JobNumber, "Job number");
|
||||
ReportFonts.ValidateText(snapshot.Notes, "Notes");
|
||||
ReportFonts.ValidateText(snapshot.Material, "Material");
|
||||
ReportFonts.ValidateText(snapshot.Grade, "Material grade");
|
||||
@@ -197,6 +198,8 @@ public static class NestPdfWriter
|
||||
var left = new List<(string Key, string Value)> { ("Nest:", snapshot.Name) };
|
||||
if (snapshot.Customer.Length > 0)
|
||||
left.Add(("Customer:", snapshot.Customer));
|
||||
if (snapshot.JobNumber.Length > 0)
|
||||
left.Add(("Job #:", snapshot.JobNumber));
|
||||
var right = new List<(string Key, string Value)>
|
||||
{
|
||||
("Distinct layouts:", snapshot.Plates.Length.ToString(Invariant)),
|
||||
|
||||
@@ -46,6 +46,7 @@ public static class NestReportBuilder
|
||||
drawings.ToImmutable(), plates.ToImmutable())
|
||||
{
|
||||
HasCutTimes = cutParameters != null,
|
||||
JobNumber = nest.JobNumber ?? "",
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,9 @@ public sealed record NestReportSnapshot(string Name, string Customer, string Not
|
||||
/// </summary>
|
||||
public string ThicknessName { get; init; } = "";
|
||||
|
||||
/// <summary>The nest's job number or comma-separated job numbers; empty when it has none.</summary>
|
||||
public string JobNumber { get; init; } = "";
|
||||
|
||||
/// <summary>"lb" for inch jobs, "kg" for millimeter jobs.</summary>
|
||||
public string WeightUnits => Units == "mm" ? "kg" : "lb";
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public sealed class DrawingLibraryDatabaseTests
|
||||
using (var database = new NestDatabase(factory.DatabasePath, pooling: false))
|
||||
Assert.Empty(database.QueryDrawings(new DrawingLibraryQuery { IncludeArchived = true }).Items);
|
||||
Assert.Equal(before, NestDigest(factory.DatabasePath));
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(21L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
}
|
||||
|
||||
using var upgraded = new NestDatabase(factory.DatabasePath, pooling: false);
|
||||
@@ -44,7 +44,7 @@ public sealed class DrawingLibraryDatabaseTests
|
||||
|
||||
using (var database = new NestDatabase(factory.DatabasePath, pooling: false))
|
||||
{
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(21L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(before, NestDigest(factory.DatabasePath));
|
||||
// Two distinct blobs across four revisions: the bracket's notes edit and the
|
||||
// plate both reuse the bracket's first package.
|
||||
@@ -81,7 +81,7 @@ public sealed class DrawingLibraryDatabaseTests
|
||||
{
|
||||
using var factory = new ServerFactory();
|
||||
using (new NestDatabase(factory.DatabasePath, pooling: false)) { }
|
||||
Execute(factory.DatabasePath, "PRAGMA user_version=21");
|
||||
Execute(factory.DatabasePath, "PRAGMA user_version=22");
|
||||
|
||||
Assert.Throws<InvalidOperationException>(() => new NestDatabase(factory.DatabasePath, pooling: false));
|
||||
}
|
||||
@@ -106,7 +106,7 @@ public sealed class DrawingLibraryDatabaseTests
|
||||
""");
|
||||
|
||||
using var upgraded = new NestDatabase(factory.DatabasePath, pooling: false);
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(21L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(-3, upgraded.GetDrawing(record.Id)!.Settings.Priority);
|
||||
Assert.Equal(-3, Assert.Single(upgraded.DrawingHistory(record.Id, 0, 100)!.Items).Settings.Priority);
|
||||
Assert.Equal(int.MaxValue, upgraded.GetDrawing(other.Id)!.Settings.Priority);
|
||||
|
||||
@@ -23,7 +23,7 @@ public sealed class DrawingSetDatabaseTests
|
||||
using (var database = new NestDatabase(factory.DatabasePath, pooling: false))
|
||||
Assert.Empty(database.QueryDrawingSets(new DrawingSetQuery { IncludeArchived = true }).Items);
|
||||
Assert.Equal(before, Digest(factory.DatabasePath));
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(21L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
}
|
||||
|
||||
using var upgraded = new NestDatabase(factory.DatabasePath, pooling: false);
|
||||
@@ -48,7 +48,7 @@ public sealed class DrawingSetDatabaseTests
|
||||
Assert.Equal(before, Digest(factory.DatabasePath));
|
||||
Execute(factory.DatabasePath, "DROP TABLE ix_drawing_set_members_drawing");
|
||||
using var database = new NestDatabase(factory.DatabasePath, pooling: false);
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(21L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -25,7 +25,7 @@ public sealed class MaterialListTests
|
||||
|
||||
using var upgraded = new NestDatabase(factory.DatabasePath, pooling: false);
|
||||
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(21L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Empty(upgraded.ListMaterials());
|
||||
Assert.Equal((" Stainless ", "304"), (upgraded.Get(nest)!.Material, upgraded.Get(nest)!.MaterialGrade));
|
||||
Assert.Equal(drawing.MaterialName, upgraded.GetDrawing(drawing.Id)!.MaterialName);
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
using OpenNest.Data;
|
||||
using static OpenNest.Server.Tests.TestDatabase;
|
||||
|
||||
namespace OpenNest.Server.Tests;
|
||||
|
||||
public sealed class NestJobNumberTests
|
||||
{
|
||||
[Fact]
|
||||
public void JobNumber_RoundTripsThroughInsertUpdateAndHistory()
|
||||
{
|
||||
using var factory = new ServerFactory();
|
||||
using var database = new NestDatabase(factory.DatabasePath, pooling: false);
|
||||
var id = Guid.NewGuid();
|
||||
|
||||
var created = database.Insert(id, Record("Job", "4980-88R"), [1]);
|
||||
Assert.Equal("4980-88R", created.JobNumber);
|
||||
|
||||
var unchanged = database.UpdateMetadata(id, Record("Job", "4980-88R"), created.Revision)!;
|
||||
Assert.Equal(created.Revision, unchanged.Revision);
|
||||
|
||||
var updated = database.UpdateMetadata(id, Record("Job", "4980-88R,4981-02"), created.Revision)!;
|
||||
Assert.Equal("4980-88R, 4981-02", updated.JobNumber);
|
||||
Assert.Equal(created.Revision + 1, updated.Revision);
|
||||
|
||||
var history = database.History(id, 0, 10)!;
|
||||
Assert.Equal(["4980-88R, 4981-02", "4980-88R"], history.Items.Select(r => r.JobNumber));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Query_SearchesAndSortsByJobNumber()
|
||||
{
|
||||
using var factory = new ServerFactory();
|
||||
using var database = new NestDatabase(factory.DatabasePath, pooling: false);
|
||||
database.Insert(Guid.NewGuid(), Record("A", "4981-02"), [1]);
|
||||
database.Insert(Guid.NewGuid(), Record("B", "4980-88R, 4156"), [1]);
|
||||
database.Insert(Guid.NewGuid(), Record("C", ""), [1]);
|
||||
|
||||
var found = database.Query(new NestQuery { Search = "4156" });
|
||||
Assert.Equal("B", Assert.Single(found.Items).Name);
|
||||
|
||||
var sorted = database.Query(new NestQuery { Sort = NestSortField.JobNumber, Descending = false });
|
||||
Assert.Equal(["C", "B", "A"], sorted.Items.Select(r => r.Name));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Version20Database_GainsBlankJobNumbersAndKeepsRecords()
|
||||
{
|
||||
using var factory = new ServerFactory();
|
||||
var id = Guid.NewGuid();
|
||||
using (var database = new NestDatabase(factory.DatabasePath, pooling: false))
|
||||
database.Insert(id, Record("Legacy", "4980-88R"), [1]);
|
||||
Execute(factory.DatabasePath, """
|
||||
ALTER TABLE nests DROP COLUMN jobNumber;
|
||||
ALTER TABLE nest_revisions DROP COLUMN jobNumber;
|
||||
PRAGMA user_version=20;
|
||||
""");
|
||||
|
||||
using var upgraded = new NestDatabase(factory.DatabasePath, pooling: false);
|
||||
|
||||
var record = upgraded.Get(id)!;
|
||||
Assert.Equal("GM", record.Customer);
|
||||
Assert.Equal("", record.JobNumber);
|
||||
Assert.Equal("", Assert.Single(upgraded.History(id, 0, 10)!.Items).JobNumber);
|
||||
Assert.Equal(21L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
}
|
||||
|
||||
private static NestRecord Record(string name, string jobNumber) => new()
|
||||
{
|
||||
Name = name,
|
||||
Customer = "GM",
|
||||
JobNumber = jobNumber,
|
||||
Material = "Mild Steel",
|
||||
Thickness = 0.135,
|
||||
DateCreated = new DateTime(2026, 1, 1),
|
||||
DateModified = new DateTime(2026, 1, 2),
|
||||
};
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public sealed class NestMaterialGradeTests
|
||||
Assert.Equal("Stainless", record.Material);
|
||||
Assert.Equal("", record.MaterialGrade);
|
||||
Assert.Equal("", Assert.Single(upgraded.History(id, 0, 10)!.Items).MaterialGrade);
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(21L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
}
|
||||
|
||||
private static NestRecord Record(string name, string material, string grade) => new()
|
||||
|
||||
@@ -370,6 +370,7 @@ public sealed class NestQueryTests : IDisposable
|
||||
DateModified = new DateTime(2026, 1, 2 + index % 27, 9, 0, 0, DateTimeKind.Unspecified),
|
||||
Material = index % 3 == 0 ? "Synthetic steel" : "Synthetic alloy",
|
||||
MaterialGrade = index % 4 == 0 ? "" : $"Grade {index % 5}",
|
||||
JobNumber = index % 3 == 0 ? "" : $"{4980 + index % 4}-{(index % 2 == 0 ? "r" : "R")}",
|
||||
Thickness = 0.25 + index % 3 * 0.125,
|
||||
Status = statuses[index % statuses.Length],
|
||||
PlateCount = 1 + index % 4,
|
||||
@@ -412,6 +413,7 @@ public sealed class NestQueryTests : IDisposable
|
||||
NestSortField.Comments => Text(r => r.Comments),
|
||||
NestSortField.FileSize => (a, b) => a.FileSize.CompareTo(b.FileSize),
|
||||
NestSortField.MaterialGrade => Text(r => r.MaterialGrade),
|
||||
NestSortField.JobNumber => Text(r => r.JobNumber),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(field)),
|
||||
};
|
||||
var sorted = records.ToList();
|
||||
|
||||
@@ -119,7 +119,7 @@ public sealed class NestStockCodesTests
|
||||
database.SetDeleted(deleted, false, record.Revision);
|
||||
Assert.Equal(["SHEET-1", "SHEET-2"], database.StockCodesInUse(null).Select(u => u.ItemCode));
|
||||
}
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(21L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
}
|
||||
|
||||
private static Nest Nest(string name, NestStatus status, params string[][] plateCodes)
|
||||
|
||||
@@ -58,7 +58,7 @@ public sealed class NestThicknessNameTests
|
||||
Assert.Equal(0.135, record.Thickness);
|
||||
Assert.Equal("", record.ThicknessName);
|
||||
Assert.Equal("", Assert.Single(upgraded.History(id, 0, 10)!.Items).ThicknessName);
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(21L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
}
|
||||
|
||||
private static NestRecord Record(string name, string thicknessName) => new()
|
||||
|
||||
@@ -77,7 +77,7 @@ public sealed class NestUnitsTests
|
||||
Assert.Equal([Units.Millimeters, Units.Millimeters], upgraded.History(metric, 0, 10)!.Items.Select(r => r.Units));
|
||||
Assert.Equal(Units.Inches, upgraded.Get(inch)!.Units);
|
||||
Assert.Equal(Units.Inches, upgraded.Get(unreadable)!.Units);
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(21L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
}
|
||||
|
||||
private static NestRecord Record(string name, Units units) => new()
|
||||
|
||||
@@ -152,7 +152,7 @@ public sealed class SetReleaseDrawingTests
|
||||
|
||||
using var upgraded = new NestDatabase(factory.DatabasePath, pooling: false);
|
||||
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(21L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
var kept = upgraded.GetRelease(releaseId)!;
|
||||
Assert.Empty(kept.Drawings);
|
||||
Assert.Equal(((Guid?)kit.Id, drawing, 2), (kept.Nests[0].Items.Single().SetId, kept.Nests[0].Items.Single().DrawingId, kept.Nests[0].Items.Single().Quantity));
|
||||
|
||||
@@ -295,7 +295,7 @@ public sealed class SetReleaseTests
|
||||
|
||||
using var upgraded = new NestDatabase(factory.DatabasePath, pooling: false);
|
||||
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(21L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(0L, Scalar(factory.DatabasePath, "SELECT COUNT(*) FROM sqlite_master WHERE name LIKE 'set_release%' OR name LIKE 'ix_set_release%'"));
|
||||
var release = upgraded.GetRelease(releaseId)!;
|
||||
Assert.Equal(("Legacy notes", "Legacy operator", false), (release.Notes, release.ReleasedBy, release.IsUndone));
|
||||
|
||||
@@ -101,7 +101,7 @@ public sealed class SharedSettingsTests
|
||||
|
||||
using var upgraded = new NestDatabase(factory.DatabasePath, pooling: false);
|
||||
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(21L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Empty(upgraded.ListSharedSettings());
|
||||
}
|
||||
|
||||
|
||||
@@ -154,10 +154,10 @@ public sealed partial class NestDatabase : IDisposable
|
||||
command.Transaction = transaction;
|
||||
command.CommandText = """
|
||||
INSERT INTO nests (id, name, customer, dateCreated, dateModified, material,
|
||||
materialGrade, thickness, thicknessName, units, status, plateCount, partCount, comments, madeBy,
|
||||
materialGrade, thickness, thicknessName, jobNumber, units, status, plateCount, partCount, comments, madeBy,
|
||||
fileSize, savedAt, file)
|
||||
VALUES ($id, $name, $customer, $dateCreated, $dateModified, $material,
|
||||
$materialGrade, $thickness, $thicknessName, $units, $status, $plateCount, $partCount, $comments,
|
||||
$materialGrade, $thickness, $thicknessName, $jobNumber, $units, $status, $plateCount, $partCount, $comments,
|
||||
$madeBy, $fileSize, $savedAt, $file)
|
||||
""";
|
||||
AddRecordParameters(command, id, record, file, updateFile: true);
|
||||
@@ -212,7 +212,7 @@ public sealed partial class NestDatabase : IDisposable
|
||||
UPDATE nests SET
|
||||
name = $name, customer = $customer, dateCreated = $dateCreated,
|
||||
dateModified = $dateModified, material = $material,
|
||||
materialGrade = $materialGrade, thickness = $thickness, thicknessName = $thicknessName, units = $units, status = $status, plateCount = $plateCount,
|
||||
materialGrade = $materialGrade, thickness = $thickness, thicknessName = $thicknessName, jobNumber = $jobNumber, units = $units, status = $status, plateCount = $plateCount,
|
||||
partCount = $partCount, comments = $comments, madeBy = $madeBy,
|
||||
savedAt = $savedAt, revision = $revision, restoredFromRevision=$source{fileClause}
|
||||
WHERE id = $id
|
||||
@@ -317,7 +317,7 @@ public sealed partial class NestDatabase : IDisposable
|
||||
}
|
||||
|
||||
private static bool SameMetadata(NestRecord a, NestRecord b) =>
|
||||
a.Name == b.Name && a.Customer == b.Customer && a.DateCreated == b.DateCreated &&
|
||||
a.Name == b.Name && a.Customer == b.Customer && a.JobNumber == b.JobNumber && a.DateCreated == b.DateCreated &&
|
||||
a.DateModified == b.DateModified && a.Material == b.Material && a.MaterialGrade == b.MaterialGrade &&
|
||||
a.Thickness == b.Thickness && a.ThicknessName == b.ThicknessName && a.Units == b.Units && a.Status == b.Status && a.PlateCount == b.PlateCount && a.PartCount == b.PartCount &&
|
||||
a.Comments == b.Comments && a.MadeBy == b.MadeBy;
|
||||
@@ -352,7 +352,7 @@ public sealed partial class NestDatabase : IDisposable
|
||||
command.Transaction = transaction;
|
||||
command.CommandText = "PRAGMA user_version";
|
||||
var version = (long)command.ExecuteScalar()!;
|
||||
if (version > 20) throw new InvalidOperationException("Database schema is newer than this server.");
|
||||
if (version > 21) throw new InvalidOperationException("Database schema is newer than this server.");
|
||||
if (version == 0)
|
||||
{
|
||||
command.CommandText = """
|
||||
@@ -485,6 +485,22 @@ public sealed partial class NestDatabase : IDisposable
|
||||
command.CommandText = "PRAGMA user_version=20";
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
if (version < 21)
|
||||
{
|
||||
// Job numbers, kept apart from the customer; existing records stay blank until
|
||||
// their nest is edited and saved again.
|
||||
foreach (var table in new[] { "nests", "nest_revisions" })
|
||||
{
|
||||
command.CommandText = $"SELECT COUNT(*) FROM pragma_table_info('{table}') WHERE name='jobNumber'";
|
||||
if ((long)command.ExecuteScalar()! == 0)
|
||||
{
|
||||
command.CommandText = $"ALTER TABLE {table} ADD COLUMN jobNumber TEXT NOT NULL DEFAULT ''";
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
command.CommandText = "PRAGMA user_version=21";
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
transaction.Commit();
|
||||
}
|
||||
}
|
||||
@@ -558,7 +574,7 @@ public sealed partial class NestDatabase : IDisposable
|
||||
private const string RecordColumns = """
|
||||
id, name, customer, dateCreated, dateModified, material, thickness,
|
||||
status, plateCount, partCount, comments, madeBy, fileSize, savedAt, revision, deleted, restoredFromRevision,
|
||||
materialGrade, units, thicknessName
|
||||
materialGrade, units, thicknessName, jobNumber
|
||||
""";
|
||||
|
||||
// Case-insensitive (ASCII) substring over the text columns and the status's stored
|
||||
@@ -566,6 +582,7 @@ public sealed partial class NestDatabase : IDisposable
|
||||
private const string SearchPredicate = """
|
||||
name LIKE $pattern ESCAPE '\'
|
||||
OR customer LIKE $pattern ESCAPE '\'
|
||||
OR jobNumber LIKE $pattern ESCAPE '\'
|
||||
OR material LIKE $pattern ESCAPE '\'
|
||||
OR materialGrade LIKE $pattern ESCAPE '\'
|
||||
OR thicknessName LIKE $pattern ESCAPE '\'
|
||||
@@ -593,6 +610,7 @@ public sealed partial class NestDatabase : IDisposable
|
||||
NestSortField.Comments => "comments COLLATE NOCASE",
|
||||
NestSortField.FileSize => "fileSize",
|
||||
NestSortField.MaterialGrade => "materialGrade COLLATE NOCASE",
|
||||
NestSortField.JobNumber => "jobNumber COLLATE NOCASE",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(field), field, "Unsupported sort column."),
|
||||
};
|
||||
|
||||
@@ -668,6 +686,7 @@ public sealed partial class NestDatabase : IDisposable
|
||||
command.Parameters.AddWithValue("$materialGrade", record.MaterialGrade);
|
||||
command.Parameters.AddWithValue("$thickness", record.Thickness);
|
||||
command.Parameters.AddWithValue("$thicknessName", record.ThicknessName ?? "");
|
||||
command.Parameters.AddWithValue("$jobNumber", Nest.NormalizeJobNumbers(record.JobNumber));
|
||||
command.Parameters.AddWithValue("$units", record.Units.ToString());
|
||||
command.Parameters.AddWithValue("$status", record.Status.ToString());
|
||||
command.Parameters.AddWithValue("$plateCount", record.PlateCount);
|
||||
@@ -708,6 +727,7 @@ public sealed partial class NestDatabase : IDisposable
|
||||
MaterialGrade = reader.GetString(first + 17),
|
||||
Units = Enum.TryParse<Units>(reader.GetString(first + 18), true, out var units) ? units : Units.Inches,
|
||||
ThicknessName = reader.GetString(first + 19),
|
||||
JobNumber = reader.GetString(first + 20),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ internal static class NestMetadata
|
||||
{
|
||||
if (record.Name is null) return "name must be a string.";
|
||||
if (record.Customer is null) return "customer must be a string.";
|
||||
if (record.JobNumber is null) return "jobNumber must be a string.";
|
||||
if (record.Material is null) return "material must be a string.";
|
||||
if (record.MaterialGrade is null) return "materialGrade must be a string.";
|
||||
if (record.ThicknessName is null) return "thicknessName must be a string.";
|
||||
|
||||
@@ -24,6 +24,7 @@ public class NestRecordFactoryTests
|
||||
{
|
||||
Name = "Current name",
|
||||
Customer = "Current customer",
|
||||
JobNumber = "4980-88R",
|
||||
Comments = "Current notes",
|
||||
Material = currentMaterial,
|
||||
Thickness = 0.375,
|
||||
@@ -41,6 +42,7 @@ public class NestRecordFactoryTests
|
||||
Assert.Equal(current.DateModified, roundTrip.DateModified);
|
||||
Assert.Equal(current.Name, roundTrip.Name);
|
||||
Assert.Equal(current.Customer, roundTrip.Customer);
|
||||
Assert.Equal(current.JobNumber, roundTrip.JobNumber);
|
||||
Assert.Equal(current.Comments, roundTrip.Comments);
|
||||
Assert.Equal(current.Status, roundTrip.Status);
|
||||
Assert.Equal(current.MadeBy, roundTrip.MadeBy);
|
||||
@@ -60,6 +62,7 @@ public class NestRecordFactoryTests
|
||||
var nest = new Nest("Job 42")
|
||||
{
|
||||
Customer = "Cozy Cat",
|
||||
JobNumber = "4156",
|
||||
Material = new Material("Aluminum", "5052"),
|
||||
Thickness = 0.125,
|
||||
Status = NestStatus.ToBeCut,
|
||||
@@ -90,6 +93,7 @@ public class NestRecordFactoryTests
|
||||
Assert.Equal(Guid.Empty, record.Id);
|
||||
Assert.Equal("Job 42", record.Name);
|
||||
Assert.Equal("Cozy Cat", record.Customer);
|
||||
Assert.Equal("4156", record.JobNumber);
|
||||
Assert.Equal("Aluminum", record.Material);
|
||||
Assert.Equal("5052", record.MaterialGrade);
|
||||
Assert.Equal(0.125, record.Thickness);
|
||||
|
||||
@@ -23,6 +23,17 @@ public class NestStatusSerializationTests
|
||||
Assert.Equal("AJ", loaded.MadeBy);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_JobNumber_PreservedAndNormalized()
|
||||
{
|
||||
var nest = CreateMinimalNest();
|
||||
nest.JobNumber = " 4980-88R ,, 4981-02 ";
|
||||
|
||||
Assert.Equal("4980-88R, 4981-02", nest.JobNumber);
|
||||
Assert.Equal("4980-88R, 4981-02", RoundTrip(nest).JobNumber);
|
||||
Assert.Equal("", RoundTrip(CreateMinimalNest()).JobNumber);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_ThicknessName_Preserved()
|
||||
{
|
||||
|
||||
@@ -74,6 +74,27 @@ public class EditNestInfoFormTests
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JobNumber_LoadsAndSavesSeveralJobs()
|
||||
{
|
||||
RunSta(() =>
|
||||
{
|
||||
using var form = new EditNestInfoForm();
|
||||
var nest = AcceptanceNest();
|
||||
nest.Customer = "GM";
|
||||
nest.JobNumber = "4980-88R";
|
||||
form.LoadNestInfo(nest);
|
||||
Assert.Equal("GM", form.Customer);
|
||||
Assert.Equal("4980-88R", form.JobNumber);
|
||||
|
||||
form.JobNumber = "4980-88R,4981-02 ";
|
||||
form.SaveNestInfo(nest);
|
||||
|
||||
Assert.Equal("GM", nest.Customer);
|
||||
Assert.Equal("4980-88R, 4981-02", nest.JobNumber);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThicknessName_FollowsTheThickness_AndKeepsATypedName()
|
||||
{
|
||||
|
||||
@@ -454,6 +454,7 @@ public class SavedNestsFormTests
|
||||
current.Revision++;
|
||||
current.Name = metadata.Name;
|
||||
current.Customer = metadata.Customer;
|
||||
current.JobNumber = metadata.JobNumber;
|
||||
current.Comments = metadata.Comments;
|
||||
current.Material = metadata.Material;
|
||||
current.Thickness = metadata.Thickness;
|
||||
|
||||
@@ -70,6 +70,7 @@ namespace OpenNest.Forms.Commands
|
||||
// current editable fields rather than silently reverting them on the next save.
|
||||
nest.Name = snapshot.Metadata.Name;
|
||||
nest.Customer = snapshot.Metadata.Customer;
|
||||
nest.JobNumber = snapshot.Metadata.JobNumber;
|
||||
nest.Notes = snapshot.Metadata.Comments;
|
||||
nest.Status = snapshot.Metadata.Status;
|
||||
nest.MadeBy = snapshot.Metadata.MadeBy;
|
||||
|
||||
+37
-13
@@ -37,6 +37,8 @@
|
||||
this.nameBox = new System.Windows.Forms.TextBox();
|
||||
this.labelCustomer = new System.Windows.Forms.Label();
|
||||
this.customerBox = new System.Windows.Forms.TextBox();
|
||||
this.labelJobNumber = new System.Windows.Forms.Label();
|
||||
this.jobNumberBox = new System.Windows.Forms.TextBox();
|
||||
this.labelStatus = new System.Windows.Forms.Label();
|
||||
this.statusBox = new System.Windows.Forms.ComboBox();
|
||||
this.labelMadeBy = new System.Windows.Forms.Label();
|
||||
@@ -112,7 +114,7 @@
|
||||
this.nestGroup.Location = new System.Drawing.Point(9, 9);
|
||||
this.nestGroup.Name = "nestGroup";
|
||||
this.nestGroup.Padding = new System.Windows.Forms.Padding(8, 4, 8, 6);
|
||||
this.nestGroup.Size = new System.Drawing.Size(550, 128);
|
||||
this.nestGroup.Size = new System.Drawing.Size(550, 160);
|
||||
this.nestGroup.TabIndex = 0;
|
||||
this.nestGroup.TabStop = false;
|
||||
this.nestGroup.Text = "Nest";
|
||||
@@ -128,15 +130,18 @@
|
||||
this.nestTable.Controls.Add(this.nameBox, 1, 0);
|
||||
this.nestTable.Controls.Add(this.labelCustomer, 0, 1);
|
||||
this.nestTable.Controls.Add(this.customerBox, 1, 1);
|
||||
this.nestTable.Controls.Add(this.labelStatus, 2, 1);
|
||||
this.nestTable.Controls.Add(this.statusBox, 3, 1);
|
||||
this.nestTable.Controls.Add(this.labelJobNumber, 2, 1);
|
||||
this.nestTable.Controls.Add(this.jobNumberBox, 3, 1);
|
||||
this.nestTable.Controls.Add(this.labelMadeBy, 0, 2);
|
||||
this.nestTable.Controls.Add(this.madeByBox, 1, 2);
|
||||
this.nestTable.Controls.Add(this.labelUnits, 2, 2);
|
||||
this.nestTable.Controls.Add(this.unitsPanel, 3, 2);
|
||||
this.nestTable.Controls.Add(this.labelStatus, 2, 2);
|
||||
this.nestTable.Controls.Add(this.statusBox, 3, 2);
|
||||
this.nestTable.Controls.Add(this.labelUnits, 0, 3);
|
||||
this.nestTable.Controls.Add(this.unitsPanel, 1, 3);
|
||||
this.nestTable.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.nestTable.Name = "nestTable";
|
||||
this.nestTable.RowCount = 3;
|
||||
this.nestTable.RowCount = 4;
|
||||
this.nestTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 32F));
|
||||
this.nestTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 32F));
|
||||
this.nestTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 32F));
|
||||
this.nestTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 32F));
|
||||
@@ -174,13 +179,31 @@
|
||||
this.customerBox.Size = new System.Drawing.Size(170, 22);
|
||||
this.customerBox.TabIndex = 3;
|
||||
//
|
||||
// labelJobNumber
|
||||
//
|
||||
this.labelJobNumber.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
||||
this.labelJobNumber.AutoSize = true;
|
||||
this.labelJobNumber.Margin = new System.Windows.Forms.Padding(12, 0, 3, 0);
|
||||
this.labelJobNumber.Name = "labelJobNumber";
|
||||
this.labelJobNumber.TabIndex = 4;
|
||||
this.labelJobNumber.Text = "Job # :";
|
||||
this.toolTip.SetToolTip(this.labelJobNumber, "The job this nest cuts parts for. Separate several with commas, such as 4980-88R, 4981-02.");
|
||||
//
|
||||
// jobNumberBox
|
||||
//
|
||||
this.jobNumberBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.jobNumberBox.Name = "jobNumberBox";
|
||||
this.jobNumberBox.Size = new System.Drawing.Size(170, 22);
|
||||
this.jobNumberBox.TabIndex = 5;
|
||||
this.toolTip.SetToolTip(this.jobNumberBox, "The job this nest cuts parts for. Separate several with commas, such as 4980-88R, 4981-02.");
|
||||
//
|
||||
// labelStatus
|
||||
//
|
||||
this.labelStatus.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
||||
this.labelStatus.AutoSize = true;
|
||||
this.labelStatus.Margin = new System.Windows.Forms.Padding(12, 0, 3, 0);
|
||||
this.labelStatus.Name = "labelStatus";
|
||||
this.labelStatus.TabIndex = 4;
|
||||
this.labelStatus.TabIndex = 8;
|
||||
this.labelStatus.Text = "Status :";
|
||||
//
|
||||
// statusBox
|
||||
@@ -190,7 +213,7 @@
|
||||
this.statusBox.FormattingEnabled = true;
|
||||
this.statusBox.Name = "statusBox";
|
||||
this.statusBox.Size = new System.Drawing.Size(170, 24);
|
||||
this.statusBox.TabIndex = 5;
|
||||
this.statusBox.TabIndex = 9;
|
||||
//
|
||||
// labelMadeBy
|
||||
//
|
||||
@@ -211,9 +234,8 @@
|
||||
//
|
||||
this.labelUnits.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
||||
this.labelUnits.AutoSize = true;
|
||||
this.labelUnits.Margin = new System.Windows.Forms.Padding(12, 0, 3, 0);
|
||||
this.labelUnits.Name = "labelUnits";
|
||||
this.labelUnits.TabIndex = 8;
|
||||
this.labelUnits.TabIndex = 10;
|
||||
this.labelUnits.Text = "Units :";
|
||||
//
|
||||
// unitsPanel
|
||||
@@ -223,7 +245,7 @@
|
||||
this.unitsPanel.Controls.Add(this.millimetersButton);
|
||||
this.unitsPanel.Name = "unitsPanel";
|
||||
this.unitsPanel.Size = new System.Drawing.Size(170, 26);
|
||||
this.unitsPanel.TabIndex = 9;
|
||||
this.unitsPanel.TabIndex = 11;
|
||||
this.unitsPanel.WrapContents = false;
|
||||
//
|
||||
// inchesButton
|
||||
@@ -251,7 +273,7 @@
|
||||
// materialGroup
|
||||
//
|
||||
this.materialGroup.Controls.Add(this.materialTable);
|
||||
this.materialGroup.Location = new System.Drawing.Point(9, 147);
|
||||
this.materialGroup.Location = new System.Drawing.Point(9, 179);
|
||||
this.materialGroup.Name = "materialGroup";
|
||||
this.materialGroup.Padding = new System.Windows.Forms.Padding(8, 4, 8, 6);
|
||||
this.materialGroup.Size = new System.Drawing.Size(550, 96);
|
||||
@@ -353,7 +375,7 @@
|
||||
//
|
||||
this.datesLabel.AutoSize = true;
|
||||
this.datesLabel.ForeColor = System.Drawing.SystemColors.GrayText;
|
||||
this.datesLabel.Location = new System.Drawing.Point(12, 254);
|
||||
this.datesLabel.Location = new System.Drawing.Point(12, 286);
|
||||
this.datesLabel.Name = "datesLabel";
|
||||
this.datesLabel.TabIndex = 2;
|
||||
//
|
||||
@@ -504,6 +526,8 @@
|
||||
private System.Windows.Forms.TextBox nameBox;
|
||||
private System.Windows.Forms.Label labelCustomer;
|
||||
private System.Windows.Forms.TextBox customerBox;
|
||||
private System.Windows.Forms.Label labelJobNumber;
|
||||
private System.Windows.Forms.TextBox jobNumberBox;
|
||||
private System.Windows.Forms.Label labelStatus;
|
||||
private System.Windows.Forms.ComboBox statusBox;
|
||||
private System.Windows.Forms.Label labelMadeBy;
|
||||
|
||||
@@ -106,6 +106,13 @@ namespace OpenNest.Forms
|
||||
set { customerBox.Text = value; }
|
||||
}
|
||||
|
||||
/// <summary>The job number, or several separated by commas.</summary>
|
||||
public string JobNumber
|
||||
{
|
||||
get { return jobNumberBox.Text; }
|
||||
set { jobNumberBox.Text = value; }
|
||||
}
|
||||
|
||||
public string Notes
|
||||
{
|
||||
get { return notesBox.Text; }
|
||||
@@ -336,6 +343,7 @@ namespace OpenNest.Forms
|
||||
Units = GetUnits(),
|
||||
Notes = Notes,
|
||||
Customer = Customer,
|
||||
JobNumber = JobNumber,
|
||||
DateCreated = DateCreated,
|
||||
DateLastModified = DateLastModified,
|
||||
Thickness = Thickness,
|
||||
@@ -359,6 +367,7 @@ namespace OpenNest.Forms
|
||||
NestName = values.Name;
|
||||
Notes = values.Notes;
|
||||
Customer = values.Customer;
|
||||
JobNumber = values.JobNumber;
|
||||
DateCreated = values.DateCreated;
|
||||
DateLastModified = values.DateLastModified;
|
||||
Thickness = values.Thickness;
|
||||
|
||||
@@ -37,7 +37,7 @@ public sealed class NestRevisionPreviewForm : Form
|
||||
{
|
||||
Dock = DockStyle.Top,
|
||||
Height = 60,
|
||||
Text = $"Read-only archive: {metadata.Id}, version {metadata.Revision}. No remote document is bound; this window cannot Save, Restore or Post.\nCustomer: {metadata.Customer}; Status: {metadata.Status}; Made by: {metadata.MadeBy}\nComments: {metadata.Comments}",
|
||||
Text = $"Read-only archive: {metadata.Id}, version {metadata.Revision}. No remote document is bound; this window cannot Save, Restore or Post.\nCustomer: {metadata.Customer}; Job #: {metadata.JobNumber}; Status: {metadata.Status}; Made by: {metadata.MadeBy}\nComments: {metadata.Comments}",
|
||||
AutoEllipsis = true
|
||||
};
|
||||
previous.Click += (_, _) => ShowPlate(index - 1);
|
||||
|
||||
@@ -125,6 +125,7 @@ public sealed class SavedNestsForm : Form
|
||||
AddNestColumn("Parts", NestSortField.PartCount, 60, alignRight: true);
|
||||
AddNestColumn("Comment", NestSortField.Comments, 260);
|
||||
AddNestColumn("Customer", NestSortField.Customer, 160);
|
||||
AddNestColumn("Job #", NestSortField.JobNumber, 110);
|
||||
AddNestColumn("Made by", NestSortField.MadeBy, 90);
|
||||
AddNestColumn("Material", NestSortField.Material, 150);
|
||||
AddNestColumn("Grade", NestSortField.MaterialGrade, 80);
|
||||
@@ -298,9 +299,9 @@ public sealed class SavedNestsForm : Form
|
||||
// Find bar and paging.
|
||||
searchBox = new TextBox
|
||||
{
|
||||
Width = 320,
|
||||
Width = 360,
|
||||
MaxLength = NestQuery.MaxSearchLength,
|
||||
PlaceholderText = "Name, customer, material, made by, comment or status",
|
||||
PlaceholderText = "Name, customer, job #, material, made by, comment or status",
|
||||
};
|
||||
searchTimer = new Timer { Interval = 300 };
|
||||
searchTimer.Tick += async (_, _) =>
|
||||
@@ -490,6 +491,7 @@ public sealed class SavedNestsForm : Form
|
||||
record.PartCount.ToString("N0", CultureInfo.CurrentCulture),
|
||||
record.Comments,
|
||||
record.Customer,
|
||||
record.JobNumber,
|
||||
record.MadeBy,
|
||||
record.Material,
|
||||
record.MaterialGrade,
|
||||
|
||||
@@ -12,6 +12,9 @@ opening and saving with an older application loses that state.
|
||||
`thicknessName` is the shop's name for the thickness ("10 ga", `Nest.ThicknessName`); it
|
||||
is omitted when blank, older files have none, and older readers ignore it. A new
|
||||
thickness value clears it, so a reader sets it after the thickness.
|
||||
`jobNumber` is the job the nest cuts parts for (`Nest.JobNumber`), several separated by
|
||||
commas and stored as `"4980-88R, 4981-02"`; it is omitted when blank, older files have
|
||||
none, and older readers ignore it.
|
||||
Status and made-by are additive: files written before them load as Quote with an
|
||||
empty maker, and an unrecognized status value likewise falls back to Quote. Builds
|
||||
before `Draft` therefore open a Draft nest as Quote, and saving it there keeps Quote.
|
||||
|
||||
+15
-3
@@ -5,7 +5,7 @@ The desktop app can save nests two ways:
|
||||
- **File mode** (default, unchanged behavior): Save/Save As write a `.nest` ZIP
|
||||
archive to disk via the normal file dialog. See [nest-file-format.md](nest-file-format.md).
|
||||
- **Database mode**: Open browses server records 100 at a time. The Find box
|
||||
searches name, customer, material, grade, thickness name, made by, comments and status on the server
|
||||
searches name, customer, job number, material, grade, thickness name, made by, comments and status on the server
|
||||
after a short typing pause (Enter in the box searches at once); clicking a
|
||||
column header sorts every match on the server (click again to reverse); the
|
||||
arrow buttons move between pages and the title and find bar show the range and
|
||||
@@ -89,6 +89,7 @@ entry, never programs or geometry, and takes the archive-derived fields below fr
|
||||
| `material` | string | Material name (type), e.g. `Stainless`. Read from the uploaded archive (nest material, else plate defaults' on an explicit null); a metadata-only PUT may change it, and the desktop applies the record's value when opening the nest. |
|
||||
| `materialGrade` | string | Optional; default blank. Older servers drop it. A blank grade on a record saved before schema v8 is treated as unrecorded: opening keeps the archive's grade while the material name matches. |
|
||||
| `thickness` | number | Read from the uploaded archive (nest thickness, else plate defaults' when not positive); editable like `material`. |
|
||||
| `jobNumber` | string | Optional; default blank. The job number, or several separated by commas, kept apart from `customer`; the server stores it as the client does, each number trimmed and joined with `", "`. Older servers drop it. See [Job numbers](#job-numbers). |
|
||||
| `thicknessName` | string | Optional; default blank. The shop's name for the thickness ("10 ga"), from the client like `materialGrade`. Older servers drop it. A blank name is filled in for display only (see [Thickness names](#thickness-names)). |
|
||||
| `units` | `"inches"` \| `"millimeters"` | The nest's units, which `thickness` is in. Server-computed from the uploaded archive (absent or unknown values are inches, as `NestReader` reads them); ignored on upload and kept by a metadata-only PUT. Schema v12 read every stored archive, current and historical, to fill it. Older servers omit it, which readers take as inches. |
|
||||
| `status` | `"draft"` \| `"quote"` \| `"toBeCut"` \| `"hasBeenCut"` | Default `quote`. |
|
||||
@@ -270,7 +271,7 @@ only the requested page of metadata (never archive bytes):
|
||||
|
||||
- `search` (optional): trimmed, at most 200 characters, no NUL characters;
|
||||
blank means no filter.
|
||||
Case-insensitive substring of the whole text in `name`, `customer`, `material`,
|
||||
Case-insensitive substring of the whole text in `name`, `customer`, `jobNumber`, `material`,
|
||||
`materialGrade`, `thicknessName`, `madeBy`, `comments` or the status (`ToBeCut` or the display name `To Be Cut`).
|
||||
`%`, `_` and `\` are literal. Dates and numbers are not matched as text.
|
||||
Case folding is ASCII-only (SQLite `LIKE`).
|
||||
@@ -285,7 +286,7 @@ only the requested page of metadata (never archive bytes):
|
||||
- `offset` (default 0, at least 0) and `limit` (default 100, 1 to 500).
|
||||
- `sort` (default `savedAt`): one of `savedAt`, `name`, `customer`, `status`,
|
||||
`material`, `dateCreated`, `dateModified`, `thickness`, `plateCount`,
|
||||
`partCount`, `madeBy`, `comments`, `fileSize`, `materialGrade` (names, case-insensitive; no
|
||||
`partCount`, `madeBy`, `comments`, `fileSize`, `materialGrade`, `jobNumber` (names, case-insensitive; no
|
||||
numbers). Text columns sort case-insensitively (ASCII); dates sort as their
|
||||
stored ISO text. `order` is `asc` or `desc` (default `desc`).
|
||||
- Ties are broken by `id` in the same direction, so pages partition the matches
|
||||
@@ -1140,6 +1141,17 @@ thickness as its bare decimal with a **Name** box beside it that fills in the sa
|
||||
thickness replaces the name, a new material only a blank or suggested one, and a typed
|
||||
name is kept.
|
||||
|
||||
### Job numbers
|
||||
|
||||
Schema v21 adds a `jobNumber` text column (default blank) to `nests` and
|
||||
`nest_revisions`; existing records keep a blank job number until they are next saved, and
|
||||
nothing is moved out of `customer`. A server older than v21 refuses to open a v21
|
||||
database, so rolling back needs the pre-upgrade backup.
|
||||
|
||||
Edit Nest has a **Job #** box beside Customer; several jobs go in it separated by
|
||||
commas. The Open list has a **Job #** column that sorts as text, the Find box matches it,
|
||||
and the nest report lists it under the customer.
|
||||
|
||||
## Material list endpoints
|
||||
|
||||
The server keeps the company material list: each material with its grades. Both
|
||||
|
||||
Reference in new issue
Block a user