mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-26 22:01:06 -04:00
fix(desktop): list the first sets in Add a set before anything is typed
The release dialog's Add a set box was a pure type-ahead: it queried the server only after typing paused, so opening it, or clicking its arrow with nothing typed, showed an empty list. From Drawing Sets > Release that was easy to miss, but New Release starts with nothing listed, and an empty dropdown there reads as a missing server connection. The dialog now reads the first active sets by name when it is shown, and again when the list is opened while still empty, without dropping the list open on its own; typing narrows it as before. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
dc4fc1d593
commit
c325a1745a
4 files changed
+47
-6
No files matched your search
@@ -639,6 +639,33 @@ public class SetReleaseFormsTests
|
||||
"The all-releases view test did not complete.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Release_ListsTheFirstSetsInTheAddSetBox_BeforeAnythingIsTyped()
|
||||
{
|
||||
StaTestThread.Run(
|
||||
() =>
|
||||
{
|
||||
var library = new PackageLibrary();
|
||||
var a = library.Add("SYN-A", "Synthetic Steel");
|
||||
var sets = new InMemoryDrawingSets();
|
||||
CreateSet(sets, "Synthetic kit", (a, 1));
|
||||
CreateSet(sets, "Synthetic frame", (a, 2));
|
||||
var nests = new MemoryNests();
|
||||
|
||||
using var form = new ReleaseSetForm(sets, library, nests, Server, Array.Empty<DrawingSetRecord>(),
|
||||
Array.Empty<SetReleaseDrawingLine>(), (_, _) => { });
|
||||
form.Show();
|
||||
var combo = Field<ComboBox>(form, "addSetCombo");
|
||||
PumpUntil(() => combo.Items.Count == 2, "the set list");
|
||||
|
||||
Assert.Equal(new[] { "Synthetic frame", "Synthetic kit" }, combo.Items.Cast<object>().Select(i => i.ToString()!.Split(" (")[0]));
|
||||
Assert.Equal("", combo.Text);
|
||||
Assert.False(combo.DroppedDown);
|
||||
},
|
||||
TestTimeout,
|
||||
"The set list test did not complete.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Release_StartedEmpty_AddsASetAndReleasesIt()
|
||||
{
|
||||
|
||||
+1
@@ -141,6 +141,7 @@ namespace OpenNest.Forms
|
||||
addSetCombo.Name = "addSetCombo";
|
||||
addSetCombo.TabIndex = 1;
|
||||
addSetCombo.TextUpdate += AddSetCombo_TextUpdate;
|
||||
addSetCombo.DropDown += AddSetCombo_DropDown;
|
||||
addSetCombo.KeyDown += AddSetCombo_KeyDown;
|
||||
//
|
||||
// addSetButton
|
||||
|
||||
@@ -121,6 +121,8 @@ namespace OpenNest.Forms
|
||||
AddRow(line.Drawing, line.Drawing.Name, line.Drawing.Customer, line.Drawing.Revision, line.Quantity);
|
||||
populating = false;
|
||||
BuildPlan();
|
||||
// The first sets by name are listed before anything is typed, so the arrow shows them.
|
||||
Shown += async (_, _) => await SearchSetsAsync("", dropDown: false);
|
||||
}
|
||||
|
||||
/// <summary>The sets listed, in order, with their kits.</summary>
|
||||
@@ -282,6 +284,13 @@ namespace OpenNest.Forms
|
||||
BuildPlan();
|
||||
}
|
||||
|
||||
// Opening the empty list reads the first sets when the initial read failed or found none yet.
|
||||
private async void AddSetCombo_DropDown(object sender, EventArgs e)
|
||||
{
|
||||
if (addSetCombo.Items.Count == 0 && string.IsNullOrEmpty(addSetCombo.Text) && addSetCombo.Enabled)
|
||||
await SearchSetsAsync("", dropDown: false);
|
||||
}
|
||||
|
||||
// Type-ahead: the set list is queried once typing pauses.
|
||||
private void AddSetCombo_TextUpdate(object sender, EventArgs e)
|
||||
{
|
||||
@@ -305,8 +314,12 @@ namespace OpenNest.Forms
|
||||
|
||||
private async void AddSetButton_Click(object sender, EventArgs e) => await AddTypedSetAsync();
|
||||
|
||||
/// <summary>Lists active sets whose name, customer or notes contain <paramref name="text"/>.</summary>
|
||||
internal async Task SearchSetsAsync(string text)
|
||||
/// <summary>
|
||||
/// Lists the first active sets by name whose name, customer or notes contain
|
||||
/// <paramref name="text"/> (all of them for an empty text); <paramref name="dropDown"/>
|
||||
/// opens the list when the box has focus, as typing does.
|
||||
/// </summary>
|
||||
internal async Task SearchSetsAsync(string text, bool dropDown = true)
|
||||
{
|
||||
searchCancellation?.Cancel();
|
||||
searchCancellation?.Dispose();
|
||||
@@ -340,7 +353,7 @@ namespace OpenNest.Forms
|
||||
addSetCombo.EndUpdate();
|
||||
addSetCombo.Text = typed;
|
||||
addSetCombo.SelectionStart = System.Math.Min(caret, typed.Length);
|
||||
if (addSetCombo.Focused && page.Items.Count > 0)
|
||||
if (dropDown && addSetCombo.Focused && page.Items.Count > 0)
|
||||
addSetCombo.DroppedDown = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -408,9 +408,9 @@ review and Save; nothing is stored before then.
|
||||
|
||||
**Release...** (in the drawing sets window) reads the
|
||||
selected active set with its members and opens the release dialog with it listed.
|
||||
More sets are added by typing in **Add a set** (the list of matching active sets
|
||||
fills as you type; Enter or **Add** takes the picked set, or the one set whose
|
||||
name is exactly what was typed). **Add Drawings...** adds library drawings on
|
||||
More sets are added from **Add a set**: the list opens with the first active sets
|
||||
by name and narrows as you type; Enter or **Add** takes the picked set, or the one
|
||||
set whose name is exactly what was typed. **Add Drawings...** adds library drawings on
|
||||
their own, outside any set: it browses every active drawing as the set editor's
|
||||
library pane does (search, server-side sort, pages, several selected at once),
|
||||
and **Add to Release**, a double-click or Enter adds the selection at the
|
||||
|
||||
Reference in new issue
Block a user