Improve styles. Add merge request completness to milestone percentage

This commit is contained in:
randx 2012-10-29 22:40:00 +02:00
parent ecdf778e80
commit d4e070cfad
4 changed files with 37 additions and 23 deletions

View file

@ -670,3 +670,8 @@ pre {
padding:0;
}
}
.milestone .progress {
margin-bottom: 0;
margin-top:4px;
}

View file

@ -1,29 +1,31 @@
# 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)
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)?
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

View file

@ -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

View file

@ -1,22 +1,21 @@
%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'