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)
* 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)
* Refactor contacts/index view [#3937](https://github.com/diaspora/diaspora/pull/3937)
## Features
@ -47,6 +48,7 @@
* 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)
* 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

View file

@ -50,5 +50,6 @@ class ContactsController < ApplicationController
end
end
@contacts = @contacts.for_a_stream.paginate(:page => params[:page], :per_page => 25)
@contacts_size = @contacts.length
end
end

View file

@ -8,7 +8,7 @@ module ContactsHelper
:aspect_id => @aspect.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')
else
@ -17,4 +17,11 @@ module ContactsHelper
:current_user => current_user }
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

View file

@ -3,7 +3,7 @@ module NotificationsHelper
def object_link(note, actors)
target_type = note.popup_translation_key
actors_count = note.actors.count
actors_count = note.actors.size
if note.instance_of?(Notifications::Mentioned)
if post = note.linked_object
@ -29,7 +29,7 @@ module NotificationsHelper
def notification_people_link(note, people=nil)
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')} " }
actor_links = actors.collect{ |person|
person_link(person, :class => 'hovercardable')

View file

@ -10,7 +10,7 @@
= my_contacts_count
%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)}
%a.aspect_selector{:href => contacts_path(:a_id => aspect.id)}
= 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
#people_stream.stream.contacts
- if @aspect
#aspect_controls
- 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
- 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
- if @contacts_size > 0
- if @aspect
#aspect_controls
- if @contacts_size < 20
= start_a_conversation_link(@aspect, @contacts_size)
= link_to t('.add_to_aspect', :name => @aspect.name), edit_aspect_path(@aspect), :rel => "facebox"
- if @contacts.size > 0
- 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
= render @contacts
= will_paginate @contacts
- else