diff --git a/internal/web/fillup.go b/internal/web/fillup.go index be9c367..4bfa36a 100644 --- a/internal/web/fillup.go +++ b/internal/web/fillup.go @@ -344,7 +344,13 @@ func (s *Server) adminFillupApply(w http.ResponseWriter, r *http.Request) { acts += int(n) } } - if cat := strings.TrimSpace(r.PostFormValue("cat_" + strconv.FormatInt(pid, 10))); cat != "" { + key := "cat_" + strconv.FormatInt(pid, 10) + cat := strings.TrimSpace(r.PostFormValue(key)) + if cat == "__custom__" { + // 下拉里选了「其它(自己写)」,真正要写的是旁边那个文本框 + cat = strings.TrimSpace(r.PostFormValue(key + "__custom")) + } + if cat != "" { res, err := ex.ExecContext(ctx, `UPDATE places SET poi_category=$1 WHERE dataset_id=$2 AND id=$3 AND COALESCE(poi_category,'')=''`, cat, ds.ID, pid) if err != nil { diff --git a/internal/web/fillup_test.go b/internal/web/fillup_test.go index 30097ef..a4a4932 100644 --- a/internal/web/fillup_test.go +++ b/internal/web/fillup_test.go @@ -215,7 +215,8 @@ func TestFillupPagination(t *testing.T) { t.Fatalf("%s 渲染失败: %d", url, rec.Code) } body := rec.Body.String() - return strings.Count(body, `name="cat_`), strings.Count(body, `class="pager"`) + // 数类别下拉本身;旁边那个「其它(自己写)」文本框的 name 也以 cat_ 开头,得排掉 + return strings.Count(body, `
@@ -52,24 +52,21 @@ @@ -85,10 +82,12 @@
- + +
+ {{if gt .PageCount 1}}
{{if gt .PageNo 1}}上一页{{end}} @@ -104,19 +103,72 @@ {{end}}
+ + {{range .Activities}}{{end}} + + diff --git a/internal/web/view.go b/internal/web/view.go index 918bd28..613ca84 100644 --- a/internal/web/view.go +++ b/internal/web/view.go @@ -1327,6 +1327,8 @@ func templateFuncs() template.FuncMap { "dt": func(t time.Time) string { return t.Local().Format("2006-01-02 15:04") }, // actKey 给活动冲突生成表单字段名,与处理函数共用同一套键 "actKey": rond.ActivityKey, + // catName 把 MKPOICategoryXxx 翻成中文,补全页的类别下拉要用 + "catName": poiName, // dtt 接受 *time.Time,nil 返回空串,便于可选时间字段直接渲染 "dtt": func(t *time.Time) string { if t == nil {
{{$row.Missing}} {{if $row.NoAct}} - + {{else}}—{{end}} {{if $row.NoCat}} {{$hint := $row.CatHint}} - + + {{if $hint}}{{end}} + {{range $.Categories}}{{if ne .Value $hint}}{{end}}{{end}} + + {{else}}—{{end}} {{if $row.Source}}{{$row.Source}}{{else}}—{{end}}