forked from GoAdminGroup/go-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
table.go
230 lines (192 loc) · 5.56 KB
/
table.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
package components
import (
"html/template"
"github.com/dikiharyadi19/go-admin/template/types"
)
type TableAttribute struct {
Name string
Thead types.Thead
InfoList []map[string]types.InfoItem
Type string
PrimaryKey string
Style string
HideThead bool
NoAction bool
Action template.HTML
EditUrl string
MinWidth string
DeleteUrl string
DetailUrl string
SortUrl string
UpdateUrl string
Layout string
IsTab bool
ExportUrl string
ActionFold bool
types.Attribute
}
func (compo *TableAttribute) SetThead(value types.Thead) types.TableAttribute {
compo.Thead = value
return compo
}
func (compo *TableAttribute) SetInfoList(value []map[string]types.InfoItem) types.TableAttribute {
compo.InfoList = value
return compo
}
func (compo *TableAttribute) SetType(value string) types.TableAttribute {
compo.Type = value
return compo
}
func (compo *TableAttribute) SetName(name string) types.TableAttribute {
compo.Name = name
return compo
}
func (compo *TableAttribute) SetHideThead() types.TableAttribute {
compo.HideThead = true
return compo
}
func (compo *TableAttribute) SetStyle(style string) types.TableAttribute {
compo.Style = style
return compo
}
func (compo *TableAttribute) SetMinWidth(value string) types.TableAttribute {
compo.MinWidth = value
return compo
}
func (compo *TableAttribute) SetLayout(value string) types.TableAttribute {
compo.Layout = value
return compo
}
func (compo *TableAttribute) GetContent() template.HTML {
if compo.MinWidth == "" {
compo.MinWidth = "1000px"
}
return ComposeHtml(compo.TemplateList, compo.Separation, *compo, "table")
}
type DataTableAttribute struct {
TableAttribute
EditUrl string
NewUrl string
UpdateUrl string
HideThead bool
DetailUrl string
SortUrl template.URL
DeleteUrl string
PrimaryKey string
IsTab bool
ExportUrl string
InfoUrl string
Buttons template.HTML
ActionJs template.JS
IsHideFilterArea bool
IsHideRowSelector bool
NoAction bool
HasFilter bool
Action template.HTML
ActionFold bool
types.Attribute
}
func (compo *DataTableAttribute) GetDataTableHeader() template.HTML {
return ComposeHtml(compo.TemplateList, compo.Separation, *compo, "table/box-header")
}
func (compo *DataTableAttribute) SetThead(value types.Thead) types.DataTableAttribute {
compo.Thead = value
return compo
}
func (compo *DataTableAttribute) SetLayout(value string) types.DataTableAttribute {
compo.Layout = value
return compo
}
func (compo *DataTableAttribute) SetIsTab(value bool) types.DataTableAttribute {
compo.IsTab = value
return compo
}
func (compo *DataTableAttribute) SetHideThead() types.DataTableAttribute {
compo.HideThead = true
return compo
}
func (compo *DataTableAttribute) SetButtons(btns template.HTML) types.DataTableAttribute {
compo.Buttons = btns
return compo
}
func (compo *DataTableAttribute) SetHideFilterArea(value bool) types.DataTableAttribute {
compo.IsHideFilterArea = value
return compo
}
func (compo *DataTableAttribute) SetActionJs(aj template.JS) types.DataTableAttribute {
compo.ActionJs = aj
return compo
}
func (compo *DataTableAttribute) SetActionFold(fold bool) types.DataTableAttribute {
compo.ActionFold = fold
return compo
}
func (compo *DataTableAttribute) SetHasFilter(hasFilter bool) types.DataTableAttribute {
compo.HasFilter = hasFilter
return compo
}
func (compo *DataTableAttribute) SetInfoUrl(value string) types.DataTableAttribute {
compo.InfoUrl = value
return compo
}
func (compo *DataTableAttribute) SetAction(action template.HTML) types.DataTableAttribute {
compo.Action = action
return compo
}
func (compo *DataTableAttribute) SetStyle(style string) types.DataTableAttribute {
compo.Style = style
return compo
}
func (compo *DataTableAttribute) SetExportUrl(value string) types.DataTableAttribute {
compo.ExportUrl = value
return compo
}
func (compo *DataTableAttribute) SetHideRowSelector(value bool) types.DataTableAttribute {
compo.IsHideRowSelector = value
return compo
}
func (compo *DataTableAttribute) SetUpdateUrl(value string) types.DataTableAttribute {
compo.UpdateUrl = value
return compo
}
func (compo *DataTableAttribute) SetDetailUrl(value string) types.DataTableAttribute {
compo.DetailUrl = value
return compo
}
func (compo *DataTableAttribute) SetSortUrl(value string) types.DataTableAttribute {
compo.SortUrl = template.URL(value)
return compo
}
func (compo *DataTableAttribute) SetPrimaryKey(value string) types.DataTableAttribute {
compo.PrimaryKey = value
return compo
}
func (compo *DataTableAttribute) SetInfoList(value []map[string]types.InfoItem) types.DataTableAttribute {
compo.InfoList = value
return compo
}
func (compo *DataTableAttribute) SetEditUrl(value string) types.DataTableAttribute {
compo.EditUrl = value
return compo
}
func (compo *DataTableAttribute) SetDeleteUrl(value string) types.DataTableAttribute {
compo.DeleteUrl = value
return compo
}
func (compo *DataTableAttribute) SetNewUrl(value string) types.DataTableAttribute {
compo.NewUrl = value
return compo
}
func (compo *DataTableAttribute) SetNoAction() types.DataTableAttribute {
compo.NoAction = true
return compo
}
func (compo *DataTableAttribute) GetContent() template.HTML {
if compo.MinWidth == "" {
compo.MinWidth = "1000px"
}
if !compo.NoAction && compo.EditUrl == "" && compo.DeleteUrl == "" && compo.DetailUrl == "" && compo.Action == "" {
compo.NoAction = true
}
return ComposeHtml(compo.TemplateList, compo.Separation, *compo, "table")
}