fix(09): WR-03 refuse writes that the compiled list and form do not declare

This commit is contained in:
Jakub Zych
2026-10-01 21:04:31 +02:00
parent 28aa073de0
commit f2ab93f291
8 changed files with 127 additions and 5 deletions

View File

@@ -107,6 +107,29 @@ func compileRegistry(items []controllerRef) (*Registry, error) {
return &Registry{byID: byID, assets: assets}, nil
}
// operationDeclared reports whether the controller's compiled list and form
// declare the write operation: create, update, delete or bulk-delete.
func (cc *CompiledController) operationDeclared(op string) bool {
switch op {
case "create":
return cc.Form != nil && (cc.List == nil || hasToolbarButton(cc.List, "create"))
case "update", "delete":
return cc.Form != nil
case "bulk-delete":
return cc.List != nil && hasToolbarButton(cc.List, "delete")
}
return false
}
func hasToolbarButton(list *ListSchema, name string) bool {
for _, button := range list.ToolbarButtons {
if button == name {
return true
}
}
return false
}
func withoutAction(actions []string, drop string) []string {
out := make([]string, 0, len(actions))
for _, action := range actions {