add inline forum editing
This commit is contained in:
@@ -48,7 +48,7 @@ module ApplicationHelper
|
||||
def error_messages_for(instance_name)
|
||||
instance = instance_variable_get("@#{instance_name}")
|
||||
|
||||
if instance.errors.any?
|
||||
if instance && instance.errors.any?
|
||||
%{<div class="error-messages ui-state-error ui-corner-all"><span class="ui-icon ui-icon-alert"></span> <strong>Error</strong>: #{instance.__send__(:errors).full_messages.join(", ")}</div>}.html_safe
|
||||
else
|
||||
""
|
||||
|
||||
@@ -104,9 +104,13 @@ class ForumPost < ActiveRecord::Base
|
||||
self.is_deleted = false if is_deleted.nil?
|
||||
end
|
||||
|
||||
def quoted_response
|
||||
"[quote]\n#{body}\n[/quote]\n\n"
|
||||
end
|
||||
|
||||
def build_response
|
||||
dup.tap do |x|
|
||||
x.body = "[quote]\n#{x.body}\n[/quote]\n\n"
|
||||
x.body = x.quoted_response
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<%= error_messages_for("forum_post") %>
|
||||
|
||||
<%= simple_form_for(@forum_post) do |f| %>
|
||||
<%= simple_form_for(forum_post) do |f| %>
|
||||
<%= f.input :topic_id, :as => :hidden %>
|
||||
<%= dtext_field "forum_post", "body" %>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<%= format_text(forum_post.body) %>
|
||||
</div>
|
||||
<menu>
|
||||
<li><%= link_to "Quote", new_forum_post_path(:post_id => forum_post.id) %></li>
|
||||
<li><%= link_to "Quote", new_forum_post_path(:post_id => forum_post.id), :method => :get, :remote => true %></li>
|
||||
<% if CurrentUser.user.is_janitor? || CurrentUser.user.id == forum_post.creator_id %>
|
||||
<% if forum_post.is_deleted %>
|
||||
<li><%= link_to "Undelete", undelete_forum_post_path(forum_post.id), :method => :post, :remote => true %></li>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div id="a-edit">
|
||||
<h1>Edit Forum Post</h1>
|
||||
|
||||
<%= render "form" %>
|
||||
<%= render "form", :forum_post => @forum_post %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<h1>New Forum Post</h1>
|
||||
<% end %>
|
||||
|
||||
<%= render "form" %>
|
||||
<%= render "form", :forum_post => @forum_post %>
|
||||
<%= error_messages_for "forum_post" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
6
app/views/forum_posts/new.js.erb
Normal file
6
app/views/forum_posts/new.js.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
$("#forum_post_body").val("<%= escape_javascript @forum_post.body %>");
|
||||
$("#new-topic-response").show();
|
||||
|
||||
$('html, body').animate({
|
||||
scrollTop: $("#forum_post_body").offset().top - 100
|
||||
}, 500);
|
||||
@@ -17,6 +17,10 @@
|
||||
|
||||
<p><%= link_to "Reply »".html_safe, new_forum_post_path(:topic_id => @forum_topic.id) %></p>
|
||||
|
||||
<div id="topic-response">
|
||||
<%= render "forum_posts/form", :forum_post => ForumPost.new(:topic_id => @forum_topic.id) %>
|
||||
</div>
|
||||
|
||||
<%= numbered_paginator(@forum_posts) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<td><%= link_to upload.id, upload_path(upload) %></td>
|
||||
<td><%= link_to upload.uploader.name, user_path(upload.uploader) %></td>
|
||||
<td><%= upload.presenter.status(self) %></td>
|
||||
<td><%= upload.created_at %></td>
|
||||
<td><%= time_ago_in_words_tagged upload.created_at %></td>
|
||||
<td><%= upload.tag_string %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user