summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG1
-rw-r--r--app/assets/stylesheets/pages/milestone.scss2
-rw-r--r--app/helpers/milestones_helper.rb10
-rw-r--r--app/models/milestone.rb13
-rw-r--r--app/views/projects/milestones/show.html.haml4
5 files changed, 16 insertions, 14 deletions
diff --git a/CHANGELOG b/CHANGELOG
index f635b49c5b4..d0842708803 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,7 @@ v 8.5.2
- Don't repeat labels listed on Labels tab
- Bring the "branded appearance" feature from EE to CE
- Fix error 500 when commenting on a commit
+ - Show days remaining instead of elapsed time for Milestone
- Fix broken icons on installations with relative URL (Artem Sidorenko)
- Fix import from gitlab.com (KazSawada)
- Improve implementation to check read access to forks and add pagination
diff --git a/app/assets/stylesheets/pages/milestone.scss b/app/assets/stylesheets/pages/milestone.scss
index 9144a83647d..d24adbf67e6 100644
--- a/app/assets/stylesheets/pages/milestone.scss
+++ b/app/assets/stylesheets/pages/milestone.scss
@@ -39,7 +39,7 @@ li.milestone {
margin-right: 10px;
}
- .time-elapsed {
+ .remaining-days {
color: $orange-light;
}
}
diff --git a/app/helpers/milestones_helper.rb b/app/helpers/milestones_helper.rb
index a42cbcff182..7de81d8dfdb 100644
--- a/app/helpers/milestones_helper.rb
+++ b/app/helpers/milestones_helper.rb
@@ -36,4 +36,14 @@ module MilestonesHelper
options_from_collection_for_select(grouped_milestones, 'name', 'title', params[:milestone_title])
end
+
+ def milestone_remaining_days(milestone)
+ if milestone.expired?
+ content_tag(:strong, 'expired')
+ elsif milestone.due_date
+ days = milestone.remaining_days
+ content = content_tag(:strong, days)
+ content << " #{'day'.pluralize(days)} remaining"
+ end
+ end
end
diff --git a/app/models/milestone.rb b/app/models/milestone.rb
index 8f99e3bef9b..7dc2f909b2f 100644
--- a/app/models/milestone.rb
+++ b/app/models/milestone.rb
@@ -110,17 +110,10 @@ class Milestone < ActiveRecord::Base
0
end
- # Returns the elapsed time (in percent) since the Milestone creation date until today.
- # If the Milestone doesn't have a due_date then returns 0 since we can't calculate the elapsed time.
- # If the Milestone is overdue then it returns 100%.
- def percent_time_used
- return 0 unless due_date
- return 100 if expired?
+ def remaining_days
+ return 0 if !due_date || expired?
- duration = ((created_at - due_date.to_datetime) / 1.day)
- days_elapsed = ((created_at - Time.now) / 1.day)
-
- ((days_elapsed.to_f / duration) * 100).floor
+ (due_date - Date.today).to_i
end
def expires_at
diff --git a/app/views/projects/milestones/show.html.haml b/app/views/projects/milestones/show.html.haml
index 631bc8c3e9d..2cae1ac4e2c 100644
--- a/app/views/projects/milestones/show.html.haml
+++ b/app/views/projects/milestones/show.html.haml
@@ -60,9 +60,7 @@
%strong== #{@milestone.percent_complete}%
complete
%span.milestone-stat
- %span.time-elapsed
- %strong== #{@milestone.percent_time_used}%
- time elapsed
+ %span.remaining-days= milestone_remaining_days(@milestone)
%span.pull-right.tab-issues-buttons
- if can?(current_user, :create_issue, @project)
= link_to new_namespace_project_issue_path(@project.namespace, @project, issue: { milestone_id: @milestone.id }), class: "btn btn-grouped", title: "New Issue" do