github.com/kotovmak/go-admin@v1.1.1/template/components/base.go (about) 1 package components 2 3 import ( 4 "html/template" 5 6 "github.com/kotovmak/go-admin/modules/config" 7 "github.com/kotovmak/go-admin/modules/menu" 8 "github.com/kotovmak/go-admin/template/types" 9 "github.com/kotovmak/go-admin/template/types/form" 10 ) 11 12 type Base struct { 13 Attribute types.Attribute 14 } 15 16 func (b Base) Box() types.BoxAttribute { 17 return &BoxAttribute{ 18 Name: "box", 19 Header: template.HTML(""), 20 Body: template.HTML(""), 21 Footer: template.HTML(""), 22 Title: "", 23 HeadBorder: "", 24 Attribute: b.Attribute, 25 } 26 } 27 28 func (b Base) Col() types.ColAttribute { 29 return &ColAttribute{ 30 Name: "col", 31 Size: "col-md-2", 32 Content: "", 33 Attribute: b.Attribute, 34 } 35 } 36 37 func (b Base) Form() types.FormAttribute { 38 return &FormAttribute{ 39 Name: "form", 40 Content: []types.FormField{}, 41 Url: "/", 42 Method: "post", 43 HiddenFields: make(map[string]string), 44 Layout: form.LayoutDefault, 45 Title: "edit", 46 Attribute: b.Attribute, 47 CdnUrl: config.GetAssetUrl(), 48 HeadWidth: 2, 49 InputWidth: 8, 50 } 51 } 52 53 func (b Base) Image() types.ImgAttribute { 54 return &ImgAttribute{ 55 Name: "image", 56 Width: "50", 57 Height: "50", 58 Src: "", 59 Attribute: b.Attribute, 60 } 61 } 62 63 func (b Base) Tabs() types.TabsAttribute { 64 return &TabsAttribute{ 65 Name: "tabs", 66 Attribute: b.Attribute, 67 } 68 } 69 70 func (b Base) Alert() types.AlertAttribute { 71 return &AlertAttribute{ 72 Name: "alert", 73 Attribute: b.Attribute, 74 } 75 } 76 77 func (b Base) Label() types.LabelAttribute { 78 return &LabelAttribute{ 79 Name: "label", 80 Type: "", 81 Content: "", 82 Attribute: b.Attribute, 83 } 84 } 85 86 func (b Base) Link() types.LinkAttribute { 87 return &LinkAttribute{ 88 Name: "link", 89 Content: "", 90 Attribute: b.Attribute, 91 } 92 } 93 94 func (b Base) Popup() types.PopupAttribute { 95 return &PopupAttribute{ 96 Name: "popup", 97 Attribute: b.Attribute, 98 } 99 } 100 101 func (b Base) Paginator() types.PaginatorAttribute { 102 return &PaginatorAttribute{ 103 Name: "paginator", 104 Attribute: b.Attribute, 105 } 106 } 107 108 func (b Base) Row() types.RowAttribute { 109 return &RowAttribute{ 110 Name: "row", 111 Content: "", 112 Attribute: b.Attribute, 113 } 114 } 115 116 func (b Base) Button() types.ButtonAttribute { 117 return &ButtonAttribute{ 118 Name: "button", 119 Attribute: b.Attribute, 120 } 121 } 122 123 func (b Base) Table() types.TableAttribute { 124 return &TableAttribute{ 125 Name: "table", 126 Thead: make(types.Thead, 0), 127 InfoList: make([]map[string]types.InfoItem, 0), 128 Type: "table", 129 Style: "hover", 130 Layout: "auto", 131 Attribute: b.Attribute, 132 } 133 } 134 135 func (b Base) DataTable() types.DataTableAttribute { 136 return &DataTableAttribute{ 137 TableAttribute: *(b.Table(). 138 SetStyle("hover"). 139 SetName("data-table"). 140 SetType("data-table").(*TableAttribute)), 141 Attribute: b.Attribute, 142 } 143 } 144 145 func (b Base) Tree() types.TreeAttribute { 146 return &TreeAttribute{ 147 Name: "tree", 148 Tree: make([]menu.Item, 0), 149 Attribute: b.Attribute, 150 } 151 } 152 153 func (b Base) TreeView() types.TreeViewAttribute { 154 return &TreeViewAttribute{ 155 Name: "treeview", 156 Attribute: b.Attribute, 157 } 158 }