feat(17-04): menu plugin admin with registry types, URL checks and tree reorder
- golem15.menu plugin, tables golem15_menu_menus and golem15_menu_menu_entries with the PHP columns plus a nullable url_pattern (D-02) - MenuEntry BeforeSave ports PHP beforeSave: nest columns 0, menu from the parent, sort_order after the menu's last - entry type dropdown: url, divider and the signpost registry types; reference depends on type through signpost.ReferenceOptions - URL scheme allowlist (errors.url_scheme), target _self or _blank, menu and parent cycle checks - menu filter, toolbar reorder/create/delete and config_reorder.yaml partitioned by menu - navigation Menus with Menus and Menu entries, permission golem15.menu.manage_menu, en and pl phrasebooks - TestMenuAdminSmoke
This commit is contained in:
38
models/menu.go
Normal file
38
models/menu.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
// Menu is a named menu stored on golem15_menu_menus, the PHP
|
||||
// Golem15\Menu\Models\Menu. Sites address a menu by its unique code.
|
||||
type Menu struct {
|
||||
ID uint `gorm:"column:id;primaryKey"`
|
||||
Name string `gorm:"column:name"`
|
||||
Code string `gorm:"column:code"`
|
||||
IsActive bool `gorm:"column:is_active"`
|
||||
CSSClass *string `gorm:"column:css_class"`
|
||||
Entries []MenuEntry `gorm:"foreignKey:MenuID" json:"-"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at"`
|
||||
}
|
||||
|
||||
func (Menu) TableName() string { return "golem15_menu_menus" }
|
||||
|
||||
// MorphName is the PHP class string of the model.
|
||||
func (Menu) MorphName() string { return `Golem15\Menu\Models\Menu` }
|
||||
|
||||
// Fillable is the list an admin save may set.
|
||||
func (Menu) Fillable() []string {
|
||||
return []string{"name", "code", "is_active", "css_class"}
|
||||
}
|
||||
|
||||
// Rules require a name and a code that no other menu uses.
|
||||
func (Menu) Rules() map[string]string {
|
||||
return map[string]string{
|
||||
"name": "required",
|
||||
"code": "required|unique:golem15_menu_menus",
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
Register(Menu{})
|
||||
}
|
||||
Reference in New Issue
Block a user