confirm-dialog.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package example_basics
  2. import (
  3. "github.com/qor5/admin/presets"
  4. "github.com/qor5/admin/presets/gorm2op"
  5. "github.com/qor5/ui/vuetify"
  6. "github.com/qor5/web"
  7. "github.com/theplant/htmlgo"
  8. )
  9. type confirmDialog struct{}
  10. func PresetsConfirmDialog(b *presets.Builder) {
  11. _ = []interface{}{
  12. // @snippet_begin(OpenConfirmDialog)
  13. presets.OpenConfirmDialog,
  14. // @snippet_end
  15. // @snippet_begin(ConfirmDialogConfirmEvent)
  16. presets.ConfirmDialogConfirmEvent,
  17. // @snippet_end
  18. // @snippet_begin(ConfirmDialogPromptText)
  19. presets.ConfirmDialogPromptText,
  20. // @snippet_end
  21. // @snippet_begin(ConfirmDialogDialogPortalName)
  22. presets.ConfirmDialogDialogPortalName,
  23. // @snippet_end
  24. }
  25. b.URIPrefix(PresetsConfirmDialogPath).
  26. DataOperator(gorm2op.DataOperator(DB))
  27. mb := b.Model(&confirmDialog{}).
  28. URIName("confirm-dialog").
  29. Label("Confirm Dialog")
  30. mb.Listing().PageFunc(func(ctx *web.EventContext) (r web.PageResponse, err error) {
  31. r.Body = htmlgo.Div(
  32. // @snippet_begin(ConfirmDialogSample)
  33. vuetify.VBtn("Delete File").
  34. Attr("@click",
  35. web.Plaid().
  36. EventFunc(presets.OpenConfirmDialog).
  37. Query(presets.ConfirmDialogConfirmEvent,
  38. `alert("file deleted")`,
  39. ).
  40. Go(),
  41. ),
  42. // @snippet_end
  43. ).Class("ma-8")
  44. return r, nil
  45. })
  46. }
  47. const PresetsConfirmDialogPath = "/samples/confirm_dialog"