From 52b787e89185871f758d097f42f592c6d286cbcd Mon Sep 17 00:00:00 2001 From: Suwon Chae Date: Thu, 16 Mar 2017 22:59:42 +0900 Subject: [PATCH] navbar: Show the number of user open issues See: Yona Github issue #178 --- app/assets/stylesheets/less/_page.less | 10 ++++++++++ app/models/Issue.java | 7 +++++++ app/views/common/usermenu.scala.html | 9 ++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/less/_page.less b/app/assets/stylesheets/less/_page.less index 4c785f7a1..8534bb718 100644 --- a/app/assets/stylesheets/less/_page.less +++ b/app/assets/stylesheets/less/_page.less @@ -547,6 +547,16 @@ .border-radius(9px); } +.counter-badge { + display: inline-block; + font-size: 12px; + padding: 0 3px; + text-align: center; + font-family: @fixed-font-family; + .border-radius(3px); + vertical-align: middle; +} + .project-new-posting { font-size: 12px; line-height: 14px; diff --git a/app/models/Issue.java b/app/models/Issue.java index c4861b122..c54ebab1a 100644 --- a/app/models/Issue.java +++ b/app/models/Issue.java @@ -658,4 +658,11 @@ public static int countByParentIssueIdAndState(Long parentIssueId, State state){ .eq("state", state) .findRowCount(); } + + public static int countOpenIssuesByUser(User user) { + return finder.where() + .eq("assignee.user.id", user.id) + .eq("state", State.OPEN) + .findRowCount(); + } } diff --git a/app/views/common/usermenu.scala.html b/app/views/common/usermenu.scala.html index dc2f71833..912f2e212 100644 --- a/app/views/common/usermenu.scala.html +++ b/app/views/common/usermenu.scala.html @@ -25,6 +25,13 @@ } } +@myOpenIssueCount = @{ + val count = Issue.countOpenIssuesByUser(UserApp.currentUser()) + if(count > 0) { + Html("(" + count + ")") + } +} +
@@ -64,7 +71,7 @@
  • - @Messages("issue.myIssue") + @Messages("issue.myIssue")@myOpenIssueCount
  • @if(UserApp.currentUser.isSiteManager) {