diff --git a/template/components/content_table.go b/template/components/content_table.go index 66c7e1f..1cb7024 100644 --- a/template/components/content_table.go +++ b/template/components/content_table.go @@ -1,17 +1,20 @@ package components type ContentTable struct { - ID string - AllTH []ContentTableTH - AllTD [][]ContentTableTD + ID string + TableClass string // table-primary, table-secondary,.. table-striped table-bordered + HeadClass string // table-dark table-light + AllTH []ContentTableTH + AllTD [][]ContentTableTD } type ContentTableTH struct { - ID string - Value string + ID string + ValueType string // -> default string, href, badge + Value string } type ContentTableTD struct { ID string - Value string + Value interface{} // string or component struct according ValueType } diff --git a/template/components/content_table.html b/template/components/content_table.html index 68e34f6..ce19344 100644 --- a/template/components/content_table.html +++ b/template/components/content_table.html @@ -1,12 +1,25 @@ {{define "content_table"}} - - +
+ {{range $index, $col := .AllTH}}{{end}} -{{range .AllTD}}{{range .}}{{end}}{{end}} + {{range .AllTD}} + {{range $index, $item := .}} + {{end}} + {{end}}
{{ $col.Value }}
{{ .Value }}
+ {{ with $x := index $.AllTH $index }} + {{ if eq $x.ValueType "href"}} + {{template "content_href" $item.Value}} + {{ else if eq $x.ValueType "badge"}} + {{template "content_badge" $item.Value}} + {{ else }} + {{ $item.Value }} + {{end}} + {{end}} +
{{end}} \ No newline at end of file diff --git a/template/components/form_input.go b/template/components/form_input.go index 0ce7ce4..e27910f 100644 --- a/template/components/form_input.go +++ b/template/components/form_input.go @@ -9,4 +9,5 @@ type FormInput struct { Hint string Error string IsDisabled bool + IsRequired bool } diff --git a/template/components/form_input.html b/template/components/form_input.html index b79ae87..8159896 100644 --- a/template/components/form_input.html +++ b/template/components/form_input.html @@ -5,6 +5,9 @@ {{if eq .IsDisabled true}} disabled {{end}} + {{if eq .IsRequired true}} + required + {{end}} {{if ne .Value ""}} value="{{.Value}}" {{end}} diff --git a/template/components/page_nav.go b/template/components/page_nav.go index 2ed9319..862d1c8 100644 --- a/template/components/page_nav.go +++ b/template/components/page_nav.go @@ -1,7 +1,7 @@ package components type PageNav struct { - NavClass string // nav-pills + NavClass string // nav-pills, nav-underline NavItems []PageNavItem IsVertical bool IsTab bool diff --git a/template/components/page_nav.html b/template/components/page_nav.html index 5bb0b83..08faaf4 100644 --- a/template/components/page_nav.html +++ b/template/components/page_nav.html @@ -8,7 +8,7 @@ class="nav-link dropdown-toggle {{if eq .IsActive true}}active{{end}} {{if eq .IsDisabled true}}disabled{{end}}">{{$item.Text}}