From 59ea47dcd686809234a3e73d931a1ebc62e27f18 Mon Sep 17 00:00:00 2001 From: Zeni Kim Date: Sun, 27 Oct 2024 12:54:34 -0500 Subject: [PATCH] detail table --- template/components/content_tabledetail.go | 16 +++++++++++ template/components/content_tabledetail.html | 29 ++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 template/components/content_tabledetail.go create mode 100644 template/components/content_tabledetail.html diff --git a/template/components/content_tabledetail.go b/template/components/content_tabledetail.go new file mode 100644 index 0000000..61848b8 --- /dev/null +++ b/template/components/content_tabledetail.go @@ -0,0 +1,16 @@ +package components + +type ContentTabledetail struct { + ID string + TableClass string // table-primary, table-secondary,.. table-striped table-bordered + HeadClass string // table-dark table-light + Title string + AllTD []ContentTabledetailTD +} + +type ContentTabledetailTD struct { + ID string + Caption string + ValueType string // -> default string, href, badge + Value interface{} // string or component struct according ValueType +} diff --git a/template/components/content_tabledetail.html b/template/components/content_tabledetail.html new file mode 100644 index 0000000..636191c --- /dev/null +++ b/template/components/content_tabledetail.html @@ -0,0 +1,29 @@ +{{define "content_tabledetail"}} + + {{$stylecell := "table-success"}} + {{if .HeadClass }}{{$stylecell = .HeadClass}}{{end}} + {{if .Title }} + + + + + + {{end}} + + {{range $item := .AllTD}} + + + + + {{end}} + +
{{ .Title }}
{{ $item.Caption }} + {{ if eq $item.ValueType "href"}} + {{template "content_href" $item.Value}} + {{ else if eq $item.ValueType "badge"}} + {{template "content_badge" $item.Value}} + {{ else }} + {{ $item.Value }} + {{end}} +
+{{end}}