confirm_dialog.go 985 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package utils
  2. import (
  3. "github.com/qor5/admin/presets"
  4. . "github.com/qor5/ui/vuetify"
  5. "github.com/qor5/x/i18n"
  6. h "github.com/theplant/htmlgo"
  7. "golang.org/x/text/language"
  8. )
  9. const I18nUtilsKey i18n.ModuleKey = "I18nUtilsKey"
  10. func Configure(b *presets.Builder) {
  11. b.I18n().
  12. RegisterForModule(language.English, I18nUtilsKey, Messages_en_US).
  13. RegisterForModule(language.SimplifiedChinese, I18nUtilsKey, Messages_zh_CN).
  14. RegisterForModule(language.Japanese, I18nUtilsKey, Messages_ja_JP)
  15. }
  16. func ConfirmDialog(msg string, okAction string, msgr *Messages) h.HTMLComponent {
  17. return VDialog(
  18. VCard(
  19. VCardTitle(h.Text(msg)),
  20. VCardActions(
  21. VSpacer(),
  22. VBtn(msgr.Cancel).
  23. Depressed(true).
  24. Class("ml-2").
  25. On("click", "locals.commonConfirmDialog = false"),
  26. VBtn(msgr.OK).
  27. Color("primary").
  28. Depressed(true).
  29. Dark(true).
  30. Attr("@click", okAction),
  31. ),
  32. ),
  33. ).MaxWidth("600px").
  34. Attr("v-model", "locals.commonConfirmDialog")
  35. }