forked from GoAdminGroup/go-admin
/
table.go
74 lines (60 loc) · 1.69 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
package components
import (
"github.com/chenhg5/go-admin/template/types"
"html/template"
)
type TableAttribute struct {
Name string
Thead []map[string]string
InfoList []map[string]template.HTML
Type string
EditUrl string
DeleteUrl string
}
func (compo *TableAttribute) SetThead(value []map[string]string) types.TableAttribute {
compo.Thead = value
return compo
}
func (compo *TableAttribute) SetInfoList(value []map[string]template.HTML) types.TableAttribute {
compo.InfoList = value
return compo
}
func (compo *TableAttribute) SetType(value string) types.TableAttribute {
compo.Type = value
return compo
}
func (compo *TableAttribute) GetContent() template.HTML {
return ComposeHtml(*compo, "table")
}
type DataTableAttribute struct {
TableAttribute
EditUrl string
NewUrl string
DeleteUrl string
}
func (compo *DataTableAttribute) GetDataTableHeader() template.HTML {
return ComposeHtml(*compo, "table/box-header")
}
func (compo *DataTableAttribute) SetThead(value []map[string]string) types.DataTableAttribute {
compo.Thead = value
return compo
}
func (compo *DataTableAttribute) SetInfoList(value []map[string]template.HTML) 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) GetContent() template.HTML {
return ComposeHtml(*compo, "table")
}