feat(web): support list editing for channel array fields (#2595)

Add reusable channel array list controls and parsing utilities for channel forms.
Normalize channel string-array payloads in the backend, including pasted values,
numeric IDs, hidden characters, duplicates, and empty clears.
Also allow FlexibleStringSlice to unmarshal null values and cover the new behavior
with backend and config tests.
This commit is contained in:
wenjie
2026-04-21 16:04:28 +08:00
committed by GitHub
parent dcb4b67e00
commit ba6992234f
15 changed files with 1025 additions and 195 deletions
+5
View File
@@ -22,6 +22,11 @@ import (
type FlexibleStringSlice []string
func (f *FlexibleStringSlice) UnmarshalJSON(data []byte) error {
if string(data) == "null" {
*f = nil
return nil
}
// Accept a single JSON string for convenience, e.g.:
// "text": "Thinking..."
var singleString string
+11
View File
@@ -1258,6 +1258,11 @@ func TestFlexibleStringSlice_UnmarshalJSON(t *testing.T) {
input string
expected []string
}{
{
name: "null",
input: `null`,
expected: nil,
},
{
name: "single string",
input: `"Thinking..."`,
@@ -1286,6 +1291,12 @@ func TestFlexibleStringSlice_UnmarshalJSON(t *testing.T) {
if err := json.Unmarshal([]byte(tt.input), &f); err != nil {
t.Fatalf("json.Unmarshal(%s) error = %v", tt.input, err)
}
if tt.expected == nil {
if f != nil {
t.Fatalf("json.Unmarshal(%s) = %#v, want nil slice", tt.input, f)
}
return
}
if len(f) != len(tt.expected) {
t.Fatalf("json.Unmarshal(%s) len = %d, want %d", tt.input, len(f), len(tt.expected))
}