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:
@@ -734,6 +734,17 @@ type ListRowStates interface {
|
||||
ListRowStates(ctx context.Context, db *gorm.DB, records []any) ([][]RowState, error)
|
||||
}
|
||||
|
||||
// ListExtendRecords optionally completes the records of one admin list page
|
||||
// before their columns are read (WinterCMS's listExtendRecords). The framework
|
||||
// calls it once per page with the page's records (pointers, in page order) and
|
||||
// the list's database handle, so a controller can fill non-persisted fields
|
||||
// its columns show with one batched query instead of one per row. A column of
|
||||
// such a field names it by its gorm column tag and sets sortable: false. An
|
||||
// error fails the list.
|
||||
type ListExtendRecords interface {
|
||||
ListExtendRecords(ctx context.Context, db *gorm.DB, records []any) error
|
||||
}
|
||||
|
||||
// ListRelationColumnMapper maps a source-schema relation column onto the
|
||||
// physical column exposed by the related Go model. It supports legacy admin
|
||||
// schemas whose public field names no longer match the database schema.
|
||||
@@ -741,6 +752,16 @@ type ListRelationColumnMapper interface {
|
||||
ListRelationColumn(relation, column string) (string, bool)
|
||||
}
|
||||
|
||||
// FormRecordTitle optionally names a record on its form and preview screens.
|
||||
// The framework calls it whenever it sends a record (the show, create and
|
||||
// update responses) with the loaded record and the request's database handle.
|
||||
// A non-empty answer is sent as the record envelope's meta.title, which the
|
||||
// admin shows instead of the value of the form's first text field. An error
|
||||
// fails the request.
|
||||
type FormRecordTitle interface {
|
||||
FormRecordTitle(ctx context.Context, db *gorm.DB, record any) (string, error)
|
||||
}
|
||||
|
||||
// FormExtendQuery optionally narrows admin form record lookup.
|
||||
type FormExtendQuery interface {
|
||||
FormExtendQuery(ctx context.Context, db *gorm.DB) *gorm.DB
|
||||
|
||||
Reference in New Issue
Block a user