个人主页留言动态:如图回复当前用户自己的留言却不能删除,“展开回复”后又可删除了,刷新网页后又删除不了

This commit is contained in:
cxt 2016-07-18 16:40:04 +08:00
parent 8e3488132b
commit fdf925a0b8
7 changed files with 9 additions and 44 deletions

View File

@ -3315,7 +3315,6 @@ class UsersController < ApplicationController
@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")

View File

@ -40,16 +40,16 @@
</div>
<% 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)) %>
<%# allow_delete = (activity.user == User.current || User.current.admin? || User.current.allowed_to?(:as_teacher,activity.course)) %>
<%# count = fetch_user_leaveWord_reply(activity).count %>
<div class="homepagePostReply">
<%= render :partial => 'users/journal_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :allow_delete => allow_delete} %>
<%= render :partial => 'users/journal_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %>
<% all_comments = []%>
<% comments = get_all_children(all_comments, activity)[0..2] %>
<% if count > 0 %>
<div class="" id="reply_div_<%= user_activity_id %>">
<%= render :partial => 'users/journal_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'JournalsForMessage', :allow_delete => allow_delete, :activity_id =>activity.id}%>
<%= render :partial => 'users/journal_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'JournalsForMessage', :activity_id =>activity.id}%>
</div>
<% end %>

View File

@ -68,7 +68,7 @@
:title => l(:button_reply)) %>
<span id="reply_iconup_<%=comment.id %>" class="reply_iconup02" style="display: none"> ︿</span>
</span>
<% if allow_delete %>
<% if comment.creator_user == User.current || User.current.admin? %>
<%= 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 %>

View File

@ -10,7 +10,7 @@
<div class="homepagePostReplyBannerTime"><%#= format_date(activity.updated_on) %></div>
<%if count>3 %>
<div class="homepagePostReplyBannerMore">
<a id="reply_btn_<%=user_activity_id%>" onclick="expand_journal_reply('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>',<%= activity.id %>,'<%=activity.class %>',<%=user_activity_id %>,<%=allow_delete %>)" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" >
<a id="reply_btn_<%=user_activity_id%>" onclick="expand_all_reply('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>',<%= activity.id %>,'<%=activity.class %>',<%=user_activity_id %>)" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" >
展开更多
</a>
</div>

View File

@ -64,15 +64,15 @@
</div>
<% all_comments = []%>
<% count=get_all_children(all_comments, activity).count %>
<% allow_delete = (activity.user == User.current || User.current.admin?) %>
<%# allow_delete = (activity.user == User.current || User.current.admin?) %>
<div class="homepagePostReply">
<%= render :partial => 'users/journal_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :allow_delete => allow_delete} %>
<%= render :partial => 'users/journal_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %>
<% all_comments = []%>
<% comments = get_all_children(all_comments, activity)[0..2] %>
<% if count > 0 %>
<div class="" id="reply_div_<%= user_activity_id %>">
<%= render :partial => 'users/journal_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'JournalsForMessage', :allow_delete => allow_delete, :activity_id =>activity.id}%>
<%= render :partial => 'users/journal_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'JournalsForMessage', :activity_id =>activity.id}%>
</div>
<% end %>

View File

@ -1,7 +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}) %>');
$('#reply_div_<%= @user_activity_id %>').html('<%=escape_javascript(render :partial => 'users/journal_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :activity_id =>params[:id].to_i}) %>');
<% elsif params[:type] == 'Message' %>
$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/message_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :activity_id => params[:id].to_i,:is_course => @is_course, :is_board => @is_board}) %>');
<% elsif params[:type] == 'BlogComment' %>

View File

@ -1340,40 +1340,6 @@ function expand_all_reply(container, btnid, id, type, div_id) {
}
}
function expand_journal_reply(container, btnid, id, type, div_id, allow_delete) {
var target = $(container);
var btn = $(btnid);
if (btn.data('init') == '0') {
btn.data('init', 1);
$.get(
'/users/all_journals',
{
type: type,
id: id,
div_id: div_id,
allow_delete: allow_delete
},
function(data) {
}
);
btn.html('收起回复');
//target.show();
} else if(btn.data('init') == '1') {
btn.data('init', 3);
btn.html('展开更多');
target.hide();
target.eq(0).show();
target.eq(1).show();
target.eq(2).show();
}
else {
btn.data('init', 1);
btn.html('收起回复');
target.show();
}
}
function expand_message_reply(container, btnid, id, type, div_id, is_course, is_board) {
var target = $(container);
var btn = $(btnid);