-
Notifications
You must be signed in to change notification settings - Fork 0
/
label.go
33 lines (29 loc) · 778 Bytes
/
label.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
package display
import (
"github.com/alesjr/go-admin/go-admin/template"
"github.com/alesjr/go-admin/go-admin/template/types"
)
type Label struct {
types.BaseDisplayFnGenerator
}
func init() {
types.RegisterDisplayFnGenerator("label", new(Label))
}
func (label *Label) Get(args ...interface{}) types.FieldFilterFn {
return func(value types.FieldModel) interface{} {
params := args[0].([]types.FieldLabelParam)
if len(params) == 0 {
return template.Default().Label().
SetContent(template.HTML(value.Value)).
SetType("success").
GetContent()
} else if len(params) == 1 {
return template.Default().Label().
SetContent(template.HTML(value.Value)).
SetColor(params[0].Color).
SetType(params[0].Type).
GetContent()
}
return ""
}
}