detail table
This commit is contained in:
parent
cf8b3bdde7
commit
59ea47dcd6
2 changed files with 45 additions and 0 deletions
16
template/components/content_tabledetail.go
Normal file
16
template/components/content_tabledetail.go
Normal file
|
@ -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
|
||||||
|
}
|
29
template/components/content_tabledetail.html
Normal file
29
template/components/content_tabledetail.html
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
{{define "content_tabledetail"}}
|
||||||
|
<table class="table table-hover" {{ if .ID }}id="{{.ID}}"{{end}}>
|
||||||
|
{{$stylecell := "table-success"}}
|
||||||
|
{{if .HeadClass }}{{$stylecell = .HeadClass}}{{end}}
|
||||||
|
{{if .Title }}
|
||||||
|
<thead class="{{.HeadClass}}">
|
||||||
|
<tr>
|
||||||
|
<th colspan="2" class="{{$stylecell}}">{{ .Title }}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
{{end}}
|
||||||
|
<tbody>
|
||||||
|
{{range $item := .AllTD}}
|
||||||
|
<tr scope="row" {{ if $item.ID }}id="{{$item.ID}}"{{end}}>
|
||||||
|
<td class="{{$stylecell}}">{{ $item.Caption }}</td>
|
||||||
|
<td>
|
||||||
|
{{ 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}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{end}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{{end}}
|
Loading…
Reference in a new issue