Refactor contacts/index
This commit is contained in:
parent
099b4063d2
commit
649844ea6a
5 changed files with 25 additions and 25 deletions
|
|
@ -50,5 +50,6 @@ class ContactsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@contacts = @contacts.for_a_stream.paginate(:page => params[:page], :per_page => 25)
|
@contacts = @contacts.for_a_stream.paginate(:page => params[:page], :per_page => 25)
|
||||||
|
@contacts_size = @contacts.length
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,11 @@ module ContactsHelper
|
||||||
:current_user => current_user }
|
:current_user => current_user }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def start_a_conversation_link(aspect, contacts_size)
|
||||||
|
suggested_limit = 16
|
||||||
|
conv_opts = { :class => "button conversation_button", :rel => "facebox"}
|
||||||
|
conv_opts[:title] = t('.many_people_are_you_sure', :suggested_limit => suggested_limit) if contacts_size > suggested_limit
|
||||||
|
link_to t('.start_a_conversation'), new_conversation_path(:aspect_id => aspect.id, :name => aspect.name), conv_opts
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
= my_contacts_count
|
= my_contacts_count
|
||||||
|
|
||||||
%ul.sub_nav
|
%ul.sub_nav
|
||||||
- for aspect in all_aspects
|
- all_aspects.each do |aspect|
|
||||||
%li{:data => {:aspect_id => aspect.id}, :class => ("active" if params["a_id"].to_i == aspect.id)}
|
%li{:data => {:aspect_id => aspect.id}, :class => ("active" if params["a_id"].to_i == aspect.id)}
|
||||||
%a.aspect_selector{:href => contacts_path(:a_id => aspect.id)}
|
%a.aspect_selector{:href => contacts_path(:a_id => aspect.id)}
|
||||||
= aspect
|
= aspect
|
||||||
|
|
|
||||||
10
app/views/contacts/_contact.html.haml
Normal file
10
app/views/contacts/_contact.html.haml
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
.stream_element{:id => contact.person_id}
|
||||||
|
.float-right
|
||||||
|
= contact_aspect_dropdown(contact)
|
||||||
|
.media
|
||||||
|
.img
|
||||||
|
= person_image_link(contact.person, :size => :thumb_small)
|
||||||
|
.bd
|
||||||
|
= person_link(contact.person)
|
||||||
|
.info
|
||||||
|
= contact.person_diaspora_handle
|
||||||
|
|
@ -16,32 +16,14 @@
|
||||||
|
|
||||||
.span-18.last
|
.span-18.last
|
||||||
#people_stream.stream.contacts
|
#people_stream.stream.contacts
|
||||||
|
- if @contacts_size > 0
|
||||||
- if @aspect
|
- if @aspect
|
||||||
#aspect_controls
|
#aspect_controls
|
||||||
- suggested_limit = 16
|
- if @contacts_size < 20
|
||||||
- conv_opts = { :class => "button conversation_button", :rel => "facebox"}
|
= start_a_conversation_link(@aspect, @contacts_size)
|
||||||
- conv_opts[:title] = t('.many_people_are_you_sure', :suggested_limit => suggested_limit) if @contacts.size > suggested_limit
|
|
||||||
|
|
||||||
- if @contacts.size < 20
|
|
||||||
= link_to t('.start_a_conversation'), new_conversation_path(:aspect_id => @aspect.id, :name => @aspect.name), conv_opts
|
|
||||||
- if @contacts.size
|
|
||||||
= link_to t('.add_to_aspect', :name => @aspect.name), edit_aspect_path(@aspect), :rel => "facebox"
|
= link_to t('.add_to_aspect', :name => @aspect.name), edit_aspect_path(@aspect), :rel => "facebox"
|
||||||
|
|
||||||
- if @contacts.size > 0
|
= render @contacts
|
||||||
- for contact in @contacts
|
|
||||||
.stream_element{:id => contact.person_id}
|
|
||||||
|
|
||||||
.float-right
|
|
||||||
= contact_aspect_dropdown(contact)
|
|
||||||
|
|
||||||
.media
|
|
||||||
.img
|
|
||||||
= person_image_link(contact.person, :size => :thumb_small)
|
|
||||||
|
|
||||||
.bd
|
|
||||||
= person_link(contact.person)
|
|
||||||
.info
|
|
||||||
= contact.person_diaspora_handle
|
|
||||||
|
|
||||||
= will_paginate @contacts
|
= will_paginate @contacts
|
||||||
- else
|
- else
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue