From 4776fde9e1caa7cee5671715144a668e19a0323c Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Thu, 2 Nov 2023 11:42:02 +0100 Subject: [PATCH] Display issue task list on project cards (#27865) Display the issue task list on project cards. ![grafik](https://github.com/go-gitea/gitea/assets/1666336/e6cb3196-8980-403c-9795-3a7b03fbfb3c) Co-authored-by: Giteabot --- models/issues/issue.go | 12 ++---------- templates/repo/issue/card.tmpl | 7 +++++++ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/models/issues/issue.go b/models/issues/issue.go index 8655b9de3..b0ff0addd 100644 --- a/models/issues/issue.go +++ b/models/issues/issue.go @@ -142,22 +142,14 @@ type Issue struct { } var ( - issueTasksPat *regexp.Regexp - issueTasksDonePat *regexp.Regexp -) - -const ( - issueTasksRegexpStr = `(^\s*[-*]\s\[[\sxX]\]\s.)|(\n\s*[-*]\s\[[\sxX]\]\s.)` - issueTasksDoneRegexpStr = `(^\s*[-*]\s\[[xX]\]\s.)|(\n\s*[-*]\s\[[xX]\]\s.)` + issueTasksPat = regexp.MustCompile(`(^\s*[-*]\s\[[\sxX]\]\s.)|(\n\s*[-*]\s\[[\sxX]\]\s.)`) + issueTasksDonePat = regexp.MustCompile(`(^\s*[-*]\s\[[xX]\]\s.)|(\n\s*[-*]\s\[[xX]\]\s.)`) ) // IssueIndex represents the issue index table type IssueIndex db.ResourceIndex func init() { - issueTasksPat = regexp.MustCompile(issueTasksRegexpStr) - issueTasksDonePat = regexp.MustCompile(issueTasksDoneRegexpStr) - db.RegisterModel(new(Issue)) db.RegisterModel(new(IssueIndex)) } diff --git a/templates/repo/issue/card.tmpl b/templates/repo/issue/card.tmpl index 05b7dbaab..3cc853b35 100644 --- a/templates/repo/issue/card.tmpl +++ b/templates/repo/issue/card.tmpl @@ -49,6 +49,13 @@ {{end}} {{end}} + {{$tasks := .GetTasks}} + {{if gt $tasks 0}} +
+ {{svg "octicon-checklist" 16 "gt-mr-2 gt-vm"}} + {{.GetTasksDone}} / {{$tasks}} +
+ {{end}} {{if or .Labels .Assignees}}