feat(quick-261016-nqk): ListExtendRecords and FormRecordTitle admin hooks (G-18.1-4)
pact.ListExtendRecords fills unstored fields of one list page before its columns are read (WinterCMS listExtendRecords); such columns compile unsortable and refuse sortable/searchable. pact.FormRecordTitle names a record; the show, create and update responses send it as meta.title.
This commit is contained in:
@@ -645,3 +645,33 @@ func filterCatalog(t *testing.T) *phrasebook.Catalog {
|
||||
}
|
||||
return cat
|
||||
}
|
||||
|
||||
// TestListUnstoredColumn: a column of a field gorm ignores (filled by
|
||||
// pact.ListExtendRecords) compiles unsortable, and declaring it sortable or
|
||||
// searchable fails the boot.
|
||||
func TestListUnstoredColumn(t *testing.T) {
|
||||
type row struct {
|
||||
ID uint `gorm:"column:id;primaryKey"`
|
||||
Name string `gorm:"column:name"`
|
||||
Badge string `gorm:"-:all;column:badge"`
|
||||
Note string `gorm:"-"`
|
||||
}
|
||||
ctl := filterController{schemaController: schemaController{model: "Widget"}, rec: &row{}}
|
||||
schema, err := CompileList("acme.demo", ctl, listFS(allColumnsConfig, "columns:\n name:\n label: Name\n badge:\n label: Badge\n Note:\n label: Note\n"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sortable := map[string]bool{}
|
||||
for _, col := range schema.Columns {
|
||||
sortable[col.Key] = col.Sortable
|
||||
}
|
||||
if !sortable["name"] || sortable["badge"] || sortable["Note"] {
|
||||
t.Fatalf("sortable = %v, want only name", sortable)
|
||||
}
|
||||
for _, bad := range []string{"sortable: true", "searchable: true"} {
|
||||
_, err := CompileList("acme.demo", ctl, listFS(allColumnsConfig, "columns:\n badge:\n label: Badge\n "+bad+"\n"))
|
||||
if err == nil || !strings.Contains(err.Error(), "column badge is not stored") {
|
||||
t.Fatalf("%s: err = %v", bad, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user