BigW Consortium Gitlab

Commit 15914676 by Ciro Santilli

Helper instead of template.

parent 0a6e978d
......@@ -122,6 +122,28 @@ module ProjectsHelper
options_for_select(values, current_tracker)
end
def link_to_toggle_star(title, starred, signed_in)
cls = 'btn'
cls += ' disabled' unless signed_in
content_tag 'span', class: starred ? 'turn-on' : 'turn-off' do
link_to toggle_star_project_path(@project),
title: title, class: cls, method: :post, remote: true,
data: {type: 'json'} do
content_tag('span', class: 'toggle') do
content_tag('i', ' ', class: 'icon-star') <<
if starred
'Unstar'
else
'Star'
end
end <<
content_tag('span', class: 'count') do
@project.star_count.to_s
end
end
end
end
private
def get_project_nav_tabs(project, current_user)
......
......@@ -36,16 +36,7 @@
%span.light.prepend-left-20= repository_size
%span.star.js-toggler-container{class: @show_star ? 'on' : ''}
- if current_user
= render 'link_to_toggle_star',
title: 'Star this project.',
starred: false,
signed_in: true
= render 'link_to_toggle_star',
title: 'Unstar this project.',
starred: true,
signed_in: true
= link_to_toggle_star('Star this project.', false, true)
= link_to_toggle_star('Unstar this project.', true, true)
- else
= render 'link_to_toggle_star',
title: 'You must sign in to star a project.',
starred: false,
signed_in: false
= link_to_toggle_star('You must sign in to star a project.', false, false)
- cls = 'btn'
- cls += ' disabled' unless signed_in
%span{class: starred ? 'turn-on' : 'turn-off'}
= link_to toggle_star_project_path(@project), title: title,
class: cls, method: :post, remote: true, data: {type: 'json'} do
%span.toggle<>
%i.icon-star
- if starred
Unstar
- else
Star
%span.count<>
= @project.star_count
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