Extract displaying votes into partials
This commit is contained in:
parent
f7c70eaaed
commit
0bfcc574b6
6 changed files with 17 additions and 32 deletions
|
@ -35,11 +35,4 @@
|
||||||
|
|
||||||
|
|
||||||
- if issue.votes_count > 0
|
- if issue.votes_count > 0
|
||||||
.votes.votes-inline
|
= render 'votes/votes_inline', votable: issue
|
||||||
.upvotes= issue.upvotes
|
|
||||||
.progress
|
|
||||||
- up_percent = 100.0/issue.votes_count*issue.upvotes
|
|
||||||
- down_percent = 100.0-up_percent
|
|
||||||
.bar.bar-success{style: "width: #{up_percent}%;"}
|
|
||||||
.bar.bar-danger{style: "width: #{down_percent}%;"}
|
|
||||||
.downvotes= issue.downvotes
|
|
||||||
|
|
|
@ -17,14 +17,7 @@
|
||||||
Edit
|
Edit
|
||||||
|
|
||||||
.right
|
.right
|
||||||
.span3.votes.votes-block#votes
|
.span3#votes= render 'votes/votes_block', votable: @issue
|
||||||
.progress
|
|
||||||
- up_percent = 100.0/@issue.votes_count*@issue.upvotes
|
|
||||||
- down_percent = 100.0-up_percent
|
|
||||||
.bar.bar-success{style: "width: #{up_percent}%;"}
|
|
||||||
.bar.bar-danger{style: "width: #{down_percent}%;"}
|
|
||||||
.upvotes= "#{@issue.upvotes} up"
|
|
||||||
.downvotes= "#{@issue.downvotes} down"
|
|
||||||
|
|
||||||
.back_link
|
.back_link
|
||||||
= link_to project_issues_path(@project) do
|
= link_to project_issues_path(@project) do
|
||||||
|
|
|
@ -23,12 +23,6 @@
|
||||||
authored by #{merge_request.author_name}
|
authored by #{merge_request.author_name}
|
||||||
= time_ago_in_words(merge_request.created_at)
|
= time_ago_in_words(merge_request.created_at)
|
||||||
ago
|
ago
|
||||||
|
|
||||||
- if merge_request.votes_count > 0
|
- if merge_request.votes_count > 0
|
||||||
.votes.votes-inline
|
= render 'votes/votes_inline', votable: merge_request
|
||||||
.upvotes= merge_request.upvotes
|
|
||||||
.progress
|
|
||||||
- up_percent = 100.0/merge_request.votes_count*merge_request.upvotes
|
|
||||||
- down_percent = 100.0-up_percent
|
|
||||||
.bar.bar-success{style: "width: #{up_percent}%;"}
|
|
||||||
.bar.bar-danger{style: "width: #{down_percent}%;"}
|
|
||||||
.downvotes= merge_request.downvotes
|
|
||||||
|
|
|
@ -24,14 +24,7 @@
|
||||||
Edit
|
Edit
|
||||||
|
|
||||||
.right
|
.right
|
||||||
.span3.votes.votes-block#votes
|
.span3#votes= render 'votes/votes_block', votable: @merge_request
|
||||||
.progress
|
|
||||||
- up_percent = 100.0/@merge_request.votes_count*@merge_request.upvotes
|
|
||||||
- down_percent = 100.0-up_percent
|
|
||||||
.bar.bar-success{style: "width: #{up_percent}%;"}
|
|
||||||
.bar.bar-danger{style: "width: #{down_percent}%;"}
|
|
||||||
.upvotes= "#{@merge_request.upvotes} up"
|
|
||||||
.downvotes= "#{@merge_request.downvotes} down"
|
|
||||||
|
|
||||||
.back_link
|
.back_link
|
||||||
= link_to project_merge_requests_path(@project) do
|
= link_to project_merge_requests_path(@project) do
|
||||||
|
|
6
app/views/votes/_votes_block.html.haml
Normal file
6
app/views/votes/_votes_block.html.haml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
.votes.votes-block
|
||||||
|
.progress
|
||||||
|
.bar.bar-success{style: "width: #{votable.upvotes_in_percent}%;"}
|
||||||
|
.bar.bar-danger{style: "width: #{votable.downvotes_in_percent}%;"}
|
||||||
|
.upvotes= "#{votable.upvotes} up"
|
||||||
|
.downvotes= "#{votable.downvotes} down"
|
6
app/views/votes/_votes_inline.html.haml
Normal file
6
app/views/votes/_votes_inline.html.haml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
.votes.votes-inline
|
||||||
|
.upvotes= votable.upvotes
|
||||||
|
.progress
|
||||||
|
.bar.bar-success{style: "width: #{votable.upvotes_in_percent}%;"}
|
||||||
|
.bar.bar-danger{style: "width: #{votable.downvotes_in_percent}%;"}
|
||||||
|
.downvotes= votable.downvotes
|
Loading…
Reference in a new issue