diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 29e6a4980..c1f5863b8 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -87,7 +87,10 @@ class UsersController < ApplicationController #展开所有回复 def show_all_replies - @comment = JournalsForMessage.find params[:comment].to_i + case params[:type] + when 'JournalsForMessage' + @comment = JournalsForMessage.find params[:comment].to_i + end end #二级回复 @@ -95,6 +98,7 @@ class UsersController < ApplicationController case params[:type] when 'HomeworkCommon' @reply = JournalsForMessage.find params[:reply_id] + @type = 'HomeworkCommon' if params[:user_activity_id] @user_activity_id = params[:user_activity_id] else @@ -102,6 +106,11 @@ class UsersController < ApplicationController end @is_in_course = params[:is_in_course].to_i @course_activity = params[:course_activity].to_i + when 'JournalsForMessage' + @reply = JournalsForMessage.find params[:reply_id] + @user_activity_id = params[:user_activity_id] + @activity_id = params[:activity_id] + @type = 'JournalsForMessage' end respond_to do |format| format.js @@ -3261,7 +3270,11 @@ class UsersController < ApplicationController @journals = obj.comments.reorder("created_on desc") when 'JournalsForMessage' obj = JournalsForMessage.where('id = ?', params[:id].to_i).first - @journals = obj.children.reorder("created_on desc") + journals = [] + @journals = get_all_children(journals, obj) + @type = 'JournalsForMessage' + @user_activity_id = params[:div_id].to_i if params[:div_id] + @allow_delete = params[:allow_delete] when 'Issue' obj = Issue.where('id = ?', params[:id].to_i).first @journals = obj.journals.reorder("created_on desc") diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 22b7f1f52..668269a26 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -54,15 +54,16 @@ class WordsController < ApplicationController :reply_id => reply_user_id, :notes => content, :is_readed => false} - @jfm = add_reply_adapter options + @activity = params[:activity_id].nil? ? JournalsForMessage.find(parent_id) : JournalsForMessage.find(params[:activity_id].to_i) + @jfm = add_reply_adapter(@activity, options) @save_succ = true if @jfm.errors.empty? if @save_succ - update_course_activity('JournalsForMessage',parent_id) - update_user_activity('JournalsForMessage',parent_id) - update_forge_activity('JournalsForMessage',parent_id) - update_org_activity('JournalsForMessage',parent_id) - update_principal_activity('JournalsForMessage',parent_id) - (JournalsForMessage.find parent_id).update_attribute(:updated_on,Time.now) + update_course_activity('JournalsForMessage',@activity.id) + update_user_activity('JournalsForMessage',@activity.id) + update_forge_activity('JournalsForMessage',@activity.id) + update_org_activity('JournalsForMessage',@activity.id) + update_principal_activity('JournalsForMessage',@activity.id) + @activity.update_attribute(:updated_on,Time.now) end respond_to do |format| # format.html { @@ -76,8 +77,6 @@ class WordsController < ApplicationController format.js { #@reply_type = params[:reply_type] @user_activity_id = params[:user_activity_id] - @activity = JournalsForMessage.find(parent_id) - @is_activity = params[:is_activity] if params[:is_activity] } end @@ -92,13 +91,14 @@ class WordsController < ApplicationController elsif @journal_destroyed.jour_type == "Course" @course = Course.find @journal_destroyed.jour_id @jours_count = @course.journals_for_messages.where('m_parent_id IS NULL').count + @user_activity_id = params[:user_activity_id] if params[:user_activity_id] + @activity = JournalsForMessage.where("id = #{params[:activity_id].to_i}").first if params[:activity_id] elsif @journal_destroyed.jour_type == "Principal" @user = User.find(@journal_destroyed.jour_id) @jours_count = @user.journals_for_messages.where('m_parent_id IS NULL').count @is_user = true @user_activity_id = params[:user_activity_id] if params[:user_activity_id] - @is_activity = params[:is_activity].to_i if params[:is_activity] - @activity = @journal_destroyed.parent if @journal_destroyed.parent + @activity = JournalsForMessage.where("id = #{params[:activity_id].to_i}").first if params[:activity_id] unless @activity redirect_to feedback_path(@user) return @@ -374,28 +374,44 @@ class WordsController < ApplicationController obj end - def add_reply_adapter options + def add_reply_adapter obj, options #modify by nwb #添加对课程留言的支持 #留言回复应该不关系其所属的Class,而关心的是其所属的父留言 - obj = obj_distinguish_url_origin || User.find_by_id(2) - if obj.kind_of? User - obj.add_jour(nil, nil, nil, options) - elsif obj.kind_of? Project - Project.add_new_jour(nil, nil, obj.id, options) - elsif obj.kind_of? Course - Course.add_new_jour(nil, nil, obj.id, options) - elsif obj.kind_of? Bid - obj.add_jour(nil, nil, nil, options) - elsif obj.kind_of? Contest - obj.add_jour(nil, nil, obj.id, options) #new added - elsif obj.kind_of? Softapplication - obj.add_jour(nil, nil, obj.id, options) #new added - elsif obj.kind_of? HomeworkAttach - obj.add_jour(nil, nil, obj.id, options) #new added - else - raise "create reply obj unknow type.#{obj.class}" + case obj.jour_type + when 'Principal' + obj.jour.add_jour(nil, nil, nil, options) + when 'Project' + Project.add_new_jour(nil, nil, obj.jour_id, options) + when 'Course' + Course.add_new_jour(nil, nil, obj.jour_id, options) + when 'Bid' + obj.jour.add_jour(nil, nil, nil, options) + when 'Contest' + obj.jour.add_jour(nil, nil, obj.jour_id, options) + when 'Softapplication' + obj.jour.add_jour(nil, nil, obj.jour_id, options) + when 'HomeworkAttach' + obj.jour.add_jour(nil, nil, obj.jour_id, options) end + # obj = obj_distinguish_url_origin || User.find_by_id(2) + # if obj.kind_of? User + # obj.add_jour(nil, nil, nil, options) + # elsif obj.kind_of? Project + # Project.add_new_jour(nil, nil, obj.id, options) + # elsif obj.kind_of? Course + # Course.add_new_jour(nil, nil, obj.id, options) + # elsif obj.kind_of? Bid + # obj.add_jour(nil, nil, nil, options) + # elsif obj.kind_of? Contest + # obj.add_jour(nil, nil, obj.id, options) #new added + # elsif obj.kind_of? Softapplication + # obj.add_jour(nil, nil, obj.id, options) #new added + # elsif obj.kind_of? HomeworkAttach + # obj.add_jour(nil, nil, obj.id, options) #new added + # else + # raise "create reply obj unknow type.#{obj.class}" + # end end #######end of message end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 46fdb02f3..2552a6e84 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3127,6 +3127,26 @@ def get_reply_parents parents_rely, comment parents_rely end +#获取回复的所有父节点(不包括根节点) +def get_reply_parents_no_root parents_rely, comment + if !comment.parent.nil? && !comment.parent.parent.nil? + parents_rely << comment.parent + get_reply_parents_no_root parents_rely, comment.parent + end + parents_rely +end + +#获取留言的所有子节点 +def get_all_children result, jour + if jour.kind_of? JournalsForMessage + jour.children.each do |jour_child| + result << jour_child + get_all_children result, jour_child + end + end + result.sort! { |a,b| b.created_on <=> a.created_on } +end + #将有置顶属性的提到数组前面 def sort_by_sticky topics tmpTopics = [] diff --git a/app/views/users/_all_replies.html.erb b/app/views/users/_all_replies.html.erb index 20a3289ff..45404ed84 100644 --- a/app/views/users/_all_replies.html.erb +++ b/app/views/users/_all_replies.html.erb @@ -13,7 +13,7 @@
<%= link_to comment.creator_user.show_name, user_url_in_org(comment.creator_user.id), :class => "newsBlue mr10 f14" %> - <%= format_activity_day(comment.created_time) %> <%= format_time(comment.created_time, false) %> + <%= time_from_now(comment.created_on) %> <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> diff --git a/app/views/users/_comment_reply_detail.html.erb b/app/views/users/_comment_reply_detail.html.erb index caac3ee62..4ced798d0 100644 --- a/app/views/users/_comment_reply_detail.html.erb +++ b/app/views/users/_comment_reply_detail.html.erb @@ -1,20 +1,9 @@ -
<%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33"), user_path(comment.user_id), :alt => "用户头像" %>
-<% if comment.try(:user).try(:realname) == ' ' %> - <%= link_to comment.try(:user), user_path(comment.user_id), :class => "content-username" %> -<% else %> - <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "content-username" %> -<% end %> -<%= time_from_now(comment.created_on) %> -
<%= comment.notes.html_safe %>
+ <%= link_to comment.user.show_name, user_path(comment.user_id), :class => "content-username" %> + <%= time_from_now(comment.created_on) %> +
<%= comment.notes.html_safe %>
\ No newline at end of file diff --git a/app/views/users/_course_journalsformessage.html.erb b/app/views/users/_course_journalsformessage.html.erb index 85e0e9335..83519b1b1 100644 --- a/app/views/users/_course_journalsformessage.html.erb +++ b/app/views/users/_course_journalsformessage.html.erb @@ -38,14 +38,18 @@
- <% count = fetch_user_leaveWord_reply(activity).count %> + <% all_comments = []%> + <% count=get_all_children(all_comments, activity).count %> + <% allow_delete = (activity.user == User.current || User.current.admin? || User.current.allowed_to?(:as_teacher,activity.course)) %> + <%# count = fetch_user_leaveWord_reply(activity).count %>
- <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> + <%= render :partial => 'users/journal_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :allow_delete => allow_delete} %> - <% comments = activity.children.reorder("created_on desc").limit(3) %> + <% all_comments = []%> + <% comments = get_all_children(all_comments, activity)[0..2] %> <% if count > 0 %>
- <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%> + <%= render :partial => 'users/journal_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'JournalsForMessage', :allow_delete => allow_delete, :activity_id =>activity.id}%>
<% end %> diff --git a/app/views/users/_homework_replies.html.erb b/app/views/users/_homework_replies.html.erb index 7f4dc379b..285d464b1 100644 --- a/app/views/users/_homework_replies.html.erb +++ b/app/views/users/_homework_replies.html.erb @@ -12,11 +12,7 @@
- <% if comment.try(:user).try(:realname) == ' ' %> - <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> - <% else %> - <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> - <% end %> + <%= link_to comment.user.show_name, user_path(comment.user_id), :class => "newsBlue mr10 f14" %> <%= time_from_now(comment.created_on) %>
<% unless comment.m_parent_id.nil? %> @@ -37,7 +33,7 @@
- <%= link_to '点击展开隐藏楼层', show_all_replies_users_path(:comment => comment),:remote=>true %> + <%= link_to '点击展开隐藏楼层', show_all_replies_users_path(:comment => comment, :type => comment.class),:remote=>true %>
<%=render :partial => 'users/comment_reply_detail', :locals => {:comment => parents_rely[0]} %>
@@ -45,7 +41,8 @@ <% end %>
- <%= comment.notes.html_safe %>
+ <%= comment.notes.html_safe %> +
diff --git a/app/views/users/_journal_comment_reply.html.erb b/app/views/users/_journal_comment_reply.html.erb new file mode 100644 index 000000000..9906abeb5 --- /dev/null +++ b/app/views/users/_journal_comment_reply.html.erb @@ -0,0 +1,8 @@ +
+ <% if !comment.parent.nil? && !comment.parent.parent.nil? %> +
+ <%=render :partial => 'users/journal_comment_reply', :locals => {:comment => comment.parent} %> +
+ <% end %> + <%=render :partial => 'users/comment_reply_detail', :locals => {:comment => comment} %> +
\ No newline at end of file diff --git a/app/views/users/_journal_replies.html.erb b/app/views/users/_journal_replies.html.erb new file mode 100644 index 000000000..7fc708ebb --- /dev/null +++ b/app/views/users/_journal_replies.html.erb @@ -0,0 +1,85 @@ +
    + <% comments.each do |comment| %> + +
  • +
    + <%= link_to image_tag(url_to_avatar(comment.creator_user), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_user.id) %> +
    +
    +
    + <%= link_to comment.creator_user.show_name, user_url_in_org(comment.creator_user.id), :class => "newsBlue mr10 f14" %> + <%= time_from_now(comment.created_on) %> +
    + <% if !comment.parent.nil? && !comment.parent.parent.nil? %> + <% parents_rely = [] %> + <% parents_rely = get_reply_parents_no_root parents_rely, comment %> + <% length = parents_rely.length %> +
    + <% if length <= 3 %> + <%=render :partial => 'users/journal_comment_reply', :locals => {:comment => comment.parent} %> + <% else %> +
    +
    +
    + <%=render :partial => 'users/journal_comment_reply', :locals => {:comment => parents_rely[length - 1]} %> +
    + <%=render :partial => 'users/comment_reply_detail', :locals => {:comment => parents_rely[length - 2]} %> +
    +
    + + + <%= link_to '点击展开隐藏楼层', show_all_replies_users_path(:comment => comment, :type => comment.class),:remote=>true %> +
    + <%=render :partial => 'users/comment_reply_detail', :locals => {:comment => parents_rely[0]} %> +
    + <% end %> +
    + <% end %> + <% if !comment.content_detail.blank? || comment.class == Journal %> +
    + <% if comment.class == Journal %> + <% if comment.details.any? %> + <% details_to_strings(comment.details).each do |string| %> +

    <%= string %>

    + <% end %> + <% end %> +

    <%= comment.notes.html_safe %>

    + <% else %> + <%= comment.content_detail.html_safe %> + <% end %> +
    +
    +
    + + + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> + + + <%= link_to( + l(:button_reply), + {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => type, :user_activity_id => user_activity_id, :activity_id => activity_id}, + :remote => true, + :method => 'get', + :title => l(:button_reply)) %> + + + <% if allow_delete %> + <%= link_to('删除', {:controller => 'words', :action => 'destroy', :object_id => comment, :user_id => comment.user, :user_activity_id => user_activity_id, :activity_id => activity_id}, + :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "fr mr20", :title => l(:button_delete)) %> + <% end %> + +
    +
    +
    +

    + <% end %> +
    +
    +
  • + <% end %> +
\ No newline at end of file diff --git a/app/views/users/_journal_reply_banner.html.erb b/app/views/users/_journal_reply_banner.html.erb new file mode 100644 index 000000000..31934328f --- /dev/null +++ b/app/views/users/_journal_reply_banner.html.erb @@ -0,0 +1,18 @@ +
+
+ 回复 + ︿ + <%= count>0 ? "(#{count})" : "" %> + + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + +
+
<%#= format_date(activity.updated_on) %>
+ <%if count>3 %> + + <% end %> +
\ No newline at end of file diff --git a/app/views/users/_reply_to.html.erb b/app/views/users/_reply_to.html.erb index 23090265c..fd56eb712 100644 --- a/app/views/users/_reply_to.html.erb +++ b/app/views/users/_reply_to.html.erb @@ -1,19 +1,36 @@
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
+
+ <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %> +
<% if User.current.logged? %>
- <%= form_for('new_form',:url => {:controller => 'words', :action => 'reply_to_homework', :id => reply.id},:method => "post", :remote => true) do |f| %> - > - > - > - -
- - -
-

- <% end%> + <% if @type == 'HomeworkCommon' %> + <%= form_for('new_form',:url => {:controller => 'words', :action => 'reply_to_homework', :id => reply.id},:method => "post", :remote => true) do |f| %> + > + > + > + +
+ + +
+

+ <% end%> + <% elsif @type == 'JournalsForMessage' %> + <%= form_for('new_form',:url => {:controller => 'words', :action => 'create_reply', :id => reply.id}, :method => "post", :remote => true) do |f|%> + <%= hidden_field_tag 'reference_id', params[:reference_id], :value => reply.id %> + <%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => reply.user.id %> + <%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => reply.id %> + <%= hidden_field_tag 'show_name',params[:show_name],:value =>true %> + <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>@user_activity_id %> + <%= hidden_field_tag 'activity_id',params[:activity_id],:value =>@activity_id %> +
+ + +
+ <% end%> + <% end %>
<% else %> <%= render :partial => "users/show_unlogged" %> diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index 3b327c080..5d06a7001 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -86,7 +86,7 @@ <% case user_activity.act_type.to_s %> <% when 'JournalsForMessage' %> <% unless act.private == 1 && (!User.current || (User.current && act.jour_id != User.current.id && act.user_id != User.current.id)) %> - <%= render :partial => 'user_journalsformessage', :locals => {:activity => act,:user_activity_id =>user_activity.id,:is_activity=>1} %> + <%= render :partial => 'user_journalsformessage', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> <% end %> <% end %> <% when 'Blog'%> diff --git a/app/views/users/_user_journalsformessage.html.erb b/app/views/users/_user_journalsformessage.html.erb index dd36d1328..4fb79ee2d 100644 --- a/app/views/users/_user_journalsformessage.html.erb +++ b/app/views/users/_user_journalsformessage.html.erb @@ -50,7 +50,7 @@
  • <%= link_to(l(:label_bid_respond_delete), - {:controller => 'words', :action => 'destroy', :object_id => activity, :user_id => activity.user,:user_activity_id => user_activity_id,:is_activity=>is_activity}, + {:controller => 'words', :action => 'destroy', :object_id => activity, :user_id => activity.user,:user_activity_id => user_activity_id, :activity_id => activity.id}, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "postOptionLink", :title => l(:button_delete)) %>
  • @@ -62,14 +62,17 @@
- <% count=fetch_user_leaveWord_reply(activity).count %> + <% all_comments = []%> + <% count=get_all_children(all_comments, activity).count %> + <% allow_delete = (activity.user == User.current || User.current.admin?) %>
- <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> + <%= render :partial => 'users/journal_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :allow_delete => allow_delete} %> - <% comments = activity.children.reorder("created_on desc").limit(3) %> + <% all_comments = []%> + <% comments = get_all_children(all_comments, activity)[0..2] %> <% if count > 0 %>
- <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%> + <%= render :partial => 'users/journal_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'JournalsForMessage', :allow_delete => allow_delete, :activity_id =>activity.id}%>
<% end %> @@ -84,7 +87,6 @@ <%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => activity.id %> <%= hidden_field_tag 'show_name',params[:show_name],:value =>true %> <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %> - <%= hidden_field_tag 'is_activity',params[:is_activity],:value =>is_activity %>
diff --git a/app/views/users/_user_jours_list.html.erb b/app/views/users/_user_jours_list.html.erb index 6211aac7d..517d66038 100644 --- a/app/views/users/_user_jours_list.html.erb +++ b/app/views/users/_user_jours_list.html.erb @@ -11,7 +11,7 @@ sd_create_editor_from_data(<%= jour.id%>, null, "100%", "<%=jour.class.to_s%>"); }); - <%= render :partial => 'user_journalsformessage', :locals => {:activity => jour,:user_activity_id =>jour.id,:is_activity=>0} %> + <%= render :partial => 'user_journalsformessage', :locals => {:activity => jour,:user_activity_id =>jour.id} %> <%#= render :partial => 'user_jours_new', :locals => {:jour => jour} %> <% end %> <%end%> diff --git a/app/views/users/all_journals.js.erb b/app/views/users/all_journals.js.erb index c18c6aae4..d4c42368d 100644 --- a/app/views/users/all_journals.js.erb +++ b/app/views/users/all_journals.js.erb @@ -1,5 +1,7 @@ <% if params[:type] == 'HomeworkCommon' %> $('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/homework_replies', :locals => {:comments => @journals, :is_in_course =>@is_in_course,:course_activity=>@course_activity, :is_teacher => @is_teacher, :user_activity_id => @user_activity_id}) %>'); +<% elsif params[:type] == 'JournalsForMessage' %> +$('#reply_div_<%= @user_activity_id %>').html('<%=escape_javascript(render :partial => 'users/journal_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :allow_delete => @allow_delete, :activity_id =>params[:id].to_i}) %>'); <% else %> -$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/all_replies', :locals => {:comments => @journals}) %>'); +$('#reply_div_<%= @user_activity_id %>').html('<%=escape_javascript(render :partial => 'users/all_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :allow_delete => @allow_delete, :activity_id =>params[:id].to_i}) %>'); <% end %> diff --git a/app/views/users/show_all_replies.js.erb b/app/views/users/show_all_replies.js.erb index 99ab73b46..5f5ea6c3f 100644 --- a/app/views/users/show_all_replies.js.erb +++ b/app/views/users/show_all_replies.js.erb @@ -1,3 +1,7 @@ <% unless @comment.parent.nil? %> -$('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'users/comment_reply', :locals => {:comment => @comment.parent})%>"); + <% if params[:type] == 'JournalsForMessage' && (@comment.jour_type == 'Principal' || @comment.jour_type == 'Course') %> + $('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'users/journal_comment_reply', :locals => {:comment => @comment.parent})%>"); + <% else %> + $('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'users/comment_reply', :locals => {:comment => @comment.parent})%>"); + <% end %> <% end %> \ No newline at end of file diff --git a/app/views/words/create_reply.js.erb b/app/views/words/create_reply.js.erb index ded05887f..9f3b0164e 100644 --- a/app/views/words/create_reply.js.erb +++ b/app/views/words/create_reply.js.erb @@ -1,8 +1,8 @@ <% if @save_succ %> <% if @user_activity_id %> - <% if @is_activity %> - $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id,:is_activity=>@is_activity}) %>"); - <% else %> + <% if @activity.jour_type == 'Principal' %> + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>"); + <% elsif @activity.jour_type == 'Course' %> $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>"); <% end %> //init_activity_KindEditor_data('<%#= @user_activity_id%>', "", "87%", "UserActivity"); diff --git a/app/views/words/destroy.js.erb b/app/views/words/destroy.js.erb index a2d606e76..c527474cd 100644 --- a/app/views/words/destroy.js.erb +++ b/app/views/words/destroy.js.erb @@ -3,8 +3,7 @@ <% elsif (['Principal','Project','Course', 'Bid', 'Contest', 'Softapplication','HomeworkCommon'].include? @journal_destroyed.jour_type)%> <% if @is_user%> <% if @activity %> - $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id,:is_activity=>@is_activity}) %>"); - //init_activity_KindEditor_data('<%#= @user_activity_id%>', "", "87%", "UserActivity"); + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>"); sd_create_editor_from_data('<%= @user_activity_id%>', "", "100%", "UserActivity"); <% else %> $("#user_activity_<%= @user_activity_id%>").hide(); @@ -20,7 +19,12 @@ <% if @bid && @jours_count %> $('#jours_count').html("<%= @jours_count %>"); <% elsif @course && @jours_count%> - $('#course_jour_count').html("(<%= @jours_count %>)"); + <% if @user_activity_id %> + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>"); + sd_create_editor_from_data('<%= @user_activity_id%>', "", "100%", "UserActivity"); + <% else %> + $('#course_jour_count').html("(<%= @jours_count %>)"); + <% end %> <% elsif @user && @jours_count%> $('#jour_count').html("<%= @jours_count %>"); <% elsif @homework%> diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 22483c1d5..2b674b60d 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1289,7 +1289,7 @@ function clear_data(k,mdu){ } } -function expand_reply(container, btnid, id, type, div_id) { +function expand_reply(container, btnid, id, type, div_id, allow_delete) { var target = $(container); var btn = $(btnid); if (btn.data('init') == '0') { @@ -1299,7 +1299,8 @@ function expand_reply(container, btnid, id, type, div_id) { { type: type, id: id, - div_id: div_id + div_id: div_id, + allow_delete: allow_delete }, function(data) {