Commit f417a265 authored by randx's avatar randx

Finalize milestones for Merge Requests

parent d4e070cf
...@@ -5,3 +5,10 @@ $ -> ...@@ -5,3 +5,10 @@ $ ->
$('.milestone-issue-filter li').toggleClass('active') $('.milestone-issue-filter li').toggleClass('active')
$('.milestone-issue-filter tr[data-closed]').toggleClass('hide') $('.milestone-issue-filter tr[data-closed]').toggleClass('hide')
false false
$('.milestone-merge-requests-filter tr[data-closed]').addClass('hide')
$('.milestone-merge-requests-filter ul.nav li a').click ->
$('.milestone-merge-requests-filter li').toggleClass('active')
$('.milestone-merge-requests-filter tr[data-closed]').toggleClass('hide')
false
...@@ -675,3 +675,11 @@ pre { ...@@ -675,3 +675,11 @@ pre {
margin-bottom: 0; margin-bottom: 0;
margin-top:4px; margin-top:4px;
} }
.float-link {
float:left;
margin-right:15px;
.s16 {
margin-right:5px;
}
}
...@@ -31,7 +31,7 @@ class MilestonesController < ProjectResourceController ...@@ -31,7 +31,7 @@ class MilestonesController < ProjectResourceController
def show def show
@issues = @milestone.issues @issues = @milestone.issues
@users = @milestone.participants @users = UserDecorator.decorate(@milestone.participants)
@merge_requests = @milestone.merge_requests @merge_requests = @milestone.merge_requests
respond_to do |format| respond_to do |format|
......
class UserDecorator < ApplicationDecorator
decorates :user
def avatar_image size = 16
h.image_tag h.gravatar_icon(self.email, size), class: "avatar #{"s#{size}"}", width: size
end
def tm_of(project)
project.team_member_by_id(self.id)
end
end
...@@ -10,5 +10,9 @@ module ProjectsHelper ...@@ -10,5 +10,9 @@ module ProjectsHelper
def link_to_project project def link_to_project project
link_to project.name, project link_to project.name, project
end end
def tm_path team_member
project_team_member_path(@project, team_member)
end
end end
require Rails.root.join("app/models/commit") require Rails.root.join("app/models/commit")
require Rails.root.join("app/roles/static_model")
class MergeRequest < ActiveRecord::Base class MergeRequest < ActiveRecord::Base
include IssueCommonality include IssueCommonality
......
...@@ -16,16 +16,20 @@ class Milestone < ActiveRecord::Base ...@@ -16,16 +16,20 @@ class Milestone < ActiveRecord::Base
User.where(id: issues.pluck(:assignee_id)) User.where(id: issues.pluck(:assignee_id))
end end
def issues_percent_complete def open_items_count
((self.issues.closed.count * 100) / self.issues.count).abs self.issues.opened.count + self.merge_requests.opened.count
end end
def merge_requests_percent_complete def closed_items_count
((self.merge_requests.closed.count * 100) / self.merge_requests.count).abs self.issues.closed.count + self.merge_requests.closed.count
end
def total_items_count
self.issues.count + self.merge_requests.count
end end
def percent_complete def percent_complete
(issues_percent_complete + merge_requests_percent_complete) / 2 ((closed_items_count * 100) / total_items_count).abs
rescue ZeroDivisionError rescue ZeroDivisionError
100 100
end end
......
...@@ -9,13 +9,13 @@ ...@@ -9,13 +9,13 @@
%small %small
= milestone.expires_at = milestone.expires_at
.row .row
.progress.progress-success.span4 .progress.progress-info.span4
.bar{style: "width: #{milestone.percent_complete}%;"} .bar{style: "width: #{milestone.percent_complete}%;"}
.span6 .span6
- if milestone.issues.any? - if milestone.issues.any?
= link_to project_issues_path(milestone.project, milestone_id: milestone.id), class: "padded" do = link_to project_issues_path(milestone.project, milestone_id: milestone.id), class: "btn very_small" do
%strong= pluralize milestone.issues.count, 'Issue' %strong= pluralize milestone.issues.count, 'Issue'
- if milestone.merge_requests.any? - if milestone.merge_requests.any?
= link_to project_merge_requests_path(milestone.project, milestone_id: milestone.id), class: "padded" do = link_to project_merge_requests_path(milestone.project, milestone_id: milestone.id), class: "btn very_small" do
%strong= pluralize milestone.issues.count, 'Merge Request' %strong= pluralize milestone.issues.count, 'Merge Request'
...@@ -31,10 +31,10 @@ ...@@ -31,10 +31,10 @@
%h5 %h5
Progress: Progress:
%small %small
#{@milestone.issues.closed.count} closed #{@milestone.closed_items_count} closed
&ndash; &ndash;
#{@milestone.issues.opened.count} open #{@milestone.open_items_count} open
.progress.progress-success .progress.progress-info
.bar{style: "width: #{@milestone.percent_complete}%;"} .bar{style: "width: #{@milestone.percent_complete}%;"}
...@@ -58,10 +58,9 @@ ...@@ -58,10 +58,9 @@
%span.badge.badge-info ##{issue.id} %span.badge.badge-info ##{issue.id}
&ndash; &ndash;
= link_to_gfm truncate(issue.title, length: 60), [@project, issue] = link_to_gfm truncate(issue.title, length: 60), [@project, issue]
%br
.span6 .span6
%table.milestone-merge_requests-filter %table.milestone-merge-requests-filter
%thead %thead
%th %th
%ul.nav.nav-pills %ul.nav.nav-pills
...@@ -74,15 +73,13 @@ ...@@ -74,15 +73,13 @@
%span.badge.badge-info ##{merge_request.id} %span.badge.badge-info ##{merge_request.id}
&ndash; &ndash;
= link_to_gfm truncate(merge_request.title, length: 60), [@project, merge_request] = link_to_gfm truncate(merge_request.title, length: 60), [@project, merge_request]
%br
.span6 %hr
%table %h6 Participants:
%thead %div
%th Participants
- @users.each do |user| - @users.each do |user|
%tr = link_to tm_path(user.tm_of(@project)), class: 'float-link' do
%td = user.avatar_image
= image_tag gravatar_icon(user.email, 24), width: "24"
&nbsp;
= user.name = user.name
.clearfix
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