refactor(tui): restructure site form to 2 type-aware pages
Replace 4-page paginated form (17 fields for HTTP) with a 2-page type-aware layout. Page 1 shows core fields + type-specific target (URL for HTTP, Hostname for ping, etc). Page 2 shows configuration with pre-filled defaults. Group type gets 1 page. Form rebuilds dynamically when monitor type changes, preserving all entered values via pointer-bound siteFormData. Focus returns to the Type select after rebuild so users can continue forward. WithWidth set explicitly on rebuild to prevent placeholder truncation.
This commit was merged in pull request #132.
This commit is contained in:
@@ -128,6 +128,13 @@ func (m *Model) handleFormMsg(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
if f, ok := form.(*huh.Form); ok {
|
||||
m.huhForm = f
|
||||
}
|
||||
if m.state == stateFormSite && m.siteFormData != nil &&
|
||||
m.siteFormData.SiteType != m.lastSiteType {
|
||||
rebuildCmd := m.rebuildSiteForm()
|
||||
// Advance to Type select — user just changed it.
|
||||
skipName := m.huhForm.NextField()
|
||||
return m, tea.Batch(rebuildCmd, skipName)
|
||||
}
|
||||
if m.huhForm.State == huh.StateCompleted {
|
||||
// The store write runs in the returned Cmd; its writeDoneMsg
|
||||
// triggers the tab-data reload once the row actually exists.
|
||||
|
||||
Reference in New Issue
Block a user