package cabana_test import ( "context" "git.golem15.com/golem15/summercms/modules/pact" "gorm.io/gorm" ) var _ pact.ListRowStates = PeopleController{} // ListRowStates marks the rows of one list page. The framework calls it once // per page with the page's records, in page order; the result is aligned // with records, and a nil entry means the row has no state. db is the list's // handle, for a hook that needs one query for the whole page. func (PeopleController) ListRowStates(_ context.Context, _ *gorm.DB, records []any) ([][]pact.RowState, error) { states := make([][]pact.RowState, len(records)) for i, record := range records { person := record.(*Person) if person.Banned { states[i] = append(states[i], pact.RowStateNegative) } if !person.Active { states[i] = append(states[i], pact.RowStateDisabled) } } return states, nil }