File size: 950 Bytes
530729e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
package components

import (
	"encoding/json"
	"html/template"

	"github.com/GoAdminGroup/go-admin/modules/utils"
	"github.com/GoAdminGroup/go-admin/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")
}