fix(admin): datetime popover clock, unsaved confirm, inferred list dates

BM UAT on v0.1.1 showed a date-only calendar for datetime fields, a stuck discard dialog, and raw ISO timestamps when columns.yaml omitted type. The picker now edits time in the popover, confirm sits above the calendar, and omitted time.Time / Date / TimeOfDay columns compile as datetime / date / time.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jakub Zych
2026-10-03 05:58:24 +02:00
parent 8031fd1c16
commit 55314e41f8
14 changed files with 227 additions and 32 deletions

View File

@@ -9,6 +9,7 @@ import (
"testing/fstest"
"time"
"git.golem15.com/golem15/summercms/modules/lagoon"
"git.golem15.com/golem15/summercms/modules/pact"
"git.golem15.com/golem15/summercms/modules/phrasebook"
"git.golem15.com/golem15/summercms/modules/towel"
@@ -96,6 +97,55 @@ toolbar:
})
}
func TestListColumnTypeInferred(t *testing.T) {
const columns = `columns:
name:
label: Name
searchable: true
created_at:
label: Created
released_on:
label: Released
opens_at:
label: Opens
active:
label: Active
type: switch
`
type row struct {
ID uint `gorm:"column:id;primaryKey"`
Name string `gorm:"column:name"`
CreatedAt time.Time `gorm:"column:created_at"`
ReleasedOn lagoon.Date `gorm:"column:released_on;type:date"`
OpensAt lagoon.TimeOfDay `gorm:"column:opens_at;type:time without time zone"`
Active bool `gorm:"column:active"`
}
ctl := filterController{schemaController: schemaController{model: "Widget"}, rec: &row{}}
schema, err := CompileList("acme.demo", ctl, listFS(allColumnsConfig, columns))
if err != nil {
t.Fatal(err)
}
got := map[string]string{}
for _, col := range schema.Columns {
got[col.Key] = col.Type
}
want := map[string]string{
"name": "",
"created_at": "datetime",
"released_on": "date",
"opens_at": "time",
"active": "switch",
}
if len(got) != len(want) {
t.Fatalf("columns = %v, want %v", got, want)
}
for key, typ := range want {
if got[key] != typ {
t.Fatalf("column %s type = %q, want %q (%v)", key, got[key], typ, got)
}
}
}
func TestListSchemaEmpty(t *testing.T) {
const config = `list: ~/plugins/acme/demo/models/widget/columns.yaml
modelClass: Widget