Commit d4e070cf authored by randx's avatar randx

Improve styles. Add merge request completness to milestone percentage

parent ecdf778e
...@@ -670,3 +670,8 @@ pre { ...@@ -670,3 +670,8 @@ pre {
padding:0; padding:0;
} }
} }
.milestone .progress {
margin-bottom: 0;
margin-top:4px;
}
# Build collection of Merge Requests
# based on filtering passed via params for @project
class MergeRequestsLoadContext < BaseContext class MergeRequestsLoadContext < BaseContext
def execute def execute
type = params[:f] type = params[:f]
merge_requests = @project.merge_requests merge_requests = project.merge_requests
merge_requests = case type merge_requests = case type
when 'all' then merge_requests when 'all' then merge_requests
when 'closed' then merge_requests.closed when 'closed' then merge_requests.closed
when 'assigned-to-me' then merge_requests.opened.assigned(current_user) when 'assigned-to-me' then merge_requests.opened.assigned(current_user)
else merge_requests.opened else merge_requests.opened
end.page(params[:page]).per(20) end
merge_requests.includes(:author, :project).order("closed, created_at desc")
@merge_requests = merge_requests merge_requests = merge_requests.page(params[:page]).per(20)
merge_requests = merge_requests.includes(:author, :project).order("closed, created_at desc")
# Filter by specific assignee_id (or lack thereof)? # Filter by specific assignee_id (or lack thereof)?
if params[:assignee_id].present? if params[:assignee_id].present?
@merge_requests = merge_requests.where(assignee_id: (params[:assignee_id] == '0' ? nil : params[:assignee_id])) merge_requests = merge_requests.where(assignee_id: (params[:assignee_id] == '0' ? nil : params[:assignee_id]))
end end
# Filter by specific milestone_id (or lack thereof)? # Filter by specific milestone_id (or lack thereof)?
if params[:milestone_id].present? if params[:milestone_id].present?
@merge_requests = merge_requests.where(milestone_id: (params[:milestone_id] == '0' ? nil : params[:milestone_id])) merge_requests = merge_requests.where(milestone_id: (params[:milestone_id] == '0' ? nil : params[:milestone_id]))
end end
@merge_requests
merge_requests
end end
end end
...@@ -16,8 +16,16 @@ class Milestone < ActiveRecord::Base ...@@ -16,8 +16,16 @@ class Milestone < ActiveRecord::Base
User.where(id: issues.pluck(:assignee_id)) User.where(id: issues.pluck(:assignee_id))
end end
def percent_complete def issues_percent_complete
((self.issues.closed.count * 100) / self.issues.count).abs ((self.issues.closed.count * 100) / self.issues.count).abs
end
def merge_requests_percent_complete
((self.merge_requests.closed.count * 100) / self.merge_requests.count).abs
end
def percent_complete
(issues_percent_complete + merge_requests_percent_complete) / 2
rescue ZeroDivisionError rescue ZeroDivisionError
100 100
end end
......
%li{class: "milestone", id: dom_id(milestone) } %li{class: "milestone", id: dom_id(milestone) }
.right .right
- if milestone.issues.any?
%span.btn.small.disabled.grouped= pluralize milestone.issues.count, 'issues'
- if milestone.issues.count > 0
= link_to 'Browse Issues', project_issues_path(milestone.project, milestone_id: milestone.id), class: "btn small grouped"
- if milestone.merge_requests.any?
%span.btn.small.disabled.grouped= pluralize milestone.issues.count, 'Merge Requests'
- if milestone.merge_requests.count > 0
= link_to 'Browse Merge Requests', project_merge_requests_path(milestone.project, milestone_id: milestone.id), class: "btn small grouped"
- if can? current_user, :admin_milestone, milestone.project - if can? current_user, :admin_milestone, milestone.project
= link_to 'Edit', edit_project_milestone_path(milestone.project, milestone), class: "btn small edit-milestone-link grouped" = link_to edit_project_milestone_path(milestone.project, milestone), class: "btn small edit-milestone-link grouped" do
%i.icon-edit
Edit
%h4 %h4
= link_to_gfm truncate(milestone.title, length: 100), project_milestone_path(milestone.project, milestone), class: "row_title" = link_to_gfm truncate(milestone.title, length: 100), project_milestone_path(milestone.project, milestone)
%small %small
= milestone.expires_at = milestone.expires_at
%br .row
.progress.progress-success.span3 .progress.progress-success.span4
.bar{style: "width: #{milestone.percent_complete}%;"} .bar{style: "width: #{milestone.percent_complete}%;"}
.span6
- if milestone.issues.any?
= link_to project_issues_path(milestone.project, milestone_id: milestone.id), class: "padded" do
%strong= pluralize milestone.issues.count, 'Issue'
- if milestone.merge_requests.any?
&nbsp; = link_to project_merge_requests_path(milestone.project, milestone_id: milestone.id), class: "padded" do
%strong= pluralize milestone.issues.count, 'Merge Request'
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment