fix(ui): sign new nests with Made By instead of on viewing Nest Info

Nest Info filled a blank Made By with the current user every time it
opened, so pressing OK on an existing nest's info (from a tab or Saved
Nests) signed someone else's nest. The author is now stamped once when a
nest is made (File > New, drawing set Make Nests, BOM import), and Nest
Info shows the stored value as is, leaving a blank one blank.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ajandClaude Opus 5.5 committed 2026-11-12 18:21:22 -05:00
1 parent 5d00715948
commit c8e1b97786
4 files changed
+36 -22

No files matched your search

@@ -311,7 +311,7 @@ public class EditNestInfoFormTests
}
[Fact]
public void BlankMadeBy_StartsFromTheUserName_AndRemembersATypedName()
public void NewNestMadeBy_StartsFromTheUserName_AndRemembersATypedName()
{
RunSta(() =>
{
@@ -320,20 +320,27 @@ public class EditNestInfoFormTests
try
{
settings.MadeBy = "";
Assert.Equal(Environment.UserName, NewNestFactory.DefaultMadeBy);
// Viewing an existing nest's info leaves a blank author blank.
var existing = new Nest();
using (var form = new EditNestInfoForm())
{
form.LoadNestInfo(new Nest());
Assert.Equal(Environment.UserName, form.MadeBy);
form.MadeBy = "Synthetic operator";
form.SaveNestInfo(new Nest());
form.LoadNestInfo(existing);
Assert.Equal("", form.MadeBy);
form.SaveNestInfo(existing);
}
Assert.Equal("Synthetic operator", settings.MadeBy);
Assert.Equal("", existing.MadeBy);
Assert.Equal("", settings.MadeBy);
using (var form = new EditNestInfoForm())
{
form.LoadNestInfo(new Nest());
Assert.Equal("Synthetic operator", form.MadeBy);
form.MadeBy = "Synthetic operator";
form.SaveNestInfo(new Nest());
}
Assert.Equal("Synthetic operator", settings.MadeBy);
Assert.Equal("Synthetic operator", NewNestFactory.DefaultMadeBy);
// A nest's own author is shown as is and, left alone, is not remembered.
using (var form = new EditNestInfoForm())
+1
View File
@@ -450,6 +450,7 @@ namespace OpenNest.Forms
_defaults.ApplyTo(nest);
clamps.ApplyToNewNest(nest);
MachineSettings.AssignMachine(nest, machine);
nest.MadeBy = NewNestFactory.DefaultMadeBy;
}
);
importErrors.AddRange(result.Errors);
+6 -15
View File
@@ -232,20 +232,9 @@ namespace OpenNest.Forms
}
/// <summary>
/// Fills a blank Made By: the name the user last typed there, else their Windows user name.
/// </summary>
public static string DefaultMadeBy
{
get
{
var remembered = Properties.Settings.Default.MadeBy;
return string.IsNullOrWhiteSpace(remembered) ? Environment.UserName : remembered.Trim();
}
}
/// <summary>
/// Remembers a Made By the user typed, so later blank nests start from it; clearing
/// the box falls back to the Windows user name again.
/// Remembers a Made By the user typed, so later new nests start from it
/// (<see cref="NewNestFactory.DefaultMadeBy"/>); clearing the box falls back to the
/// Windows user name again.
/// </summary>
private void RememberMadeBy()
{
@@ -357,7 +346,9 @@ namespace OpenNest.Forms
MaterialName = nest.Material?.Name ?? "";
MaterialGrade = nest.Material?.Grade ?? "";
Status = nest.Status;
MadeBy = string.IsNullOrWhiteSpace(nest.MadeBy) ? DefaultMadeBy : nest.MadeBy;
// Shown as stored: a new nest got its author when it was made, and viewing an
// existing nest's info must not sign it.
MadeBy = nest.MadeBy ?? "";
shownMadeBy = MadeBy;
SizeString = nest.PlateDefaults.Size.ToString();
PartSpacing = nest.PlateDefaults.PartSpacing;
+15
View File
@@ -31,10 +31,25 @@ namespace OpenNest.Forms
nest.DateCreated = now;
nest.DateLastModified = now;
nest.MadeBy = DefaultMadeBy;
nest.Name = NestNames.Format(now.Year, await AllocateNumberAsync(now));
return nest;
}
/// <summary>
/// The author a new nest starts with: the name the user last typed in Nest Info's Made By,
/// else their Windows user name. Only new nests get it; opening an existing nest's info
/// leaves a blank Made By blank.
/// </summary>
public static string DefaultMadeBy
{
get
{
var remembered = Settings.Default.MadeBy;
return string.IsNullOrWhiteSpace(remembered) ? Environment.UserName : remembered.Trim();
}
}
private static Nest CreateDefaultNest(SetReleaseGroup release)
{
var nest = new Nest();