From 3d4d89f060f01b7993ef8e1839744c81b53293bf Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 14 May 2015 18:30:23 +0300 Subject: [PATCH 1/3] Use count badges with number_with_delimiter helper for issue, commit count --- app/helpers/application_helper.rb | 17 +++++++++++++---- app/views/projects/commits/_head.html.haml | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 672be54e66..26bb3c66fd 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -324,12 +324,21 @@ module ApplicationHelper count = if project.nil? - "" + nil elsif current_controller?(:issues) - " (#{project.issues.send(entity).count})" + project.issues.send(entity).count elsif current_controller?(:merge_requests) - " (#{project.merge_requests.send(entity).count})" + project.merge_requests.send(entity).count end - "#{entity_title}#{count}" + + html = "" + html += content_tag :span, entity_title + html += " " + + if count.present? + html += content_tag :span, number_with_delimiter(count), class: 'badge' + end + + html.html_safe end end diff --git a/app/views/projects/commits/_head.html.haml b/app/views/projects/commits/_head.html.haml index 66261c7336..e3d8cd0fdd 100644 --- a/app/views/projects/commits/_head.html.haml +++ b/app/views/projects/commits/_head.html.haml @@ -3,7 +3,7 @@ = link_to namespace_project_commits_path(@project.namespace, @project, @ref || @repository.root_ref) do = icon("history") Commits - %span.badge= number_with_precision(@repository.commit_count, precision: 0, delimiter: ',') + %span.badge= number_with_delimiter(@repository.commit_count) = nav_link(controller: :compare) do = link_to namespace_project_compare_index_path(@project.namespace, @project, from: @repository.root_ref, to: @ref || @repository.root_ref) do = icon("exchange") From 40f381e6527f6eac3f4ccbbd7cfde690f2b40be8 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 14 May 2015 18:32:07 +0300 Subject: [PATCH 2/3] append empty space only if count exists --- app/helpers/application_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 26bb3c66fd..3d4588a3b5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -333,9 +333,9 @@ module ApplicationHelper html = "" html += content_tag :span, entity_title - html += " " if count.present? + html += " " html += content_tag :span, number_with_delimiter(count), class: 'badge' end From ded82ed4c9fde4e439a0da01138c6a3d9c1c991e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 14 May 2015 18:34:06 +0300 Subject: [PATCH 3/3] Small refactoring of state_filters_text_for helper --- app/helpers/application_helper.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3d4588a3b5..ea9722b9be 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -331,11 +331,10 @@ module ApplicationHelper project.merge_requests.send(entity).count end - html = "" - html += content_tag :span, entity_title + html = content_tag :span, entity_title if count.present? - html += " " + html += " " html += content_tag :span, number_with_delimiter(count), class: 'badge' end