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:
@@ -148,11 +148,18 @@ func ExecuteList(ctx context.Context, db *gorm.DB, cc *CompiledController, in Li
|
||||
return nil, err
|
||||
}
|
||||
values := slice.Elem()
|
||||
data := make([]map[string]any, 0, values.Len())
|
||||
records := make([]any, 0, values.Len())
|
||||
for i := 0; i < values.Len(); i++ {
|
||||
record := values.Index(i).Addr().Interface()
|
||||
records = append(records, record)
|
||||
records = append(records, values.Index(i).Addr().Interface())
|
||||
}
|
||||
if hook, ok := cc.Controller.(pact.ListExtendRecords); ok && hook != nil && len(records) > 0 {
|
||||
if err := hook.ListExtendRecords(ctx, db.WithContext(ctx), records); err != nil {
|
||||
slog.Error("cabana: list extend records failed", "controller", controllerID(cc), "error", err)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
data := make([]map[string]any, 0, len(records))
|
||||
for _, record := range records {
|
||||
data = append(data, projectRowCtx(ctx, record, cc.Controller, cc.List.Columns))
|
||||
}
|
||||
states, err := listRowStates(ctx, db, cc, records)
|
||||
|
||||
Reference in New Issue
Block a user