feat(17-01): tree reorder page and singleton admin controllers
- cabana: config_reorder.yaml (title, nameFrom, modelClass, parentColumn,
sortColumn, maxDepth, partition) with fail-loud boot checks and the
built-in reorder toolbar button; list schema carries reorder
- GET/POST {controller}/reorder: scoped set (ListExtendQuery plus the
partition) locked FOR UPDATE, 409 reorder_stale on any set difference,
422 for duplicates, foreign parents, cycles and maxDepth, both columns
written without model hooks
- pact.AdminSingleton: GET {controller}/singleton (first or create, form
scope checked), form schema singleton, list/create/bulk/delete 404,
no config_list.yaml needed
- swag, inventories, token classes, CSRF walk, conformance cases, backend
lang reorder.stale and load_failed, reorder and singleton smoke tests, docs
This commit is contained in:
@@ -297,6 +297,14 @@ func (s *service) mount(r pact.Router) {
|
||||
constrainController(g)
|
||||
g.Post("/{vendor}/{plugin}/{controller}/bulk-delete", requireAjax(s.bulkDelete))
|
||||
constrainController(g)
|
||||
// Tree reorder page (D-09): the scoped set and its locked save.
|
||||
g.Get("/{vendor}/{plugin}/{controller}/reorder", s.reorderGet)
|
||||
constrainController(g)
|
||||
g.Post("/{vendor}/{plugin}/{controller}/reorder", requireAjax(s.reorderPost))
|
||||
constrainController(g)
|
||||
// The one record of a pact.AdminSingleton controller (D-11).
|
||||
g.Get("/{vendor}/{plugin}/{controller}/singleton", s.singletonRoute)
|
||||
constrainController(g)
|
||||
// Declared bulk actions (D-09): ids are resolved through the list
|
||||
// scope before plugin code runs.
|
||||
g.Post("/{vendor}/{plugin}/{controller}/bulk/{action}", requireAjax(s.bulkAction))
|
||||
@@ -1043,6 +1051,9 @@ func (s *service) enabledContentLocales(ctx context.Context) []string {
|
||||
|
||||
func (s *service) list(w http.ResponseWriter, r *http.Request) {
|
||||
s.protect(w, r, func(cc *CompiledController) {
|
||||
if singletonRefuses(w, r, cc) {
|
||||
return
|
||||
}
|
||||
db, err := s.db()
|
||||
if err != nil {
|
||||
WriteError(w, http.StatusInternalServerError, "error", msgServerError)
|
||||
@@ -1101,6 +1112,10 @@ func (s *service) protect(w http.ResponseWriter, r *http.Request, fn func(*Compi
|
||||
// the toolbar `delete` button, which in turn needs showCheckboxes. The answer is
|
||||
// 403 with the same envelope as a permission failure.
|
||||
func (s *service) operationDeclared(w http.ResponseWriter, r *http.Request, cc *CompiledController, op string) bool {
|
||||
// A singleton controller (D-11) has no create, delete or bulk delete.
|
||||
if op != "update" && singletonRefuses(w, r, cc) {
|
||||
return false
|
||||
}
|
||||
if cc.operationDeclared(op) {
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user