From c6b242112781120233a3627098e50689f6ccf9f8 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 9 Mar 2015 15:20:32 -0700 Subject: [PATCH] Render milestone progress with one helper method --- app/helpers/milestones_helper.rb | 11 +++++++++++ app/views/dashboard/milestones/index.html.haml | 3 +-- app/views/dashboard/milestones/show.html.haml | 3 +-- app/views/groups/milestones/index.html.haml | 3 +-- app/views/groups/milestones/show.html.haml | 3 +-- app/views/projects/milestones/_milestone.html.haml | 3 +-- app/views/projects/milestones/show.html.haml | 3 +-- 7 files changed, 17 insertions(+), 12 deletions(-) diff --git a/app/helpers/milestones_helper.rb b/app/helpers/milestones_helper.rb index 3383b1ae5be..59fdc0d49cc 100644 --- a/app/helpers/milestones_helper.rb +++ b/app/helpers/milestones_helper.rb @@ -8,4 +8,15 @@ module MilestonesHelper dashboard_milestones_path(opts) end end + + def milestone_progress_bar(milestone) + options = { + class: 'progress-bar progress-bar-success', + style: "width: #{milestone.percent_complete}%;" + } + + content_tag :div, class: 'progress' do + content_tag :div, nil, options + end + end end diff --git a/app/views/dashboard/milestones/index.html.haml b/app/views/dashboard/milestones/index.html.haml index 65fc5898518..caf3b685864 100644 --- a/app/views/dashboard/milestones/index.html.haml +++ b/app/views/dashboard/milestones/index.html.haml @@ -28,8 +28,7 @@ = pluralize milestone.merge_requests_count, 'Merge Request'   %span.light #{milestone.percent_complete}% complete - .progress.progress-info - .progress-bar{style: "width: #{milestone.percent_complete}%;"} + = milestone_progress_bar(milestone) %div %br - milestone.milestones.each do |milestone| diff --git a/app/views/dashboard/milestones/show.html.haml b/app/views/dashboard/milestones/show.html.haml index a45a52001be..57cce9ab749 100644 --- a/app/views/dashboard/milestones/show.html.haml +++ b/app/views/dashboard/milestones/show.html.haml @@ -39,8 +39,7 @@ #{@dashboard_milestone.closed_items_count} closed – #{@dashboard_milestone.open_items_count} open - .progress.progress-info - .progress-bar{style: "width: #{@dashboard_milestone.percent_complete}%;"} + = milestone_progress_bar(@dashboard_milestone) %ul.nav.nav-tabs %li.active diff --git a/app/views/groups/milestones/index.html.haml b/app/views/groups/milestones/index.html.haml index fcbcb309aa7..9febaab04a7 100644 --- a/app/views/groups/milestones/index.html.haml +++ b/app/views/groups/milestones/index.html.haml @@ -36,8 +36,7 @@ = pluralize milestone.merge_requests_count, 'Merge Request'   %span.light #{milestone.percent_complete}% complete - .progress.progress-info - .progress-bar{style: "width: #{milestone.percent_complete}%;"} + = milestone_progress_bar(milestone) %div %br - milestone.milestones.each do |milestone| diff --git a/app/views/groups/milestones/show.html.haml b/app/views/groups/milestones/show.html.haml index e3606d167ad..dd2d84499ba 100644 --- a/app/views/groups/milestones/show.html.haml +++ b/app/views/groups/milestones/show.html.haml @@ -45,8 +45,7 @@ #{@group_milestone.closed_items_count} closed – #{@group_milestone.open_items_count} open - .progress.progress-info - .progress-bar{style: "width: #{@group_milestone.percent_complete}%;"} + = milestone_progress_bar(@group_milestone) %ul.nav.nav-tabs %li.active diff --git a/app/views/projects/milestones/_milestone.html.haml b/app/views/projects/milestones/_milestone.html.haml index d32b2ba271f..dcf56541db8 100644 --- a/app/views/projects/milestones/_milestone.html.haml +++ b/app/views/projects/milestones/_milestone.html.haml @@ -23,5 +23,4 @@ = pluralize milestone.merge_requests.count, 'Merge Request'   %span.light #{milestone.percent_complete}% complete - .progress.progress-info - .progress-bar{style: "width: #{milestone.percent_complete}%;"} + = milestone_progress_bar(milestone) diff --git a/app/views/projects/milestones/show.html.haml b/app/views/projects/milestones/show.html.haml index fea96f37011..110d8967342 100644 --- a/app/views/projects/milestones/show.html.haml +++ b/app/views/projects/milestones/show.html.haml @@ -43,8 +43,7 @@   %span.light #{@milestone.percent_complete}% complete %span.pull-right= @milestone.expires_at - .progress.progress-info - .progress-bar{style: "width: #{@milestone.percent_complete}%;"} + = milestone_progress_bar(@milestone) %ul.nav.nav-tabs