Input required, table (class, href, badge)
This commit is contained in:
parent
f398ebb02d
commit
458ad520ca
6 changed files with 31 additions and 11 deletions
|
@ -2,16 +2,19 @@ package components
|
||||||
|
|
||||||
type ContentTable struct {
|
type ContentTable struct {
|
||||||
ID string
|
ID string
|
||||||
|
TableClass string // table-primary, table-secondary,.. table-striped table-bordered
|
||||||
|
HeadClass string // table-dark table-light
|
||||||
AllTH []ContentTableTH
|
AllTH []ContentTableTH
|
||||||
AllTD [][]ContentTableTD
|
AllTD [][]ContentTableTD
|
||||||
}
|
}
|
||||||
|
|
||||||
type ContentTableTH struct {
|
type ContentTableTH struct {
|
||||||
ID string
|
ID string
|
||||||
|
ValueType string // -> default string, href, badge
|
||||||
Value string
|
Value string
|
||||||
}
|
}
|
||||||
|
|
||||||
type ContentTableTD struct {
|
type ContentTableTD struct {
|
||||||
ID string
|
ID string
|
||||||
Value string
|
Value interface{} // string or component struct according ValueType
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,25 @@
|
||||||
{{define "content_table"}}
|
{{define "content_table"}}
|
||||||
<table class="table table-hover" {{ if .ID }}id="{{.ID}}"{{end}}>
|
<table class="table table-hover {{.TableClass}}" {{ if .ID }}id="{{.ID}}"{{end}}>
|
||||||
<thead>
|
<thead class="{{.HeadClass}}">
|
||||||
<tr>
|
<tr>
|
||||||
{{range $index, $col := .AllTH}}<th {{ if .ID }}id="{{.ID}}"{{end}} scope="col">{{ $col.Value }}</th>{{end}}
|
{{range $index, $col := .AllTH}}<th {{ if .ID }}id="{{.ID}}"{{end}} scope="col">{{ $col.Value }}</th>{{end}}
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{range .AllTD}}<tr scope="row">{{range .}}<td {{ if .ID }}id="{{.ID}}"{{end}}>{{ .Value }}</td>{{end}}</tr>{{end}}
|
{{range .AllTD}}<tr scope="row">
|
||||||
|
{{range $index, $item := .}}<td {{ if $item.ID }}id="{{$item.ID}}"{{end}}>
|
||||||
|
{{ 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}}
|
||||||
|
</td>
|
||||||
|
{{end}}</tr>
|
||||||
|
{{end}}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{{end}}
|
{{end}}
|
|
@ -9,4 +9,5 @@ type FormInput struct {
|
||||||
Hint string
|
Hint string
|
||||||
Error string
|
Error string
|
||||||
IsDisabled bool
|
IsDisabled bool
|
||||||
|
IsRequired bool
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
{{if eq .IsDisabled true}}
|
{{if eq .IsDisabled true}}
|
||||||
disabled
|
disabled
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{if eq .IsRequired true}}
|
||||||
|
required
|
||||||
|
{{end}}
|
||||||
{{if ne .Value ""}}
|
{{if ne .Value ""}}
|
||||||
value="{{.Value}}"
|
value="{{.Value}}"
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package components
|
package components
|
||||||
|
|
||||||
type PageNav struct {
|
type PageNav struct {
|
||||||
NavClass string // nav-pills
|
NavClass string // nav-pills, nav-underline
|
||||||
NavItems []PageNavItem
|
NavItems []PageNavItem
|
||||||
IsVertical bool
|
IsVertical bool
|
||||||
IsTab bool
|
IsTab bool
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
class="nav-link dropdown-toggle {{if eq .IsActive true}}active{{end}} {{if eq .IsDisabled true}}disabled{{end}}">{{$item.Text}}</a>
|
class="nav-link dropdown-toggle {{if eq .IsActive true}}active{{end}} {{if eq .IsDisabled true}}disabled{{end}}">{{$item.Text}}</a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
{{ range $item.ChildItems}}
|
{{ range $item.ChildItems}}
|
||||||
{{template "form_dropdown_item" .}}
|
{{template "content_dropdown_item" .}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
Loading…
Reference in a new issue