linkage-select.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package vuetifyx
  2. import (
  3. "context"
  4. "github.com/qor5/web"
  5. h "github.com/theplant/htmlgo"
  6. )
  7. type VXLinkageSelectBuilber struct {
  8. tag *h.HTMLTagBuilder
  9. }
  10. func VXLinkageSelect() *VXLinkageSelectBuilber {
  11. b := &VXLinkageSelectBuilber{
  12. tag: h.Tag("vx-linkageselect"),
  13. }
  14. return b
  15. }
  16. func (b *VXLinkageSelectBuilber) FieldName(v string) (r *VXLinkageSelectBuilber) {
  17. b.tag.Attr(web.VFieldName(v)...)
  18. return b
  19. }
  20. type LinkageSelectItem struct {
  21. ID string
  22. Name string
  23. ChildrenIDs []string
  24. }
  25. func (b *VXLinkageSelectBuilber) Items(vs ...[]*LinkageSelectItem) (r *VXLinkageSelectBuilber) {
  26. b.tag.Attr(":items", vs)
  27. return b
  28. }
  29. func (b *VXLinkageSelectBuilber) Labels(vs ...string) (r *VXLinkageSelectBuilber) {
  30. b.tag.Attr(":labels", vs)
  31. return b
  32. }
  33. func (b *VXLinkageSelectBuilber) SelectedIDs(vs ...string) (r *VXLinkageSelectBuilber) {
  34. b.tag.Attr(":value", vs)
  35. return b
  36. }
  37. func (b *VXLinkageSelectBuilber) ErrorMessages(vs ...[]string) (r *VXLinkageSelectBuilber) {
  38. b.tag.Attr(":error-messages", vs)
  39. return b
  40. }
  41. func (b *VXLinkageSelectBuilber) Disabled(v bool) (r *VXLinkageSelectBuilber) {
  42. b.tag.Attr(":disabled", h.JSONString(v))
  43. return b
  44. }
  45. func (b *VXLinkageSelectBuilber) SelectOutOfOrder(v bool) (r *VXLinkageSelectBuilber) {
  46. b.tag.Attr(":select-out-of-order", h.JSONString(v))
  47. return b
  48. }
  49. func (b *VXLinkageSelectBuilber) Chips(v bool) (r *VXLinkageSelectBuilber) {
  50. b.tag.Attr(":chips", h.JSONString(v))
  51. return b
  52. }
  53. func (b *VXLinkageSelectBuilber) Row(v bool) (r *VXLinkageSelectBuilber) {
  54. b.tag.Attr(":row", h.JSONString(v))
  55. return b
  56. }
  57. func (b *VXLinkageSelectBuilber) MarshalHTML(ctx context.Context) ([]byte, error) {
  58. return b.tag.MarshalHTML(ctx)
  59. }