forked from tangled.org/core
this repo has no description

appview/pages: show labels in all issues view

Signed-off-by: oppiliappan <me@oppi.li>

oppi.li b9abc383 8d03574f

verified
Changed files
+44 -3
appview
issues
pages
templates
labels
repo
issues
+13
appview/issues/issues.go
···
return
}
+
labelDefs, err := db.GetLabelDefinitions(rp.db, db.FilterIn("at_uri", f.Repo.Labels))
+
if err != nil {
+
log.Println("failed to fetch labels", err)
+
rp.pages.Error503(w)
+
return
+
}
+
+
defs := make(map[string]*db.LabelDefinition)
+
for _, l := range labelDefs {
+
defs[l.AtUri().String()] = &l
+
}
+
rp.pages.RepoIssues(w, pages.RepoIssuesParams{
LoggedInUser: rp.oauth.GetUser(r),
RepoInfo: f.RepoInfo(user),
Issues: issues,
+
LabelDefs: defs,
FilteringByOpen: isOpen,
Page: page,
})
+3
appview/pages/funcmap.go
···
"split": func(s string) []string {
return strings.Split(s, "\n")
},
+
"join": func(elems []string, sep string) string {
+
return strings.Join(elems, sep)
+
},
"contains": func(s string, target string) bool {
return strings.Contains(s, target)
},
+1
appview/pages/pages.go
···
RepoInfo repoinfo.RepoInfo
Active string
Issues []db.Issue
+
LabelDefs map[string]*db.LabelDefinition
Page pagination.Page
FilteringByOpen bool
}
+8
appview/pages/templates/labels/fragments/label.html
···
+
{{ define "labels/fragments/label" }}
+
{{ $d := .def }}
+
{{ $v := .val }}
+
<span class="flex items-center gap-2 font-normal normal-case rounded py-1 px-2 border border-gray-200 dark:border-gray-700 text-sm">
+
{{ template "repo/fragments/colorBall" (dict "color" $d.GetColor) }}
+
{{ $d.Name }}{{ if not $d.ValueType.IsNull }}/{{ $v }}{{ end }}
+
</span>
+
{{ end }}
+6
appview/pages/templates/labels/fragments/labelDef.html
···
+
{{ define "labels/fragments/labelDef" }}
+
<span class="flex items-center gap-2 font-normal normal-case">
+
{{ template "repo/fragments/colorBall" (dict "color" .GetColor) }}
+
{{ .Name }}
+
</span>
+
{{ end }}
+13 -3
appview/pages/templates/repo/issues/issues.html
···
<span class="text-gray-500">#{{ .IssueId }}</span>
</a>
</div>
-
<p class="text-sm text-gray-500 dark:text-gray-400 flex flex-wrap items-center gap-1">
+
<div class="text-sm text-gray-500 dark:text-gray-400 flex flex-wrap items-center gap-1">
{{ $bgColor := "bg-gray-800 dark:bg-gray-700" }}
{{ $icon := "ban" }}
{{ $state := "closed" }}
···
<span class="before:content-['·']">
{{ $s := "s" }}
{{ if eq (len .Comments) 1 }}
-
{{ $s = "" }}
+
{{ $s = "" }}
{{ end }}
<a href="/{{ $.RepoInfo.FullName }}/issues/{{ .IssueId }}" class="text-gray-500 dark:text-gray-400">{{ len .Comments }} comment{{$s}}</a>
</span>
-
</p>
+
+
{{ if .Labels.Inner }}
+
<span class="before:content-['·']"></span>
+
{{ range $k, $valset := .Labels.Inner }}
+
{{ $d := index $.LabelDefs $k }}
+
{{ range $v, $s := $valset }}
+
{{ template "labels/fragments/label" (dict "def" $d "val" $v) }}
+
{{ end }}
+
{{ end }}
+
{{ end }}
+
</div>
</div>
{{ end }}
</div>