start a conversation with an aspect from contact index page

This commit is contained in:
danielgrippi 2011-06-28 23:09:11 -07:00
parent 2c3e403bc0
commit b8ea8e9e75
6 changed files with 34 additions and 7 deletions

View file

@ -61,8 +61,14 @@ class ConversationsController < ApplicationController
select("contacts.id, profiles.first_name, profiles.last_name, people.diaspora_handle").to_sql
).map{|r| {:value => r[0], :name => Person.name_from_attrs(r[1], r[2], r[3]).gsub(/(")/, "'")} }
@contact_ids = ""
@contacts_json = all_contacts_and_ids.to_json.gsub!(/(")/, '\\"')
@contact = current_user.contacts.find(params[:contact_id]) if params[:contact_id]
if params[:contact_id]
@contact_ids = current_user.contacts.find(params[:contact_id]).id
elsif params[:aspect_id]
@contact_ids = current_user.aspects.find(params[:aspect_id]).contacts.map{|c| c.id}.join(',')
end
render :layout => false
end

View file

@ -6,6 +6,9 @@
- content_for :page_title do
= t('.title')
- content_for :head do
= include_javascripts :people
#section_header
%h2
= t('.title')
@ -44,6 +47,10 @@
.span-18.last
#people_stream.stream.contacts
- if @contacts.size > 0
#aspect_controls
- if @aspect_
= link_to "start a conversation", new_conversation_path(:aspect_id => @aspect_.id, :name => @aspect_.name), :class => "button conversation_button", :rel => "facebox"
- for contact in @contacts
.stream_element{:id => contact.person.id}
.right

View file

@ -16,14 +16,12 @@
keyDelay: 0,
startText: '',
emptyText: '#{t('no_results')}',
preFill: [{ 'name' : "#{params[:name]}",
'value' : "#{params[:contact_id]}"}]
preFill: [{name : "#{params[:name]}",
value : "#{@contact_ids}"}]
});
autocompleteInput.focus();
});
#new_message_pane
.span-12.last
#facebox_header

View file

@ -29,7 +29,7 @@
.right
= link_to t('.mention'), new_status_message_path(:person_id => @person.id), :class => 'button', :rel => 'facebox'
- if @contact.mutual?
= link_to t('.message'), new_conversation_path(:contact_id => @contact.id, :name => @contact.person.name, :contact_id => @contact.id), :class => 'button', :rel => 'facebox'
= link_to t('.message'), new_conversation_path(:contact_id => @contact.id, :name => @contact.person.name), :class => 'button', :rel => 'facebox'
%h3
= @person.name

View file

@ -3104,3 +3104,14 @@ ul#left_nav
a.close
:float right
:text-decoration none
#aspect_controls
@include border-radius(2px)
:background
:color #fafafa
:border 1px solid #ccc
:padding 10px
:min-height 23px
.conversation_button
:float right

View file

@ -24,7 +24,12 @@ describe ConversationsController do
it "assigns a contact if passed a contact id" do
get :new, :contact_id => alice.contacts.first.id
assigns(:contact).should == alice.contacts.first
assigns(:contact_ids).should == alice.contacts.first.id
end
it "assigns a set of contacts if passed an aspect id" do
get :new, :aspect_id => alice.aspects.first.id
assigns(:contact_ids).should == alice.aspects.first.contacts.map(&:id).join(',')
end
end