- config_reorder.yaml without parentColumn on a record with no parent_id column compiles as a flat (WinterCMS Sortable) reorder; maxDepth above 0 on it fails boot, an explicit parentColumn still means a tree - ListReorder.Flat and AdminReorderTree.Flat (flat, omitempty); flat nodes carry parent_id null, a save writes only the sort column, a parent is a 422 on nodes (reorder.flat_parent); 409 and duplicate rules unchanged - swag descriptions, OpenAPI and schema.d.ts regenerated - acme.catalog badges reorder fixture, TestReorderFlatCompile and TestReorderFlatSmoke; docs Flat reorder section and cabana README
71 lines
2.2 KiB
Go
71 lines
2.2 KiB
Go
package cabana
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"git.golem15.com/golem15/summercms/modules/pact"
|
|
"git.golem15.com/golem15/summercms/modules/party"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// CompiledListSchema compiles the admin controllers of plugins without a
|
|
// database or config, as Activate does, and returns the list schema of the
|
|
// controller id (with its reorder object).
|
|
func CompiledListSchema(plugins []party.Plugin, id string) (*ListSchema, error) {
|
|
items, err := collectControllers(plugins)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
types, err := compileFieldTypes(plugins)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
reg, err := compileRegistryWithTypes(items, types)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
cc, ok := reg.Get(id)
|
|
if !ok || cc.List == nil {
|
|
return nil, fmt.Errorf("cabana: no list schema for %s", id)
|
|
}
|
|
return cc.List, nil
|
|
}
|
|
|
|
// AdminAPIRoutes exposes the admin API route inventory (method plus
|
|
// prefix-relative path) to the external conformance test.
|
|
func AdminAPIRoutes() []string {
|
|
out := make([]string, 0, len(phase09Routes))
|
|
for _, route := range phase09Routes {
|
|
if !route.spa {
|
|
out = append(out, route.key)
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
// IssueTestAPIToken mints a personal API token for ownerID with the given
|
|
// scopes and optional expiry. Used by external Postgres smoke tests before
|
|
// the HTTP create route exists.
|
|
func IssueTestAPIToken(db *gorm.DB, ownerID uint, scopes []string, expiresAt *time.Time) (plain string, err error) {
|
|
plain, _, err = insertAPIToken(db, ownerID, "test", scopes, expiresAt)
|
|
return plain, err
|
|
}
|
|
|
|
// ValidateMoneyValue exposes the money field's save check (phrase key and
|
|
// placeholders of the first failure, "" when accepted) to the external
|
|
// money field tests.
|
|
func ValidateMoneyValue(value any, scale int, max string) (string, map[string]string) {
|
|
return validateMoneyValue(value, scale, max)
|
|
}
|
|
|
|
// CheckMoneyType exposes the money field's model column gate to the
|
|
// external money field tests.
|
|
func CheckMoneyType(model any, field FormField) error { return checkMoneyType(model, field) }
|
|
|
|
// ProjectRow exposes one list row's projection to the external money
|
|
// column tests.
|
|
func ProjectRow(row any, controller pact.AdminController, cols []ListColumn) map[string]any {
|
|
return projectRow(row, controller, cols)
|
|
}
|