From b8ea8e9e7561ec2d5e8cb2239b1865205ee8d868 Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Tue, 28 Jun 2011 23:09:11 -0700 Subject: [PATCH] start a conversation with an aspect from contact index page --- app/controllers/conversations_controller.rb | 8 +++++++- app/views/contacts/index.html.haml | 7 +++++++ app/views/conversations/new.haml | 6 ++---- app/views/people/show.html.haml | 2 +- public/stylesheets/sass/application.sass | 11 +++++++++++ spec/controllers/conversations_controller_spec.rb | 7 ++++++- 6 files changed, 34 insertions(+), 7 deletions(-) diff --git a/app/controllers/conversations_controller.rb b/app/controllers/conversations_controller.rb index 593217770..eaa6ed522 100644 --- a/app/controllers/conversations_controller.rb +++ b/app/controllers/conversations_controller.rb @@ -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 diff --git a/app/views/contacts/index.html.haml b/app/views/contacts/index.html.haml index b971be5ef..01b9477d2 100644 --- a/app/views/contacts/index.html.haml +++ b/app/views/contacts/index.html.haml @@ -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 diff --git a/app/views/conversations/new.haml b/app/views/conversations/new.haml index b7877372b..cf8d8c0e8 100644 --- a/app/views/conversations/new.haml +++ b/app/views/conversations/new.haml @@ -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 diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index 55eb45b7a..c822793fe 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -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 diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 8fdd4d6cd..d01f58e0f 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -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 diff --git a/spec/controllers/conversations_controller_spec.rb b/spec/controllers/conversations_controller_spec.rb index 5ed0eb786..a1287d166 100644 --- a/spec/controllers/conversations_controller_spec.rb +++ b/spec/controllers/conversations_controller_spec.rb @@ -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