Use static helper for aspect links
This commit is contained in:
parent
b84d2bcc56
commit
49e8347aa3
3 changed files with 36 additions and 7 deletions
|
|
@ -9,6 +9,38 @@ module ApplicationHelper
|
|||
false
|
||||
end
|
||||
|
||||
def aspects_with_post aspects, post
|
||||
aspects.select do |a|
|
||||
post.aspect_ids.include?(a.id)
|
||||
end
|
||||
end
|
||||
def aspects_without_post aspects, post
|
||||
aspects.reject do |a|
|
||||
post.aspect_ids.include?(a.id)
|
||||
end
|
||||
end
|
||||
def aspect_links aspects, opts={}
|
||||
str = ""
|
||||
aspects.each do |a|
|
||||
str << aspect_li(a, opts)
|
||||
end
|
||||
str.html_safe
|
||||
end
|
||||
def aspect_li aspect, opts= {}
|
||||
param_string = ""
|
||||
if opts.size > 0
|
||||
param_string << '?'
|
||||
opts.each_pair do |k,v|
|
||||
param_string << "#{k}=#{v}"
|
||||
end
|
||||
end
|
||||
"<li>
|
||||
<a href='/aspects/#{aspect.id}#{param_string}'>
|
||||
#{aspect.name}
|
||||
</a>
|
||||
</li>".html_safe
|
||||
end
|
||||
|
||||
def current_aspect?(aspect)
|
||||
!@aspect.nil? && !@aspect.is_a?(Symbol) && @aspect.id == aspect.id
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,6 +7,5 @@
|
|||
= link_to t('.reshare'), "#"
|
||||
|
||||
%ul.reshare_box
|
||||
- for aspect in aspects
|
||||
%li.aspect_to_share= link_to aspect, :controller => "aspects", :action => "show", :id => aspect.id, :prefill => post.message
|
||||
=aspect_links(aspects, :prefill => post.message)
|
||||
|
||||
|
|
|
|||
|
|
@ -17,14 +17,12 @@
|
|||
- if post.public?
|
||||
%li= t('the_world')
|
||||
- else
|
||||
- for aspect in aspects.select{|a| post.aspect_ids.include?(a.id)}
|
||||
%li
|
||||
%a{:href => "/aspects/#{aspect.id}"}=aspect.name
|
||||
=aspect_links(aspects_with_post(aspects, post))
|
||||
|
||||
.right
|
||||
- reshare_aspects = aspects.reject{|a| post.aspect_ids.include?(a.id)}
|
||||
- reshare_aspects = aspects_without_post(aspects, post)
|
||||
- unless reshare_aspects.empty?
|
||||
= render 'shared/reshare', :current_user => current_user, :aspects => aspects, :post => post
|
||||
= render 'shared/reshare', :current_user => current_user, :aspects => reshare_aspects, :post => post
|
||||
= link_to t('delete'), status_message_path(post), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete"
|
||||
|
||||
= render 'status_messages/status_message', :post => post, :photos => post.photos
|
||||
|
|
|
|||
Loading…
Reference in a new issue