diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 5731244c3..226d24afa 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -47,6 +47,9 @@ class MessagesController < ApplicationController all_comments = [] @replies = get_all_children(all_comments, @topic) @reply_count = @replies.count + @page = params[:page] ? params[:page].to_i + 1 : 0 + @limit = 10 + @replies = @replies[@page * @limit..@page * @limit + 9] @reply = Message.new(:subject => "RE: #{@message.subject}") if @course #@replies = @topic.children. @@ -57,7 +60,11 @@ class MessagesController < ApplicationController #all #@replies = paginateHelper messages_replies,10 @left_nav_type = 2 - render :action => "show", :layout => "base_courses"#by young + respond_to do |format| + format.js + format.html {render :layout => 'base_courses'} + end + #render :action => "show", :layout => "base_courses"#by young elsif @project #@reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page # @replies = @topic.children. @@ -66,8 +73,10 @@ class MessagesController < ApplicationController # limit(@reply_pages.per_page). # offset(@reply_pages.offset). # all - - render :action => "show", :layout => "base_projects"#by young + respond_to do |format| + format.js + format.html {render :layout => 'base_projects'} + end else # @reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page # @replies = @topic.children. @@ -78,7 +87,10 @@ class MessagesController < ApplicationController # all @organization = @org_subfield.organization - render :action => "show", :layout => "base_org"#by young + respond_to do |format| + format.js + format.html {render :layout => 'base_org'} + end end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2c427bbea..c3e0bee54 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3244,17 +3244,32 @@ def get_reply_parents_no_root parents_rely, comment parents_rely end +def get_all_children_ex result, jour + if jour.kind_of? Message + jour.children.includes(:author, :praise_tread_cache).each do |jour_child| + result << jour_child + get_all_children_ex result, jour_child + end + elsif (jour.kind_of? JournalsForMessage) || (jour.kind_of? BlogComment) || (jour.kind_of? OrgDocumentComment) + jour.children.each do |jour_child| + result << jour_child + get_all_children_ex result, jour_child + end + end + result +end + #获取所有子节点 def get_all_children result, jour if jour.kind_of? Message jour.children.includes(:author, :praise_tread_cache).each do |jour_child| result << jour_child - get_all_children result, jour_child + get_all_children_ex result, jour_child end elsif (jour.kind_of? JournalsForMessage) || (jour.kind_of? BlogComment) || (jour.kind_of? OrgDocumentComment) jour.children.each do |jour_child| result << jour_child - get_all_children result, jour_child + get_all_children_ex result, jour_child end end if jour.respond_to?(:created_on) diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb index abdeef255..80661078a 100644 --- a/app/views/messages/_course_show.html.erb +++ b/app/views/messages/_course_show.html.erb @@ -95,58 +95,8 @@ <%# all_comments = []%> <%# comments = get_all_children(all_comments, @topic) %> -
- <% @replies.each do |reply| %> - -
-
- <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %> -
-
- <%= render :partial => 'users/message_contents', :locals => {:comment => reply}%> - -
- <%= reply.content.html_safe%> -
-
-
- - - <%= render :partial => "praise_tread/praise", :locals => {:activity => reply, :user_activity_id => reply.id, :type => "reply"} %> - - - <%= link_to( - l(:button_reply), - {:action => 'quote', :id => reply}, - :remote => true, - :method => 'get', - :title => l(:button_reply)) if !@topic.locked? && authorize_for('messages', 'reply') %> - - - <%= link_to( - l(:button_delete), - {:action => 'destroy', :id => reply}, - :method => :post, - :id => "delete_reply_#{reply.id}", - :class => 'fr mr20 undis', - :data => {:confirm => l(:text_are_you_sure)}, - :title => l(:button_delete) - ) if reply.course_destroyable_by?(User.current) %> - - -
-
-
-

-
-
-
- <% end %> +
+ <%= render :partial => "messages/course_show_replies" %>
diff --git a/app/views/messages/_course_show_replies.html.erb b/app/views/messages/_course_show_replies.html.erb new file mode 100644 index 000000000..ad715df20 --- /dev/null +++ b/app/views/messages/_course_show_replies.html.erb @@ -0,0 +1,60 @@ +<% @replies.each do |reply| %> + +
+
+ <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %> +
+
+ <%= render :partial => 'users/message_contents', :locals => {:comment => reply}%> + +
+ <%= reply.content.html_safe%> +
+
+
+ + + <%= render :partial => "praise_tread/praise", :locals => {:activity => reply, :user_activity_id => reply.id, :type => "reply"} %> + + + <%= link_to( + l(:button_reply), + {:action => 'quote', :id => reply}, + :remote => true, + :method => 'get', + :title => l(:button_reply)) if !@topic.locked? && authorize_for('messages', 'reply') %> + + + <%= link_to( + l(:button_delete), + {:action => 'destroy', :id => reply}, + :method => :post, + :id => "delete_reply_#{reply.id}", + :class => 'fr mr20 undis', + :data => {:confirm => l(:text_are_you_sure)}, + :title => l(:button_delete) + ) if reply.course_destroyable_by?(User.current) %> + + +
+
+
+

+
+
+
+<% end %> +<% if @reply_count > @page * @limit + 10 %> +
+
+ + + <%= link_to '点击展开更多回复', board_message_path(@topic.board_id, @topic, :page => @page),:remote=>true %> +
+
+<% end %> \ No newline at end of file diff --git a/app/views/messages/_org_show_replies.html.erb b/app/views/messages/_org_show_replies.html.erb new file mode 100644 index 000000000..fbde35fcf --- /dev/null +++ b/app/views/messages/_org_show_replies.html.erb @@ -0,0 +1,59 @@ +<% @replies.each_with_index do |reply, i| %> + +
+
+ <%= link_to image_tag(url_to_avatar(reply.author), :width => 33, :height => 33), user_path(reply.author) %> +
+
+ <%= render :partial => 'users/message_contents', :locals => {:comment => reply} %> + +
+ <%= reply.content.html_safe %> +
+
+
+ + + <%= render :partial => "praise_tread/praise", :locals => {:activity => reply, :user_activity_id => reply.id, :type => "reply"} %> + + + <%= link_to( + l(:button_reply), + {:action => 'quote', :id => reply}, + :remote => true, + :method => 'get', + :title => l(:button_reply)) if !@topic.locked? && authorize_for('messages', 'reply') %> + + + <%= link_to( + l(:button_delete), + {:action => 'destroy', :id => reply}, + :method => :post, + :class => 'fr mr20', + :data => {:confirm => l(:text_are_you_sure)}, + :title => l(:button_delete) + ) if reply.course_destroyable_by?(User.current) %> + + +
+
+
+

+
+
+
+<% end %> +<% if @reply_count > @page * @limit + 10 %> +
+
+ + + <%= link_to '点击展开更多回复', board_message_path(@topic.board_id, @topic, :page => @page),:remote=>true %> +
+
+<% end %> \ No newline at end of file diff --git a/app/views/messages/_org_subfield_show.html.erb b/app/views/messages/_org_subfield_show.html.erb index 6b6983bb1..19e8b30d5 100644 --- a/app/views/messages/_org_subfield_show.html.erb +++ b/app/views/messages/_org_subfield_show.html.erb @@ -130,56 +130,7 @@ <%# all_comments = [] %> <%# comments = get_all_children(all_comments, @topic) %>
- <% @replies.each_with_index do |reply, i| %> - -
-
- <%= link_to image_tag(url_to_avatar(reply.author), :width => 33, :height => 33), user_path(reply.author) %> -
-
- <%= render :partial => 'users/message_contents', :locals => {:comment => reply} %> - -
- <%= reply.content.html_safe %> -
-
-
- - - <%= render :partial => "praise_tread/praise", :locals => {:activity => reply, :user_activity_id => reply.id, :type => "reply"} %> - - - <%= link_to( - l(:button_reply), - {:action => 'quote', :id => reply}, - :remote => true, - :method => 'get', - :title => l(:button_reply)) if !@topic.locked? && authorize_for('messages', 'reply') %> - - - <%= link_to( - l(:button_delete), - {:action => 'destroy', :id => reply}, - :method => :post, - :class => 'fr mr20', - :data => {:confirm => l(:text_are_you_sure)}, - :title => l(:button_delete) - ) if reply.course_destroyable_by?(User.current) %> - - -
-
-
-

-
-
-
- <% end %> + <%= render :partial => "messages/org_show_replies" %>
<% end %> diff --git a/app/views/messages/_project_show.html.erb b/app/views/messages/_project_show.html.erb index f46d70ad2..e7d12c3d3 100644 --- a/app/views/messages/_project_show.html.erb +++ b/app/views/messages/_project_show.html.erb @@ -160,57 +160,7 @@ <%# all_comments = []%> <%# comments = get_all_children(all_comments, @topic) %>
- <% @replies.each_with_index do |reply,i| %> - -
-
- <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %> -
-
- <%= render :partial => 'users/message_contents', :locals => {:comment => reply}%> - -
- <%= reply.content.html_safe%> -
-
-
- - - <%= render :partial => "praise_tread/praise", :locals => {:activity => reply, :user_activity_id => reply.id, :type => "reply"} %> - - - <%= link_to( - l(:button_reply), - {:action => 'quote', :id => reply}, - :remote => true, - :method => 'get', - :title => l(:button_reply)) if !@topic.locked? && authorize_for('messages', 'reply') %> - - - <%= link_to( - l(:button_delete), - {:action => 'destroy', :id => reply}, - :method => :post, - :id => "delete_reply_#{reply.id}", - :class => 'fr mr20 undis', - :data => {:confirm => l(:text_are_you_sure)}, - :title => l(:button_delete) - ) if reply.destroyable_by?(User.current) %> - - -
-
-
-

-
-
-
- <% end %> + <%= render :partial => "messages/project_show_replies" %>
<% if !@topic.locked? && authorize_for('messages', 'reply') %> diff --git a/app/views/messages/_project_show_replies.html.erb b/app/views/messages/_project_show_replies.html.erb new file mode 100644 index 000000000..ea0b64069 --- /dev/null +++ b/app/views/messages/_project_show_replies.html.erb @@ -0,0 +1,60 @@ +<% @replies.each_with_index do |reply,i| %> + +
+
+ <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %> +
+
+ <%= render :partial => 'users/message_contents', :locals => {:comment => reply}%> + +
+ <%= reply.content.html_safe%> +
+
+
+ + + <%= render :partial => "praise_tread/praise", :locals => {:activity => reply, :user_activity_id => reply.id, :type => "reply"} %> + + + <%= link_to( + l(:button_reply), + {:action => 'quote', :id => reply}, + :remote => true, + :method => 'get', + :title => l(:button_reply)) if !@topic.locked? && authorize_for('messages', 'reply') %> + + + <%= link_to( + l(:button_delete), + {:action => 'destroy', :id => reply}, + :method => :post, + :id => "delete_reply_#{reply.id}", + :class => 'fr mr20 undis', + :data => {:confirm => l(:text_are_you_sure)}, + :title => l(:button_delete) + ) if reply.destroyable_by?(User.current) %> + + +
+
+
+

+
+
+
+<% end %> +<% if @reply_count > @page * @limit + 10 %> +
+
+ + + <%= link_to '点击展开更多回复', board_message_path(@topic.board_id, @topic, :page => @page),:remote=>true %> +
+
+<% end %> \ No newline at end of file diff --git a/app/views/messages/show.js.erb b/app/views/messages/show.js.erb new file mode 100644 index 000000000..fcfaa3858 --- /dev/null +++ b/app/views/messages/show.js.erb @@ -0,0 +1,7 @@ +<% if @project %> +$("#more_message_replies").replaceWith("<%= escape_javascript(render :partial => 'messages/project_show_replies')%>"); +<% elsif @course %> +$("#more_message_replies").replaceWith("<%= escape_javascript(render :partial => 'messages/course_show_replies')%>"); +<% else %> +$("#more_message_replies").replaceWith("<%= escape_javascript(render :partial => 'messages/org_show_replies')%>"); +<% end %> \ No newline at end of file diff --git a/public/stylesheets/css/public.css b/public/stylesheets/css/public.css index d4cce2679..cce278668 100644 --- a/public/stylesheets/css/public.css +++ b/public/stylesheets/css/public.css @@ -1403,6 +1403,7 @@ a:hover.comment_ding_link{ color:#269ac9;} .orig_icon{ color:#888; margin-right:10px; font-size:14px; font-weight:bold;} .relateText {font-size:16px; color:#269ac9; line-height:16px; padding-top:20px; display:inline-block; font-weight: bold;} +.detail_cont_hide{ text-align:center; width:690px; display:block; font-size:14px; color:#333; border-bottom:1px solid #e3e3e3; padding:8px 0; margin: 0px auto;} /* 未登录的提示信息 */ .syllabusbox_tishi{