list.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. package views
  2. import (
  3. "github.com/qor5/admin/media/media_library"
  4. "github.com/qor5/admin/presets"
  5. "github.com/qor5/web"
  6. h "github.com/theplant/htmlgo"
  7. "gorm.io/gorm"
  8. )
  9. const (
  10. mediaLibraryListField = "media-library-list"
  11. )
  12. func configList(b *presets.Builder, db *gorm.DB) {
  13. mm := b.Model(&media_library.MediaLibrary{}).Label("Media Library").MenuIcon("image").URIName("media-library")
  14. mm.Listing().PageFunc(func(ctx *web.EventContext) (r web.PageResponse, err error) {
  15. r.PageTitle = "Media Library"
  16. keyword := ctx.R.FormValue("keyword")
  17. ctx.R.Form.Set(searchKeywordName(mediaLibraryListField), keyword)
  18. r.Body = h.Components(
  19. web.Portal().Name(deleteConfirmPortalName(mediaLibraryListField)),
  20. web.Portal(
  21. h.Input("").
  22. Type("hidden").
  23. Value(keyword).
  24. Attr(web.VFieldName(searchKeywordName(mediaLibraryListField))...),
  25. fileChooserDialogContent(db, mediaLibraryListField, ctx, &media_library.MediaBoxConfig{}),
  26. ).Name(dialogContentPortalName(mediaLibraryListField)),
  27. )
  28. return
  29. })
  30. }