-
Notifications
You must be signed in to change notification settings - Fork 0
/
posts.go
46 lines (38 loc) · 1.72 KB
/
posts.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
package tables
import (
"github.com/GoAdminGroup/go-admin/context"
"github.com/GoAdminGroup/go-admin/modules/db"
"github.com/GoAdminGroup/go-admin/plugins/admin/modules/table"
"github.com/GoAdminGroup/go-admin/template"
"github.com/GoAdminGroup/go-admin/template/types"
"github.com/GoAdminGroup/go-admin/template/types/form"
editType "github.com/GoAdminGroup/go-admin/template/types/table"
)
// GetPostsTable return the model of table posts.
func GetPostsTable(ctx *context.Context) (postsTable table.Table) {
postsTable = table.NewDefaultTable(table.DefaultConfig())
info := postsTable.GetInfo()
info.AddField("ID", "id", db.Int).FieldSortable()
info.AddField("Title", "title", db.Varchar)
info.AddField("AuthorID", "author_id", db.Varchar).FieldDisplay(func(value types.FieldModel) interface{} {
return template.Default().
Link().
SetURL("/admin/info/authors/detail?__goadmin_detail_pk=100").
SetContent("100").
OpenInNewTab().
SetTabTitle("Author Detail").
GetContent()
})
info.AddField("Description", "description", db.Varchar)
info.AddField("Content", "content", db.Varchar).FieldEditAble(editType.Textarea)
info.AddField("Date", "date", db.Varchar)
info.SetTable("posts").SetTitle("Posts").SetDescription("Posts")
formList := postsTable.GetForm()
formList.AddField("ID", "id", db.Int, form.Default).FieldNotAllowEdit().FieldNotAllowAdd()
formList.AddField("Title", "title", db.Varchar, form.Text)
formList.AddField("Description", "description", db.Varchar, form.Text)
formList.AddField("Content", "content", db.Varchar, form.RichText).FieldEnableFileUpload()
formList.AddField("Date", "date", db.Varchar, form.Datetime)
formList.SetTable("posts").SetTitle("Posts").SetDescription("Posts")
return
}