Skip to content

Commit

Permalink
Improving messages validations and bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Roendal committed Mar 30, 2011
1 parent 6b15d9c commit c4cc0f6
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 23 deletions.
10 changes: 4 additions & 6 deletions app/controllers/conversations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def show
@conversation = Conversation.find_by_id(params[:id])
if @conversation.nil? or !@conversation.is_participant?(@actor)
redirect_to conversations_path(:box => @box)
return
return
end
if @box.eql? 'trash'
@receipts = @conversation.receipts(@actor).trash
Expand Down Expand Up @@ -50,10 +50,8 @@ def update
end

if params[:reply_all].present?
if params[:body].present?
last_receipt = @conversation.receipts(@actor).last
@actor.reply_to_all(last_receipt, params[:body])
end
last_receipt = @conversation.receipts(@actor).last
@receipt = @actor.reply_to_all(last_receipt, params[:body])
end

if @box.eql? 'trash'
Expand Down Expand Up @@ -93,7 +91,7 @@ def destroy
def get_mailbox
@mailbox = current_subject.mailbox
end

def get_actor
@actor = Actor.normalize(current_subject)
end
Expand Down
16 changes: 9 additions & 7 deletions app/controllers/messages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ def edit
def create
@actor = current_subject
@recipients = Array.new
params[:_recipients].each do |recp_id|
recp = Actor.find_by_id(recp_id)
next if recp.nil?
@recipients << recp
if params[:_recipients].present?
params[:_recipients].each do |recp_id|
recp = Actor.find_by_id(recp_id)
next if recp.nil?
@recipients << recp
end
end

if (mail = @actor.send_message(@recipients, params[:body], params[:subject]))
@conversation = mail.conversation
@receipt = @actor.send_message(@recipients, params[:body], params[:subject])
if (@receipt.errors.blank?)
@conversation = @receipt.conversation
redirect_to conversation_path(@conversation, :box => :sentbox)
else
render :action => :new
Expand Down
14 changes: 13 additions & 1 deletion app/views/conversations/_conversation_full.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,19 @@
<% unless @box.eql?'trash' %>
<br>
<%= form_tag conversation_path(conversation.id), :method => :put, :class => "cont_conversation" do %>
<div class="block">
<% if @receipt and @receipt.errors.any? %>
<div id="error">
<h2><%= pluralize(@receipt.errors.count, "error") %> prohibited this message from being sent:</h2>
<ul>
<% @receipt.errors.full_messages.each do |msg| %>
<li>
<%= msg %>
</li>
<% end %>
</ul>
</div>
<% end %>
<div class="block">
<div class="form_row">
Write your answer:
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/conversations/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<% end %>
<% content_for :javascript do %>
$('.cont_conversation').validate();
//$('.cont_conversation').validate(); //***************************************************************************** UNCOMMENT
<% unless @box.eql?'trash' %>
$('#body').ckeditor(
function(){
Expand Down
8 changes: 4 additions & 4 deletions app/views/messages/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<h2>New Message</h2>
<%= form_tag messages_path, :method => :post , :class => "new_message" do %>
<% if @conversation and @conversation.errors.any? %>
<div id="notice">
<h2><%= pluralize(@conversation.errors.count, "error") %> prohibited this message from being sent:</h2>
<% if @receipt and @receipt.errors.any? %>
<div id="error">
<h2><%= pluralize(@receipt.errors.count, "error") %> prohibited this message from being sent:</h2>
<ul>
<% @conversation.errors.full_messages.each do |msg| %>
<% @receipt.errors.full_messages.each do |msg| %>
<li>
<%= msg %>
</li>
Expand Down
4 changes: 2 additions & 2 deletions app/views/messages/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<% content_for :javascript do %>

var recipients = $("#_recipients").fcbkcomplete({
json_url: <%= contacts_path(:format => :json) %>,
json_url: "<%= contacts_path(:format => :json) %>",
cache: true,
filter_case: true,
filter_hide: true,
Expand Down Expand Up @@ -48,7 +48,7 @@
$("#_recipients").trigger("addItem",[{"title": "<%= @recipient.name %>", "value": "<%= @recipient.id %>"}]);
<% end %>

$(".new_message").validate();
//$(".new_message").validate(); //***************************************************************************** UNCOMMENT

<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/messages/new.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $("head").append($("<%= escape_javascript(stylesheet_link_tag "fcbkComplete.css"
$("head").append($("<%= escape_javascript(javascript_include_tag 'jquery.fcbkcomplete.min','jquery.validate','ckeditor/ckeditor.js','ckeditor/adapters/jquery.js') %>"));

var recipients = $("#_recipients").fcbkcomplete({
json_url: <%= contacts_path(:format => :json) %>,
json_url: "<%= contacts_path(:format => :json) %>",
cache: true,
filter_case: true,
filter_hide: true,
Expand Down
2 changes: 1 addition & 1 deletion social_stream.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Gem::Specification.new do |s|
# Theme support
s.add_runtime_dependency('rails_css_themes','~> 1.0.0')
# Messages
s.add_runtime_dependency('mailboxer','~> 0.0.13')
s.add_runtime_dependency('mailboxer','~> 0.0.14')
# Avatar manipulation
s.add_runtime_dependency('rmagick','~> 2.13.1')

Expand Down

0 comments on commit c4cc0f6

Please sign in to comment.