Browse Source

Posts data table

Vova Tkach 6 years ago
parent
commit
c24bfe1187
4 changed files with 83 additions and 1 deletions
  1. 14 0
      assets/cp.styles.css
  2. 0 0
      assets/cp.styles.css.go
  3. 1 1
      consts/consts.go
  4. 68 0
      modules/module_blog.go

+ 14 - 0
assets/cp.styles.css

@@ -298,6 +298,20 @@ ul.pagination {
 	text-align: right;
 	text-align: right;
 }
 }
 
 
+/* Admin table: blog_posts */
+.data-table.table_blog_posts .col_datetime {
+	width: 8rem;
+}
+
+.data-table.table_blog_posts .col_active {
+	width: 5rem;
+}
+
+.data-table.table_blog_posts .col_action {
+	width: 6rem;
+	text-align: right;
+}
+
 /* Admin table: table_blog_cats */
 /* Admin table: table_blog_cats */
 .data-table.table_blog_cats .col_action {
 .data-table.table_blog_cats .col_action {
 	width: 6rem;
 	width: 6rem;

File diff suppressed because it is too large
+ 0 - 0
assets/cp.styles.css.go


+ 1 - 1
consts/consts.go

@@ -5,7 +5,7 @@ import (
 )
 )
 
 
 const ServerVersion = "1.0.2"
 const ServerVersion = "1.0.2"
-const AssetsVersion = "16"
+const AssetsVersion = "17"
 const AssetsPath = "assets"
 const AssetsPath = "assets"
 const DirIndexFile = "index.html"
 const DirIndexFile = "index.html"
 
 

+ 68 - 0
modules/module_blog.go

@@ -38,6 +38,74 @@ func (this *Modules) RegisterModule_Blog() *Module {
 			content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
 			content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
 				{Name: "List of posts"},
 				{Name: "List of posts"},
 			})
 			})
+			content += builder.DataTable(
+				wrap,
+				"blog_posts",
+				"id",
+				"DESC",
+				&[]builder.DataTableRow{
+					{
+						DBField: "id",
+					},
+					{
+						DBField:     "name",
+						NameInTable: "Post / Alias",
+						CallBack: func(values *[]string) string {
+							name := `<a href="/cp/` + wrap.CurrModule + `/modify/` + (*values)[0] + `/">` + html.EscapeString((*values)[1]) + `</a>`
+							alias := html.EscapeString((*values)[2])
+							return `<div>` + name + `</div><div><small>` + alias + `</small></div>`
+						},
+					},
+					{
+						DBField: "alias",
+					},
+					{
+						DBField:     "datetime",
+						DBExp:       "UNIX_TIMESTAMP(`datetime`)",
+						NameInTable: "Date / Time",
+						Classes:     "d-none d-md-table-cell",
+						CallBack: func(values *[]string) string {
+							t := int64(utils.StrToInt((*values)[3]))
+							return `<div>` + utils.UnixTimestampToFormat(t, "02.01.2006") + `</div>` +
+								`<div><small>` + utils.UnixTimestampToFormat(t, "15:04:05") + `</small></div>`
+						},
+					},
+					{
+						DBField:     "active",
+						NameInTable: "Active",
+						Classes:     "d-none d-sm-table-cell",
+						CallBack: func(values *[]string) string {
+							return builder.CheckBox(utils.StrToInt((*values)[4]))
+						},
+					},
+				},
+				func(values *[]string) string {
+					return builder.DataTableAction(&[]builder.DataTableActionRow{
+						{
+							Icon:   assets.SysSvgIconView,
+							Href:   (*values)[2],
+							Hint:   "View",
+							Target: "_blank",
+						},
+						{
+							Icon: assets.SysSvgIconEdit,
+							Href: "/cp/" + wrap.CurrModule + "/modify/" + (*values)[0] + "/",
+							Hint: "Edit",
+						},
+						{
+							Icon: assets.SysSvgIconRemove,
+							Href: "javascript:fave.ActionDataTableDelete(this,'blog-delete','" +
+								(*values)[0] + "','Are you sure want to delete post?');",
+							Hint:    "Delete",
+							Classes: "delete",
+						},
+					})
+				},
+				"/cp/"+wrap.CurrModule+"/",
+				nil,
+				nil,
+				true,
+			)
 		} else if wrap.CurrSubModule == "categories" {
 		} else if wrap.CurrSubModule == "categories" {
 			content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
 			content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
 				{Name: "Categories", Link: "/cp/" + wrap.CurrModule + "/" + wrap.CurrSubModule + "/"},
 				{Name: "Categories", Link: "/cp/" + wrap.CurrModule + "/" + wrap.CurrSubModule + "/"},

Some files were not shown because too many files changed in this diff