datetime-picker.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. package vuetifyx
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/qor5/web"
  6. h "github.com/theplant/htmlgo"
  7. )
  8. type VXDateTimePickerBuilder struct {
  9. tag *h.HTMLTagBuilder
  10. }
  11. func VXDateTimePicker() (r *VXDateTimePickerBuilder) {
  12. r = &VXDateTimePickerBuilder{
  13. tag: h.Tag("vx-datetimepicker"),
  14. }
  15. return
  16. }
  17. type DatePickerProps struct {
  18. }
  19. type TimePickerProps struct {
  20. Format string `json:"format"` // 可用的选项是 ampm 和 24hr
  21. Scrollable bool `json:"scrollable"`
  22. UseSeconds bool `json:"use-seconds"`
  23. NoTitle bool `json:"no-title"`
  24. }
  25. func (b *VXDateTimePickerBuilder) Value(v string) (r *VXDateTimePickerBuilder) {
  26. b.tag.Attr(":value", h.JSONString(v))
  27. return b
  28. }
  29. func (b *VXDateTimePickerBuilder) FieldName(v string) (r *VXDateTimePickerBuilder) {
  30. b.tag.Attr(web.VFieldName(v)...)
  31. return b
  32. }
  33. func (b *VXDateTimePickerBuilder) Label(v string) (r *VXDateTimePickerBuilder) {
  34. b.tag.Attr(":label", h.JSONString(v))
  35. return b
  36. }
  37. func (b *VXDateTimePickerBuilder) DialogWidth(v int) (r *VXDateTimePickerBuilder) {
  38. b.tag.Attr(":dialogWidth", h.JSONString(v))
  39. return b
  40. }
  41. func (b *VXDateTimePickerBuilder) DateFormat(v string) (r *VXDateTimePickerBuilder) {
  42. b.tag.Attr(":dateFormat", h.JSONString(v))
  43. return b
  44. }
  45. func (b *VXDateTimePickerBuilder) TimeFormat(v string) (r *VXDateTimePickerBuilder) {
  46. b.tag.Attr(":timeFormat", h.JSONString(v))
  47. return b
  48. }
  49. func (b *VXDateTimePickerBuilder) ClearText(v string) (r *VXDateTimePickerBuilder) {
  50. b.tag.Attr(":clearText", h.JSONString(v))
  51. return b
  52. }
  53. func (b *VXDateTimePickerBuilder) OkText(v string) (r *VXDateTimePickerBuilder) {
  54. b.tag.Attr(":okText", h.JSONString(v))
  55. return b
  56. }
  57. func (b *VXDateTimePickerBuilder) Disabled(v bool) (r *VXDateTimePickerBuilder) {
  58. b.tag.Attr(":disabled", h.JSONString(v))
  59. return b
  60. }
  61. func (b *VXDateTimePickerBuilder) DatePickerProps(v DatePickerProps) (r *VXDateTimePickerBuilder) {
  62. b.tag.Attr(":datePickerProps", h.JSONString(v))
  63. return b
  64. }
  65. func (b *VXDateTimePickerBuilder) TimePickerProps(v TimePickerProps) (r *VXDateTimePickerBuilder) {
  66. b.tag.Attr(":timePickerProps", h.JSONString(v))
  67. return b
  68. }
  69. func (b *VXDateTimePickerBuilder) SetAttr(k string, v interface{}) {
  70. b.tag.SetAttr(k, v)
  71. }
  72. func (b *VXDateTimePickerBuilder) Attr(vs ...interface{}) (r *VXDateTimePickerBuilder) {
  73. b.tag.Attr(vs...)
  74. return b
  75. }
  76. func (b *VXDateTimePickerBuilder) HideDetails(v bool) (r *VXDateTimePickerBuilder) {
  77. b.tag.Attr(":hide-details", fmt.Sprint(v))
  78. return b
  79. }
  80. func (b *VXDateTimePickerBuilder) MarshalHTML(ctx context.Context) (r []byte, err error) {
  81. return b.tag.MarshalHTML(ctx)
  82. }