feat(build): scaffold working admin controllers with model, AdminFS and delete (quick-261028-pq8)
- make:admin-controller edits the singular of its name (--model overrides):
ModelName, modelClass and the YAML under models/<model>/
- NewRecord returns &models.<Model>{} when the model exists; otherwise the
nil body stays and the command says to run make:model
- config_list.yaml offers create and delete with showCheckboxes
- registry.gen.go embeds controllers/*/*.yaml and models/*/*.yaml once they
exist and exposes generatedAdminFS(); scaffolded plugins implement
pact.AdminAssets through it, and a plugin without AdminFS gets a note
- blog example moves its YAML to models/post; docs and help text follow
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
package blog
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"io/fs"
|
||||
|
||||
"git.golem15.com/golem15/summercms/docs/examples/blog/controllers"
|
||||
"git.golem15.com/golem15/summercms/docs/examples/blog/models"
|
||||
"git.golem15.com/golem15/summercms/docs/examples/blog/updates"
|
||||
@@ -40,3 +43,16 @@ func generatedAdminControllers() []pact.AdminController {
|
||||
controllers.PostsController(),
|
||||
}
|
||||
}
|
||||
|
||||
// generatedAdminTree holds the admin YAML of the plugin: the controller
|
||||
// configuration and the model fields and columns. Go evaluates the go:embed
|
||||
// globs at compile time, so YAML files added later in these directories are
|
||||
// included; the next make: command rewrites the line when a glob starts or
|
||||
// stops matching a file.
|
||||
//
|
||||
//go:embed controllers/*/*.yaml models/*/*.yaml
|
||||
var generatedAdminTree embed.FS
|
||||
|
||||
// generatedAdminFS returns the admin YAML for pact.AdminAssets: an empty tree
|
||||
// until the first admin controller is scaffolded.
|
||||
func generatedAdminFS() fs.FS { return generatedAdminTree }
|
||||
|
||||
Reference in New Issue
Block a user