diff --git a/plugins/comment_paragraph/controllers/profile/comment_paragraph_plugin_profile_controller.rb b/plugins/comment_paragraph/controllers/profile/comment_paragraph_plugin_profile_controller.rb index 9743c3e..09b4b98 100644 --- a/plugins/comment_paragraph/controllers/profile/comment_paragraph_plugin_profile_controller.rb +++ b/plugins/comment_paragraph/controllers/profile/comment_paragraph_plugin_profile_controller.rb @@ -1,4 +1,4 @@ -class CommentParagraphPluginProfileController < ProfileController +class CommentParagraphPluginProfileController < CommentController append_view_path File.join(File.dirname(__FILE__) + '/../../views') def view_comments @@ -11,4 +11,14 @@ class CommentParagraphPluginProfileController < ProfileController render :partial => 'comment/comment.html.erb', :collection => @comments end + def comment_form + @page = profile.articles.find(params[:article_id]) + render :partial => 'comment/comment_form', :locals => { + :comment => Comment.new, + :display_link => true, + :cancel_triggers_hide => true, + :paragraph_uuid => params[:paragraph_uuid] + } + end + end diff --git a/plugins/comment_paragraph/public/comment_paragraph_macro.js b/plugins/comment_paragraph/public/comment_paragraph_macro.js index 5a4c166..07a050a 100644 --- a/plugins/comment_paragraph/public/comment_paragraph_macro.js +++ b/plugins/comment_paragraph/public/comment_paragraph_macro.js @@ -80,6 +80,12 @@ jQuery(document).ready(function($) { container.find('.display-comment-form').show(); } }); + var formDiv = container.find('.side-comment .post_comment_box'); + if(formDiv.find('.page-comment-form').length==0) { + $.ajax(formDiv.data('comment_paragraph_form_url')).done(function(data) { + formDiv.append(data); + }); + } }); diff --git a/plugins/comment_paragraph/test/functional/comment_paragraph_plugin_profile_controller_test.rb b/plugins/comment_paragraph/test/functional/comment_paragraph_plugin_profile_controller_test.rb index edaf8aa..86aaeac 100644 --- a/plugins/comment_paragraph/test/functional/comment_paragraph_plugin_profile_controller_test.rb +++ b/plugins/comment_paragraph/test/functional/comment_paragraph_plugin_profile_controller_test.rb @@ -10,6 +10,9 @@ class CommentParagraphPluginProfileControllerTest < ActionController::TestCase @profile = create_user('testuser').person @article = profile.articles.build(:name => 'test') @article.save! + @environment = Environment.default + @environment.enabled_plugins = ['CommentParagraphPlugin'] + @environment.save! end attr_reader :article, :profile @@ -39,4 +42,12 @@ class CommentParagraphPluginProfileControllerTest < ActionController::TestCase assert_match /d comment/, @response.body end + should 'load the comment form for a paragraph' do + login_as('testuser') + comment = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala', :paragraph_uuid => 0) + xhr :get, :comment_form, :profile => @profile.identifier, :article_id => article.id, :paragraph_uuid => 0 + assert_select ".page-comment-form" + assert_select "#comment_paragraph_uuid[value=?]", '0' + end + end diff --git a/plugins/comment_paragraph/views/comment_paragraph_plugin_profile/_comment_paragraph.html.erb b/plugins/comment_paragraph/views/comment_paragraph_plugin_profile/_comment_paragraph.html.erb index 131353c..b698151 100644 --- a/plugins/comment_paragraph/views/comment_paragraph_plugin_profile/_comment_paragraph.html.erb +++ b/plugins/comment_paragraph/views/comment_paragraph_plugin_profile/_comment_paragraph.html.erb @@ -11,14 +11,14 @@ <% load_comments_url = url_for({:profile => profile_identifier, :controller => 'comment_paragraph_plugin_profile', :action => 'view_comments', :paragraph_uuid => paragraph_uuid, :article_id => article_id}) %> + <% load_comment_form_url = url_for({:profile => profile_identifier, :controller => 'comment_paragraph_plugin_profile', :action => 'comment_form', :paragraph_uuid => paragraph_uuid, :article_id => article_id}) %>
-
- <%= render :partial => 'comment/comment_form', :locals => {:comment => Comment.new, :display_link => true, :cancel_triggers_hide => true, :paragraph_uuid => paragraph_uuid}%> +
-- libgit2 0.21.2