render serie via a separate block

This commit is contained in:
Florian Klink 2019-11-27 11:38:54 +01:00
parent 1b249600e5
commit 151cc75532
3 changed files with 17 additions and 10 deletions

View file

@ -68,7 +68,11 @@ func MakeFrontend(runner *submitqueue.Runner) http.Handler {
}, },
} }
tmpl := template.Must(loadTemplate([]string{"submit-queue.tmpl.html", "changeset.tmpl.html"}, funcMap)) tmpl := template.Must(loadTemplate([]string{
"submit-queue.tmpl.html",
"serie.tmpl.html",
"changeset.tmpl.html",
}, funcMap))
tmpl.ExecuteTemplate(c.Writer, "submit-queue.tmpl.html", gin.H{ tmpl.ExecuteTemplate(c.Writer, "submit-queue.tmpl.html", gin.H{
"series": submitQueue.Series, "series": submitQueue.Series,

11
public/serie.tmpl.html Normal file
View file

@ -0,0 +1,11 @@
{{ define "serie" }}
<tr>
<td colspan="3" class="{{ if not (. | isAutoSubmittable) }}table-primary{{ else }}table-success{{ end }}">Serie with {{ len .ChangeSets }} changes</td>
</tr>
{{ range $changeset := .ChangeSets }}
{{ block "changeset" $changeset }}{{ end }}
{{ end }}
<tr>
<td colspan="3">&nbsp;</td>
</tr>
{{ end }}

View file

@ -67,15 +67,7 @@
</thead> </thead>
<tbody> <tbody>
{{ range $serie := .series }} {{ range $serie := .series }}
<tr> {{ block "serie" $serie }}{{ end }}
<td colspan="3" class="{{ if not ($serie | isAutoSubmittable) }}table-primary{{ else }}table-success{{ end }}">Serie with {{ len $serie.ChangeSets }} changes</td>
</tr>
{{ range $changeset := $serie.ChangeSets }}
{{ block "changeset" $changeset }}{{ end }}
{{ end }}
<tr>
<td colspan="3">&nbsp;</td>
</tr>
{{ end }} {{ end }}
</tbody> </tbody>
</table> </table>