Commit d4e070cf authored by randx's avatar randx

Improve styles. Add merge request completness to milestone percentage

parent ecdf778e
......@@ -670,3 +670,8 @@ pre {
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
def execute
type = params[:f]
merge_requests = @project.merge_requests
merge_requests = project.merge_requests
merge_requests = case type
when 'all' then merge_requests
when 'closed' then merge_requests.closed
when 'assigned-to-me' then merge_requests.opened.assigned(current_user)
else merge_requests.opened
end.page(params[:page]).per(20)
merge_requests.includes(:author, :project).order("closed, created_at desc")
end
@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)?
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
# Filter by specific milestone_id (or lack thereof)?
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
@merge_requests
merge_requests
end
end
......@@ -16,8 +16,16 @@ class Milestone < ActiveRecord::Base
User.where(id: issues.pluck(:assignee_id))
end
def percent_complete
def issues_percent_complete
((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
100
end
......
%li{class: "milestone", id: dom_id(milestone) }
.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
= 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
= 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
= milestone.expires_at
%br
.progress.progress-success.span3
.row
.progress.progress-success.span4
.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'
&nbsp;
- if milestone.merge_requests.any?
= 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