diff --git a/app/controllers/conversations_controller.rb b/app/controllers/conversations_controller.rb index dfe07c023ce644d17568271783c86fac20aa3b96..3ff512e526785764c8c670bf8cefba639645c28c 100644 --- a/app/controllers/conversations_controller.rb +++ b/app/controllers/conversations_controller.rb @@ -6,7 +6,9 @@ class ConversationsController < ApplicationController def index @conversations = Conversation.joins(:conversation_visibilities).where( :conversation_visibilities => {:person_id => current_user.person.id}).paginate( - :page => params[:page], :per_page => 7, :order => 'updated_at DESC') + :page => params[:page], :per_page => 15, :order => 'updated_at DESC') + @authors = {} + @conversations.each{|c| @authors[c.id] = c.last_author} @conversation = Conversation.joins(:conversation_visibilities).where( :conversation_visibilities => {:person_id => current_user.person.id, :conversation_id => params[:conversation_id]}).first @@ -22,7 +24,12 @@ class ConversationsController < ApplicationController @conversation = Conversation.create(params[:conversation]) - redirect_to conversations_path(:conversation_id => @conversation.id) + flash[:notice] = "Message sent" + if params[:profile] + redirect_to person_path(params[:profile]) + else + redirect_to conversations_path(:conversation_id => @conversation.id) + end end def show @@ -37,6 +44,7 @@ class ConversationsController < ApplicationController end def new + @contact = current_user.contacts.find(params[:contact_id]) if params[:contact_id] render :layout => false end diff --git a/app/views/conversations/new.haml b/app/views/conversations/new.haml index e61d21678e1b7974353a1f5c708811d0165618d2..03542287a7fe3ff6fca80730fe8281cc2c5e1bbb 100644 --- a/app/views/conversations/new.haml +++ b/app/views/conversations/new.haml @@ -3,21 +3,32 @@ -# the COPYRIGHT file. -%h2 - New Message +#new_message_pane + #facebox_header + %h4 + New Message -= form_for Conversation.new do |conversation| - %h4 - to - = text_field_tag "conversation[contact_ids]" + = form_for Conversation.new do |conversation| - %h4 - subject - = conversation.text_field :subject + - if @contact + send a message to + = @contact.person.name - %h4 - message - = text_area_tag "conversation[text]", '', :rows => 5 + = hidden_field_tag "conversation[contact_ids]", @contact.id + = hidden_field_tag "profile", @contact.person.id - = conversation.submit :send - = link_to 'cancel', conversations_path + -else + %h4 + to + = text_field_tag "conversation[contact_ids]" + + %h4 + subject + = conversation.text_field :subject + + %h4 + message + = text_area_tag "conversation[text]", '', :rows => 5 + + = conversation.submit :send + = link_to 'cancel', conversations_path diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index 928c90a082b90beb88e0486a51b61f4ff68f7bc6..e8385392607401223f431b3c33843507abd1179b 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -42,10 +42,12 @@ - else .right - - if @post_type == :photos - = link_to t('layouts.header.view_profile'), person_path(@person) - - else - = link_to t('_photos'), person_photos_path(@person) + = link_to 'Message', new_conversation_path(:contact_id => @contact.id), :class => 'button', :rel => 'facebox' + + /- if @post_type == :photos + / = link_to t('layouts.header.view_profile'), person_path(@person) + /- else + / = link_to t('_photos'), person_photos_path(@person) %h3 = @person.name