- pact.ListRowStates with the fixed RowState set deleted, negative, disabled - list response meta.row_states keyed by row id; unknown values dropped - list messages rowStateDeleted, rowStateNegative, rowStateDisabled - update writes through the scope the load used, so a soft-deleted record a controller includes stays soft-deleted - DataTable row state badges and text styles - roster fixture, smoke tests, OpenAPI, TS types, dist, READMEs, docs
29 lines
864 B
Go
29 lines
864 B
Go
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
|
|
}
|