-
Notifications
You must be signed in to change notification settings - Fork 0
/
display.go
66 lines (56 loc) · 1.26 KB
/
display.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
package admin
var DefaultDisplay = &Display{
Name: "default",
Label: PKG + ".resource.display.Default",
}
type DisplayInterface interface {
ThemeInterface
GetLayoutName() string
GetIcon() string
GetLabel() string
}
type Display struct {
Name string
LayoutName string
Icon string
Label string
GetViewPathsFunc func() []string
ConfigAdminThemeFunc func(*Resource)
EnabledFunc func(ctx *Context) bool
}
// GetName get name from theme
func (d *Display) GetName() string {
return d.Name
}
func (d *Display) Enabled(ctx *Context) bool {
if d.EnabledFunc != nil {
return d.EnabledFunc(ctx)
}
return true
}
// GetViewPaths get view paths from theme
func (d *Display) GetViewPaths() []string {
if d.GetViewPathsFunc != nil {
return d.GetViewPathsFunc()
}
return []string{}
}
// ConfigAdminTheme config theme for admin resource
func (d *Display) ConfigAdminTheme(res *Resource) {
if d.ConfigAdminThemeFunc != nil {
d.ConfigAdminThemeFunc(res)
}
return
}
func (d *Display) GetLayoutName() string {
if d.LayoutName == "" {
return SectionLayoutDefault
}
return d.LayoutName
}
func (d *Display) GetIcon() string {
return d.Icon
}
func (d *Display) GetLabel() string {
return d.Label
}