From ffee082fadc6a0241a08516b37633cd379b78459 Mon Sep 17 00:00:00 2001 From: tamakyi Date: Sun, 20 Sep 2026 09:32:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=A8=E9=A1=B5=EF=BC=9A=E6=89=8B?= =?UTF-8?q?=E5=B7=A5=E5=A1=AB=E8=BF=87=E7=9A=84=E5=80=BC=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=BF=9B=E4=B8=8B=E6=8B=89=E5=80=99=E9=80=89=EF=BC=8C=E5=90=8E?= =?UTF-8?q?=E9=9D=A2=E5=90=8C=E7=B1=BB=E5=9C=B0=E7=82=B9=E4=B8=8D=E7=94=A8?= =?UTF-8?q?=E5=86=8D=E6=89=93=E4=B8=80=E9=81=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 下拉的候选是渲染时定好的,这一页手工新填的活动名/类别进不去候选, 后面遇到同类地点只能照着再敲一遍——这正是「其它(自己写)」最费事的地方。 现在填过的值会被记住并补进同类下拉,标成「新填:X」,插在建议之后、 真正的候选之前,一眼就能挑到;本页实时同步(打字即生效), 翻页和点「用高德分析」重载也留得住,提交成功后清掉(那之后它们已经是真候选了)。 顺带两处: - 草稿保存改成按 name 合并,翻页不再把上一页填的覆盖掉;分页链接也接了保存。 - 重画候选前先把「这一格已经选中的新填值」留住再还回去, 否则改一下文本框就会把别的行选好的值悄悄抹成空。 文本框的监听直接挂在框上而不是委托到 document:`new Event('input')` 默认不冒泡, 探针第一次就是这么假绿的——直接挂不依赖冒泡,也少一层隐式约定。 --- internal/web/fillup_test.go | 21 ++++++ internal/web/templates/admin/fillup.html | 84 +++++++++++++++++++++++- 2 files changed, 102 insertions(+), 3 deletions(-) diff --git a/internal/web/fillup_test.go b/internal/web/fillup_test.go index d728505..a9bfc9f 100644 --- a/internal/web/fillup_test.go +++ b/internal/web/fillup_test.go @@ -301,3 +301,24 @@ func TestFillupCustomActivityEmptyIsSkipped(t *testing.T) { t.Fatalf("没填名字不该建类型,活动数 %d → %d", before, n) } } + +// 「手工填过的值自动进候选」是纯前端行为,Go 测不到运行时,只能钉住它还在模板里。 +// 这东西少一半都不会报错,只会悄悄退回「后面每行都得重新打一遍」—— +// 所以把三个关键标记都钉住:存下来的键、注入选项的标记、显示用的前缀。 +func TestFillupKeepsHandwrittenCandidates(t *testing.T) { + f := newMovementFixture(t) + fillupPlace(t, f) + + rec := httptest.NewRecorder() + req := httptest.NewRequest("GET", "/admin/fillup", nil).WithContext(f.ctx) + f.srv.adminFillupPage(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("渲染失败: %d", rec.Code) + } + body := rec.Body.String() + for _, want := range []string{"rond-fillup-newopts", "data-local", "新填:"} { + if !strings.Contains(body, want) { + t.Errorf("模板里找不到 %q —— 「手工填过的值自动进候选」失效了", want) + } + } +} diff --git a/internal/web/templates/admin/fillup.html b/internal/web/templates/admin/fillup.html index e0ee1a3..2b9bb65 100644 --- a/internal/web/templates/admin/fillup.html +++ b/internal/web/templates/admin/fillup.html @@ -113,6 +113,7 @@