Skip to content

Commit e9209ba

Browse files
cpcloudclaude
andcommitted
fix(domain): correct skipColEdit index for appliance maintenance sub-table
The new Season column shifted Appliance from index 3 to 4. Use the typed maintenanceColAppliance constant instead of a bare integer so the sub-table inline edit dispatches to the correct full-table column. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9406af9 commit e9209ba

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

internal/app/handler_crud_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,43 @@ func TestApplianceMaintenanceHandlerLoad(t *testing.T) {
990990
assert.NotZero(t, meta[0].ID)
991991
}
992992

993+
func TestApplianceMaintenanceInlineEditSeasonDispatchesCorrectly(t *testing.T) {
994+
t.Parallel()
995+
m := newTestModelWithStore(t)
996+
cats, _ := m.store.MaintenanceCategories()
997+
998+
require.NoError(t, m.store.CreateAppliance(&data.Appliance{Name: "Furnace"}))
999+
apps, _ := m.store.ListAppliances(false)
1000+
appID := apps[0].ID
1001+
1002+
require.NoError(t, m.store.CreateMaintenance(&data.MaintenanceItem{
1003+
Name: "Replace Filter",
1004+
CategoryID: cats[0].ID,
1005+
ApplianceID: &appID,
1006+
Season: data.SeasonFall,
1007+
}))
1008+
1009+
h := newApplianceMaintenanceHandler(appID)
1010+
_, meta, _, err := h.Load(m.store, false)
1011+
require.NoError(t, err)
1012+
id := meta[0].ID
1013+
1014+
// In the sub-table (Appliance column removed), Season is at index 3.
1015+
// skipColEdit must remap this to maintenanceColSeason (4) in the full table,
1016+
// NOT to maintenanceColAppliance.
1017+
m.exitForm()
1018+
m.closeInlineInput()
1019+
require.NoError(t, h.InlineEdit(m, id, 3))
1020+
assert.Equal(t, modeForm, m.mode)
1021+
1022+
// Verify the form opened for season, not appliance:
1023+
// the form data should reflect the current season value.
1024+
fd, ok := m.fs.formData.(*maintenanceFormData)
1025+
require.True(t, ok)
1026+
assert.Equal(t, data.SeasonFall, fd.Season,
1027+
"inline edit on sub-table col 3 should dispatch to Season, not Appliance")
1028+
}
1029+
9931030
// ---------------------------------------------------------------------------
9941031
// Regression: ctrl+s during add form must not create duplicates (#354)
9951032
// ---------------------------------------------------------------------------

internal/app/handlers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ func newApplianceMaintenanceHandler(applianceID uint) scopedHandler {
436436
rows, meta, cellRows := applianceMaintenanceRows(items, logCounts, docCounts)
437437
return rows, meta, cellRows, nil
438438
},
439-
inlineEditFn: skipColEdit(parent, 3), // skip Appliance column
439+
inlineEditFn: skipColEdit(parent, int(maintenanceColAppliance)), // skip Appliance column
440440
}
441441
}
442442

0 commit comments

Comments
 (0)