-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
treeview.go
42 lines (35 loc) · 940 Bytes
/
treeview.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
package components
import (
"encoding/json"
"html/template"
"github.com/MarErm27/GoAdmin/modules/utils"
"github.com/MarErm27/GoAdmin/template/types"
)
type TreeViewAttribute struct {
Name string
ID string
Tree types.TreeViewData
TreeJSON template.JS
UrlPrefix string
types.Attribute
}
func (compo *TreeViewAttribute) SetID(id string) types.TreeViewAttribute {
compo.ID = id
return compo
}
func (compo *TreeViewAttribute) SetTree(value types.TreeViewData) types.TreeViewAttribute {
compo.Tree = value
return compo
}
func (compo *TreeViewAttribute) SetUrlPrefix(value string) types.TreeViewAttribute {
compo.UrlPrefix = value
return compo
}
func (compo *TreeViewAttribute) GetContent() template.HTML {
if compo.ID == "" {
compo.ID = utils.Uuid(10)
}
b, _ := json.Marshal(compo.Tree)
compo.TreeJSON = template.JS(b)
return ComposeHtml(compo.TemplateList, compo.Separation, *compo, "treeview")
}