Merge pull request #3937 from marpo60/refactor-contacts-view

Refactor contacts view
This commit is contained in:
Jonne Haß 2013-01-29 04:08:59 -08:00
commit 58b4907de8
7 changed files with 30 additions and 28 deletions

View file

@ -15,6 +15,7 @@
* Write unicorn stderr and stdout [#3785](https://github.com/diaspora/diaspora/pull/3785) * Write unicorn stderr and stdout [#3785](https://github.com/diaspora/diaspora/pull/3785)
* Ported aspects to backbone [#3850](https://github.com/diaspora/diaspora/pull/3850) * Ported aspects to backbone [#3850](https://github.com/diaspora/diaspora/pull/3850)
* Join tagging's table instead of tags to improve a bit the query [#3932](https://github.com/diaspora/diaspora/pull/3932) * Join tagging's table instead of tags to improve a bit the query [#3932](https://github.com/diaspora/diaspora/pull/3932)
* Refactor contacts/index view [#3937](https://github.com/diaspora/diaspora/pull/3937)
## Features ## Features
@ -47,6 +48,7 @@
* Fix services index view. [#3884](https://github.com/diaspora/diaspora/issues/3884) * Fix services index view. [#3884](https://github.com/diaspora/diaspora/issues/3884)
* Excesive padding with "user-controls" in single post view. [#3861](https://github.com/diaspora/diaspora/issues/3861) * Excesive padding with "user-controls" in single post view. [#3861](https://github.com/diaspora/diaspora/issues/3861)
* Resize full scaled image to a specific width. [#3818](https://github.com/diaspora/diaspora/issues/3818) * Resize full scaled image to a specific width. [#3818](https://github.com/diaspora/diaspora/issues/3818)
* Fix translation issue in contacts_helper [#3937](https://github.com/diaspora/diaspora/pull/3937)
## Gem Updates ## Gem Updates

View file

@ -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

View file

@ -8,7 +8,7 @@ module ContactsHelper
:aspect_id => @aspect.id, :aspect_id => @aspect.id,
:person_id => contact.person_id :person_id => contact.person_id
}, },
:title => t('.remove_person_from_aspect', :person_name => contact.person_first_name, :aspect_name => @aspect.name), :title => t('contacts.index.remove_person_from_aspect', :person_name => contact.person_first_name, :aspect_name => @aspect.name),
:method => 'delete') :method => 'delete')
else else
@ -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

View file

@ -3,7 +3,7 @@ module NotificationsHelper
def object_link(note, actors) def object_link(note, actors)
target_type = note.popup_translation_key target_type = note.popup_translation_key
actors_count = note.actors.count actors_count = note.actors.size
if note.instance_of?(Notifications::Mentioned) if note.instance_of?(Notifications::Mentioned)
if post = note.linked_object if post = note.linked_object
@ -29,7 +29,7 @@ module NotificationsHelper
def notification_people_link(note, people=nil) def notification_people_link(note, people=nil)
actors =people || note.actors actors =people || note.actors
number_of_actors = actors.count number_of_actors = actors.size
sentence_translations = {:two_words_connector => " #{t('notifications.index.and')} ", :last_word_connector => ", #{t('notifications.index.and')} " } sentence_translations = {:two_words_connector => " #{t('notifications.index.and')} ", :last_word_connector => ", #{t('notifications.index.and')} " }
actor_links = actors.collect{ |person| actor_links = actors.collect{ |person|
person_link(person, :class => 'hovercardable') person_link(person, :class => 'hovercardable')

View file

@ -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

View 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

View file

@ -16,32 +16,14 @@
.span-18.last .span-18.last
#people_stream.stream.contacts #people_stream.stream.contacts
- if @aspect - if @contacts_size > 0
#aspect_controls - if @aspect
- suggested_limit = 16 #aspect_controls
- conv_opts = { :class => "button conversation_button", :rel => "facebox"} - if @contacts_size < 20
- conv_opts[:title] = t('.many_people_are_you_sure', :suggested_limit => suggested_limit) if @contacts.size > suggested_limit = start_a_conversation_link(@aspect, @contacts_size)
- 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