diff --git a/controllers/profile/comment_paragraph_plugin_profile_controller.rb b/controllers/profile/comment_paragraph_plugin_profile_controller.rb index 06ab1a6..9743c3e 100644 --- a/controllers/profile/comment_paragraph_plugin_profile_controller.rb +++ b/controllers/profile/comment_paragraph_plugin_profile_controller.rb @@ -8,6 +8,7 @@ class CommentParagraphPluginProfileController < ProfileController @comments = article.comments.without_spam.in_paragraph(@paragraph_uuid) @comments_count = @comments.count @comments = @comments.without_reply + render :partial => 'comment/comment.html.erb', :collection => @comments end end diff --git a/db/migrate/20141223184902_add_paragraph_uuid_to_comments.rb b/db/migrate/20141223184902_add_paragraph_uuid_to_comments.rb index 1bc166d..cdf5454 100644 --- a/db/migrate/20141223184902_add_paragraph_uuid_to_comments.rb +++ b/db/migrate/20141223184902_add_paragraph_uuid_to_comments.rb @@ -1,6 +1,6 @@ class AddParagraphUuidToComments < ActiveRecord::Migration def change - add_column :comments, :paragraph_uuid, :string unless column_exists?(:comments, :paragraph_uuid) + add_column :comments, :paragraph_uuid add_index :comments, :paragraph_uuid end end diff --git a/lib/comment_paragraph_plugin.rb b/lib/comment_paragraph_plugin.rb index 56a13d6..6e19e89 100644 --- a/lib/comment_paragraph_plugin.rb +++ b/lib/comment_paragraph_plugin.rb @@ -40,55 +40,6 @@ class CommentParagraphPlugin < Noosfero::Plugin true end -# def cms_controller_filters -# block = proc do -# if params['commit'] == 'Save' -# -# settings = Noosfero::Plugin::Settings.new(environment, CommentParagraphPlugin, params[:settings]) -# -# extend CommentParagraphPlugin::CommentParagraphHelper -# if !@article.id.blank? && self.auto_marking_enabled?(settings, @article.class.name) -# -# parsed_paragraphs = [] -# paragraph_uuid = 0 -# -# doc = Hpricot(@article.body) -# paragraphs = doc.search("/*").each do |paragraph| -# -# if paragraph.to_html =~ /^\W<\/p>$/ -# parsed_paragraphs << paragraph.to_html -# else -# if paragraph.to_html =~ /^( 'after_filter', -# :method_name => 'new', -# :block => block } -# end - - - def self.parse_paragraph( paragraph_content, paragraph_uuid ) - "
#{paragraph_content}
\r\n" + - "

 

" - end - end require_dependency 'comment_paragraph_plugin/macros/allow_comment' diff --git a/lib/ext/article.rb b/lib/ext/article.rb index 776b6bb..dd86dd4 100644 --- a/lib/ext/article.rb +++ b/lib/ext/article.rb @@ -1,41 +1,37 @@ require_dependency 'article' +#FIXME should be specific to TextArticle? class Article has_many :paragraph_comments, :class_name => 'Comment', :foreign_key => 'source_id', :dependent => :destroy, :order => 'created_at asc', :conditions => [ 'paragraph_uuid IS NOT NULL'] - # validate :body_change_with_comments - before_save :parse_html - def body_change_with_comments - if body && body_changed? && !self.comments.empty? - paragraphs_with_comments = self.comments.where("paragraph_uuid IS NOT NULL") - errors[:base] << (N_('You are unable to change the body of the article when paragraphs are commented')) unless (paragraphs_with_comments).empty? - end + def parse_paragraph(paragraph_content, paragraph_uuid) + "
#{paragraph_content}
\r\n" + + "

 

" end - + def parse_html - if body && body_changed? + if body && body_changed? parsed_paragraphs = [] updated = body_change[1] doc = Hpricot(updated) - paragraphs = doc.search("/*").each do |paragraph| - uuid = SecureRandom.uuid + doc.search("/*").each do |paragraph| if paragraph.to_html =~ /^\W<\/p>$/ parsed_paragraphs << paragraph.to_html else if paragraph.to_html =~ /^(Comentar\ '); - $('.side-comments-counter').click(function(){ - var paragraphId = $(this).data('paragraph'); - hideAllCommentsExcept(paragraphId); + $('.comment-paragraph-plugin .side-comments-counter').click(function(){ + var container = $(this).closest('.comment-paragraph-plugin'); + var paragraphId = container.data('paragraph'); hideAllSelectedAreasExcept(paragraphId); hideCommentBox(); - $(this).closest('.comments').addClass('selected'); - $('.article-body').addClass('comment-paragraph-slide-left'); - $('#side_comment_' + paragraphId).show(); + container.addClass('comment-paragraph-slide-left selected'); + container.find('.side-comment').show(); $('#comment-bubble').removeClass('visible'); //Loads the comments - var url = $('#link_to_ajax_comments_' + paragraphId).data('url'); - $.ajax({ - dataType: "script", - url: url - }).done(function() { - var button = $('#page-comment-form-' + paragraphId + ' a').get(0); - button.click(); + var url = container.find('.side-comment').data('comment_paragraph_url'); + $.ajax(url).done(function(data) { + container.find('.article-comments-list').html(data); + if(container.find('.article-comment').length==0) { + container.find('.post_comment_box a.display-comment-form').click(); + } else { + container.find('.post_comment_box').removeClass('opened'); + container.find('.post_comment_box').addClass('closed'); + container.find('.display-comment-form').show(); + } }); }); $('#comment-bubble').click(function(event){ - $(this).hide(); - if($('.comment-paragraph-slide-left').size()==0){ - $('.article-body').addClass('comment-paragraph-slide-left'); - } - var url = $("#comment-bubble").data('url'); - var paragraphId = $("#comment-bubble").data("paragraphId"); - hideAllCommentsExcept(paragraphId); - $('#side_comment_' + paragraphId).show(); - $.ajax({ - dataType: "script", - url: url - }).done(function() { - var button = $('#page-comment-form-' + paragraphId + ' a').get(0); - button.click(); - }); + var paragraph = $("#comment-bubble").data("paragraph"); + $('#comment-paragraph-plugin_' + paragraph).find('.side-comments-counter').click(); }); - function hideAllCommentsExcept(clickedParagraph){ - $(".side-comment").each(function(){ - paragraph = $(this).data('paragraph'); - if(paragraph != clickedParagraph){ - $(this).hide(); - //$(this).find().hide(); - } - }); - } - function hideAllSelectedAreasExcept(clickedParagraph){ $(".comment_paragraph").each(function(){ - paragraph = $(this).data('paragraph'); + paragraph = $(this).closest('.comment-paragraph-plugin').data('paragraph'); if(paragraph != clickedParagraph){ $(this).find(".commented-area").contents().unwrap(); + $(this).html($(this).html()); //XXX: workaround to prevent creation of text nodes } }); } @@ -154,23 +113,20 @@ jQuery(document).ready(function($) { //highlight area from the paragraph $('.comment_paragraph').mouseup(function(event) { - if($('.comment-paragraph-slide-left').size() > 0){ - hideCommentBox(); - } + hideCommentBox(); //Don't do anything if there is no selected text if (getSelectionText().length == 0) { return; } - var paragraphId = $(this).data('paragraph'); + var container = $(this).closest('.comment-paragraph-plugin'); + var paragraphId = container.data('paragraph'); setCommentBubblePosition( event.pageX, event.pageY ); //Prepare to open the div - var url = $('#link_to_ajax_comments_' + paragraphId).data('url'); - $("#comment-bubble").data("url", url); - $("#comment-bubble").data("paragraphId", paragraphId); + $("#comment-bubble").data("paragraph", paragraphId); $("#comment-bubble").addClass('visible'); var rootElement = $(this).get(0); @@ -182,9 +138,9 @@ jQuery(document).ready(function($) { } catch(e) { return; } - form = $('#page-comment-form-' + paragraphId).find('form'); + form = container.find('.post_comment_box').find('form'); - //Register the area the has been selected at input.selected_area + //Register the area that has been selected at input.selected_area if (form.find('input.selected_area').length === 0){ $('').attr({ class: 'selected_area', @@ -216,16 +172,15 @@ jQuery(document).ready(function($) { if(anchor.length==0) return; var val = anchor.split('-'); //anchor format = #comment-\d+ if(val.length!=2 || val[0]!='#comment') return; - if($('div[data-macro=comment_paragraph_plugin\\/allow_comment]').length==0) return; //comment_paragraph_plugin/allow_comment div must exists + if($('.comment-paragraph-plugin').length==0) return; var comment_id = val[1]; if(!/^\d+$/.test(comment_id)) return; //test for integer comment_paragraph_anchor = anchor; + var url = '/plugin/comment_paragraph/public/comment_paragraph/'+comment_id; - $.ajax({ - dataType: "script", - url: url - }).done(function() { - var button = $('#page-comment-form-' + comment_id + ' a').get(0) + $.ajax(url).done(function(data) { + var button = $('#comment-paragraph-plugin_' + data.paragraph_uuid + ' .side-comments-counter').click(); + $('body').animate({scrollTop: parseInt(button.offset().top)}, 500); button.click(); }); } @@ -234,8 +189,8 @@ jQuery(document).ready(function($) { $(document).on('mouseenter', 'li.article-comment', function() { var selected_area = $(this).find('input.paragraph_comment_area').val(); - var paragraph_uuid = $(this).find('input.paragraph_uuid').val(); - var rootElement = $('#comment_paragraph_' + paragraph_uuid).get(0); + var container = $(this).closest('.comment-paragraph-plugin'); + var rootElement = container.find('.comment_paragraph')[0]; if(selected_area != ""){ rangy.deserializeSelection(selected_area, rootElement); @@ -244,30 +199,6 @@ jQuery(document).ready(function($) { }); $(document).on('mouseleave', 'li.article-comment', function() { - var paragraph_uuid = $(this).find('input.paragraph_uuid').val(); - var rootElement = $('#comment_paragraph_'+ paragraph_uuid).get(0); - - original_paragraphs.each( function(paragraph) { - if (paragraph.id == paragraph_uuid) { - rootElement.innerHTML = paragraph.content; - } - }); + hideAllSelectedAreasExcept(); }); - - function toggleParagraph(paragraph) { - var div = $('div.comments_list_toggle_paragraph_'+paragraph); - var visible = div.is(':visible'); - if(!visible) - $('div.comment-paragraph-loading-' + paragraph).addClass('comment-button-loading'); - div.toggle('fast'); - return visible; - } - - function loadCompleted(paragraph) { - $('div.comment-paragraph-loading-'+paragraph).removeClass('comment-button-loading') - if(comment_paragraph_anchor) { - $.scrollTo($(comment_paragraph_anchor)); - comment_paragraph_anchor = null; - } - } }); diff --git a/public/style.css b/public/style.css index c898e98..c14c9f9 100644 --- a/public/style.css +++ b/public/style.css @@ -9,6 +9,7 @@ width: 90px; text-decoration: none; visibility: hidden; + cursor: pointer; } div.article-comments-list-more{ @@ -99,21 +100,17 @@ div.article-comments-list-more{ } .side-comment .comment-created-at{display: none;} -.side-comment #comment_title{display: none;} -.side-comment .comment_title{display: none;} +.side-comment #comment_title, .side-comment .comment_title{display: none;} .side-comment label[for="comment_title"] {display: none;} -div[class^='comments_list_toggle_paragraph_'] { - border-style: solid; - border-width: 1px; - border-color: #e7e7e7; - padding: 5px; - background-color: whitesmoke; - width: 280px; -} - -div[class^='comment-paragraph-loading-'] { - z-index: 99; +.side-comment { + border-style: solid; + border-width: 1px; + border-color: #e7e7e7; + padding: 5px; + background-color: whitesmoke; + width: 280px; + display: none; } #content .side-comment .comment-balloon div[class^='comment-wrapper-']{ @@ -172,12 +169,12 @@ div[class^='comment-paragraph-loading-'] { left: 5px; border-style: solid; border-width: 10px 5px 0; - border-color: #bdbdbd transparent; + border-color: #b5b5b5 transparent; display: block; width: 0; } -.comment-count{ +.comment-count-container { position: relative; top: 3px; } @@ -231,9 +228,6 @@ div[class^='comment-paragraph-loading-'] { .side-comment .comment-wrapper-1 { margin-left: 36px; } -#article .side-comment .article-comments-list .comment-replies { - padding-left: 25px; -} #article .side-comment .comment-picture { width: 100%; height: auto; @@ -246,9 +240,6 @@ div[class^='comment-paragraph-loading-'] { .side-comment .formlabel[for='comment_body'] { display: none; } -.side-comment > div > div { - background: #FFFFFF; -} .side-comment .comment_form p { display: none; } @@ -257,7 +248,7 @@ div[class^='comment-paragraph-loading-'] { padding-bottom: 15px; } -.side-comment .comment-count { +.side-comment .comment-count-container { bg-color: #b3b2d4; } @@ -265,22 +256,12 @@ div[class^='comment-paragraph-loading-'] { height: 50px; } -.comment-paragraph-comments{ - background: lightblue; - padding: 5px; - width: 150px; - margin-top: 10px; - color: white; - font-weight: bold; - text-align: center; -} - .single-border{ border-style: solid; border-width: 2px; } -.comment-paragraph-slide-left .comments { +.comment-paragraph-plugin .comments { position: relative; display: table; } @@ -289,7 +270,7 @@ div[class^='comment-paragraph-loading-'] { background-color: rgb(236, 236, 236); } -.comment-paragraph-group-comments{ +.side-comment { position: absolute; right: -296px; top: 0px; @@ -297,11 +278,11 @@ div[class^='comment-paragraph-loading-'] { z-index: 199; } -.article-body.comment-paragraph-slide-left { +.comment-paragraph-plugin.comment-paragraph-slide-left { position: relative; width: 80%; } -.article-body { +.comment-paragraph-plugin { width: 100%; transition: width 0.3s ease-in-out; } @@ -320,3 +301,44 @@ div[class^='comment-paragraph-loading-'] { padding-right: 10px; margin-left: -36px; } + +.comment-paragraph-plugin .no-comments-yet .comment-count { + display: none; +} + +.comment-paragraph-plugin .no-comments-yet:after { + content: "+"; +} +#content .comment-paragraph-plugin .no-comments-yet { + font-size: 100%; + opacity: 1; +} + +#content .comment-paragraph-plugin .display-comment-form { + text-decoration: none; + color: gray; +} + +#content .comment-paragraph-plugin .display-comment-form:hover { + color: rgb(95, 95, 95); +} + +#content .comment-paragraph-plugin .side-comment .article-comments-list .comment-replies .comment-replies { + padding-left: 0; +} +#content .comment-paragraph-plugin .side-comment .article-comments-list .comment-replies { + padding-left: 25px; +} + +#content .comment-paragraph-plugin #cancel-comment, #content .comment-paragraph-plugin .icon-add { + background: none; + border: none; +} +#content .comment-paragraph-plugin #cancel-comment:hover, #content .comment-paragraph-plugin .icon-add:hover { + background: none; + color: black; + border: none; +} +#content .comment-paragraph-plugin .button-bar { + margin: 5px 0; +} diff --git a/test/functional/comment_paragraph_plugin_admin_controller_test.rb b/test/functional/comment_paragraph_plugin_admin_controller_test.rb new file mode 100644 index 0000000..4bc077c --- /dev/null +++ b/test/functional/comment_paragraph_plugin_admin_controller_test.rb @@ -0,0 +1,38 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' +require File.dirname(__FILE__) + '/../../controllers/comment_paragraph_plugin_admin_controller' + +# Re-raise errors caught by the controller. +class CommentParagraphPluginAdminController; def rescue_action(e) raise e end; end + +class CommentParagraphPluginAdminControllerTest < ActionController::TestCase + + def setup + @environment = Environment.default + user_login = create_admin_user(@environment) + login_as(user_login) + @environment.enabled_plugins = ['CommentParagraphPlugin'] + @environment.save! + @plugin_settings = Noosfero::Plugin::Settings.new(@environment, CommentParagraphPlugin) + end + + should 'access index action' do + get :index + assert_template 'index' + assert_response :success + end + + should 'update comment paragraph plugin settings' do + assert_nil @plugin_settings.get_setting(:auto_marking_article_types) + post :index, :settings => { :auto_marking_article_types => ['TinyMceArticle'] } + @environment.reload + assert_not_nil @plugin_settings.get_setting(:auto_marking_article_types) + end + + should 'get article types previously selected' do + post :index, :settings => { :auto_marking_article_types => ['TinyMceArticle', 'TextileArticle'] } + get :index + assert_tag :input, :attributes => { :value => 'TinyMceArticle' } + assert_tag :input, :attributes => { :value => 'TextileArticle' } + end + +end diff --git a/test/functional/comment_paragraph_plugin_profile_controller_test.rb b/test/functional/comment_paragraph_plugin_profile_controller_test.rb index 791e4fc..5942273 100644 --- a/test/functional/comment_paragraph_plugin_profile_controller_test.rb +++ b/test/functional/comment_paragraph_plugin_profile_controller_test.rb @@ -7,39 +7,31 @@ class CommentParagraphPluginProfileController; def rescue_action(e) raise e end; class CommentParagraphPluginProfileControllerTest < ActionController::TestCase def setup - @controller = CommentParagraphPluginProfileController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @profile = create_user('testuser').person @article = profile.articles.build(:name => 'test') @article.save! end - attr_reader :article - attr_reader :profile + attr_reader :article, :profile should 'be able to show paragraph comments' do comment = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala', :paragraph_uuid => 0) xhr :get, :view_comments, :profile => @profile.identifier, :article_id => article.id, :paragraph_uuid => 0 - assert_template 'comment_paragraph_plugin_profile/view_comments' - assert_match /comments_list_paragraph_0/, @response.body - assert_match /\"comment-count-0\", \"1\"/, @response.body + assert_select "#comment-#{comment.id}" end should 'do not show global comments' do - fast_create(Comment, :source_id => article, :author_id => profile, :title => 'global comment', :body => 'global', :paragraph_uuid => nil) - fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala', :paragraph_uuid => 0) + global_comment = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'global comment', :body => 'global', :paragraph_uuid => nil) + comment = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala', :paragraph_uuid => 0) xhr :get, :view_comments, :profile => @profile.identifier, :article_id => article.id, :paragraph_uuid => 0 - assert_template 'comment_paragraph_plugin_profile/view_comments' - assert_match /comments_list_paragraph_0/, @response.body - assert_match /\"comment-count-0\", \"1\"/, @response.body + assert_select "#comment-#{global_comment.id}", 0 + assert_select "#comment-#{comment.id}" end should 'be able to show all comments of a paragraph' do - comment1 = fast_create(Comment, :created_at => Time.now - 1.days, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'a comment', :paragraph_uuid => 0) - comment2 = fast_create(Comment, :created_at => Time.now - 2.days, :source_id => article, :author_id => profile, :title => 'b comment', :body => 'b comment', :paragraph_uuid => 0) - comment3 = fast_create(Comment, :created_at => Time.now - 3.days, :source_id => article, :author_id => profile, :title => 'c comment', :body => 'c comment', :paragraph_uuid => 0) - comment4 = fast_create(Comment, :created_at => Time.now - 4.days, :source_id => article, :author_id => profile, :title => 'd comment', :body => 'd comment', :paragraph_uuid => 0) + fast_create(Comment, :created_at => Time.now - 1.days, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'a comment', :paragraph_uuid => 0) + fast_create(Comment, :created_at => Time.now - 2.days, :source_id => article, :author_id => profile, :title => 'b comment', :body => 'b comment', :paragraph_uuid => 0) + fast_create(Comment, :created_at => Time.now - 3.days, :source_id => article, :author_id => profile, :title => 'c comment', :body => 'c comment', :paragraph_uuid => 0) + fast_create(Comment, :created_at => Time.now - 4.days, :source_id => article, :author_id => profile, :title => 'd comment', :body => 'd comment', :paragraph_uuid => 0) xhr :get, :view_comments, :profile => @profile.identifier, :article_id => article.id, :paragraph_uuid => 0 assert_match /a comment/, @response.body assert_match /b comment/, @response.body diff --git a/test/functional/comment_paragraph_plugin_public_controller_test.rb b/test/functional/comment_paragraph_plugin_public_controller_test.rb index 3f4bf32..d612fb1 100644 --- a/test/functional/comment_paragraph_plugin_public_controller_test.rb +++ b/test/functional/comment_paragraph_plugin_public_controller_test.rb @@ -8,30 +8,23 @@ class CommentParagraphPluginPublicController; def rescue_action(e) raise e end; class CommentParagraphPluginPublicControllerTest < ActionController::TestCase def setup - @controller = CommentParagraphPluginPublicController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @profile = create_user('testuser').person @article = profile.articles.build(:name => 'test') @article.save! end - attr_reader :article - attr_reader :profile - + attr_reader :article, :profile should 'be able to return paragraph_uuid for a comment' do comment = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala', :paragraph_uuid => 0) cid = comment.id xhr :get, :comment_paragraph, :id => cid - assert_match /\{\"paragraph_uuid\":0\}/, @response.body + assert_equal({'paragraph_uuid' => '0'}, ActiveSupport::JSON.decode(@response.body)) end should 'return paragraph_uuid=null for a global comment' do comment = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala' ) xhr :get, :comment_paragraph, :id => comment.id - assert_match /\{\"paragraph_uuid\":null\}/, @response.body + assert_equal({'paragraph_uuid' => nil}, ActiveSupport::JSON.decode(@response.body)) end - end diff --git a/test/functional/comment_paragraph_plugin_test.rb b/test/functional/comment_paragraph_plugin_test.rb deleted file mode 100644 index 4bc077c..0000000 --- a/test/functional/comment_paragraph_plugin_test.rb +++ /dev/null @@ -1,38 +0,0 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' -require File.dirname(__FILE__) + '/../../controllers/comment_paragraph_plugin_admin_controller' - -# Re-raise errors caught by the controller. -class CommentParagraphPluginAdminController; def rescue_action(e) raise e end; end - -class CommentParagraphPluginAdminControllerTest < ActionController::TestCase - - def setup - @environment = Environment.default - user_login = create_admin_user(@environment) - login_as(user_login) - @environment.enabled_plugins = ['CommentParagraphPlugin'] - @environment.save! - @plugin_settings = Noosfero::Plugin::Settings.new(@environment, CommentParagraphPlugin) - end - - should 'access index action' do - get :index - assert_template 'index' - assert_response :success - end - - should 'update comment paragraph plugin settings' do - assert_nil @plugin_settings.get_setting(:auto_marking_article_types) - post :index, :settings => { :auto_marking_article_types => ['TinyMceArticle'] } - @environment.reload - assert_not_nil @plugin_settings.get_setting(:auto_marking_article_types) - end - - should 'get article types previously selected' do - post :index, :settings => { :auto_marking_article_types => ['TinyMceArticle', 'TextileArticle'] } - get :index - assert_tag :input, :attributes => { :value => 'TinyMceArticle' } - assert_tag :input, :attributes => { :value => 'TextileArticle' } - end - -end diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb index b83340e..c95d19c 100644 --- a/test/unit/article_test.rb +++ b/test/unit/article_test.rb @@ -22,5 +22,4 @@ class ArticleTest < ActiveSupport::TestCase assert article.save end - end diff --git a/test/unit/comment_test.rb b/test/unit/comment_test.rb index c9d83f2..0ee3f57 100644 --- a/test/unit/comment_test.rb +++ b/test/unit/comment_test.rb @@ -10,16 +10,16 @@ class CommentTest < ActiveSupport::TestCase attr_reader :article should 'return comments that belongs to a specified paragraph' do - comment1 = fast_create(Comment, :paragraph_uuid => 1, :source_id => article.id) + comment1 = fast_create(Comment, :paragraph_uuid => '1', :source_id => article.id) comment2 = fast_create(Comment, :paragraph_uuid => nil, :source_id => article.id) - comment3 = fast_create(Comment, :paragraph_uuid => 2, :source_id => article.id) - assert_equal [comment1], article.comments.in_paragraph(1) + comment3 = fast_create(Comment, :paragraph_uuid => '2', :source_id => article.id) + assert_equal [comment1], article.comments.in_paragraph('1') end should 'return comments that do not belongs to any paragraph' do - comment1 = fast_create(Comment, :paragraph_uuid => 1, :source_id => article.id) + comment1 = fast_create(Comment, :paragraph_uuid => '1', :source_id => article.id) comment2 = fast_create(Comment, :paragraph_uuid => nil, :source_id => article.id) - comment3 = fast_create(Comment, :paragraph_uuid => 2, :source_id => article.id) + comment3 = fast_create(Comment, :paragraph_uuid => '2', :source_id => article.id) assert_equal [comment2], article.comments.without_paragraph end diff --git a/views/comment_paragraph_plugin_profile/_comment_paragraph.html.erb b/views/comment_paragraph_plugin_profile/_comment_paragraph.html.erb index 9b8848f..131353c 100644 --- a/views/comment_paragraph_plugin_profile/_comment_paragraph.html.erb +++ b/views/comment_paragraph_plugin_profile/_comment_paragraph.html.erb @@ -1,48 +1,24 @@ -
-
+
+
<%= inner_html %>
-
- - <%= count %> +
+ '> + <%= count %>
-
- <%= - url = { :profile => profile_identifier, :controller => 'comment_paragraph_plugin_profile', :action => 'view_comments', :paragraph_uuid => paragraph_uuid, :article_id => article_id} - link_to_remote( - '', - { - :url => url, - :method => :post, - :condition => "!toggleParagraph(#{paragraph_uuid})", - :complete => "loadCompleted(#{paragraph_uuid})" - }, - { - :id => "link_to_ajax_comments_#{paragraph_uuid}", - :'data-url' => url_for(url) - } - )%> - -
- - - - - diff --git a/views/comment_paragraph_plugin_profile/view_comments.rjs b/views/comment_paragraph_plugin_profile/view_comments.rjs deleted file mode 100644 index 736a028..0000000 --- a/views/comment_paragraph_plugin_profile/view_comments.rjs +++ /dev/null @@ -1,2 +0,0 @@ -page.replace_html "comments_list_paragraph_#{@paragraph_uuid}", :partial => 'comment/comment.html.erb', :collection => @comments -page.replace_html "comment-count-#{@paragraph_uuid}", @comments_count -- libgit2 0.21.2