menu.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package e21_presents
  2. import (
  3. "github.com/qor5/admin/presets"
  4. "github.com/qor5/ui/vuetify"
  5. "github.com/qor5/web"
  6. h "github.com/theplant/htmlgo"
  7. )
  8. type music struct{}
  9. type video struct{}
  10. type book struct{}
  11. func PresetsOrderMenu(b *presets.Builder) {
  12. b.Model(&music{}).Listing().PageFunc(func(ctx *web.EventContext) (r web.PageResponse, err error) {
  13. r.Body = vuetify.VContainer(
  14. h.Div(
  15. h.H1("music"),
  16. ).Class("text-center mt-8"),
  17. )
  18. return
  19. })
  20. b.Model(&video{}).Listing().PageFunc(func(ctx *web.EventContext) (r web.PageResponse, err error) {
  21. r.Body = vuetify.VContainer(
  22. h.Div(
  23. h.H1("video"),
  24. ).Class("text-center mt-8"),
  25. )
  26. return
  27. })
  28. b.Model(&book{}).Listing().PageFunc(func(ctx *web.EventContext) (r web.PageResponse, err error) {
  29. r.Body = vuetify.VContainer(
  30. h.Div(
  31. h.H1("book"),
  32. ).Class("text-center mt-8"),
  33. )
  34. return
  35. })
  36. // @snippet_begin(MenuOrderSample)
  37. b.URIPrefix(PresetsMenuOrderPath).
  38. MenuOrder(
  39. "books",
  40. "videos",
  41. "musics",
  42. )
  43. // @snippet_end
  44. }
  45. func PresetsGroupMenu(b *presets.Builder) {
  46. b.URIPrefix(PresetsMenuGroupPath)
  47. b.Model(&music{}).Listing().PageFunc(func(ctx *web.EventContext) (r web.PageResponse, err error) {
  48. r.Body = vuetify.VContainer(
  49. h.Div(
  50. h.H1("music"),
  51. ).Class("text-center mt-8"),
  52. )
  53. return
  54. })
  55. b.Model(&video{}).Listing().PageFunc(func(ctx *web.EventContext) (r web.PageResponse, err error) {
  56. r.Body = vuetify.VContainer(
  57. h.Div(
  58. h.H1("video"),
  59. ).Class("text-center mt-8"),
  60. )
  61. return
  62. })
  63. // @snippet_begin(MenuGroupSample)
  64. mb := b.Model(&book{}).MenuIcon("book")
  65. mb.Listing().PageFunc(func(ctx *web.EventContext) (r web.PageResponse, err error) {
  66. r.Body = vuetify.VContainer(
  67. h.Div(
  68. h.H1("book"),
  69. ).Class("text-center mt-8"),
  70. )
  71. return
  72. })
  73. b.MenuOrder(
  74. "books",
  75. b.MenuGroup("Media").SubItems(
  76. "videos",
  77. "musics",
  78. ).Icon("perm_media"),
  79. )
  80. // @snippet_end
  81. }
  82. const PresetsMenuOrderPath = "/samples/menu_order"
  83. const PresetsMenuGroupPath = "/samples/menu_group"