一部分ajax留言实现
This commit is contained in:
parent
c05dd4f900
commit
64d85a9ab2
|
@ -223,9 +223,8 @@ class UsersController < ApplicationController
|
|||
# modified by fq
|
||||
def user_newfeedback
|
||||
@jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
||||
@jours.each do |jour|
|
||||
jour.update_attribute(:status, false)
|
||||
end
|
||||
@jours.update_all(:is_readed => true, :status => false)
|
||||
|
||||
@limit = 10
|
||||
@feedback_count = @jours.count
|
||||
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
||||
|
|
|
@ -41,31 +41,34 @@ class WordsController < ApplicationController
|
|||
end
|
||||
|
||||
def create_reply
|
||||
@params = params
|
||||
user_id_str = request.headers["Referer"].match((%r|/[0-9]{1,}/|))[0]
|
||||
user_id = user_id_str[1, user_id_str.size-2]
|
||||
@user = User.find(user_id)
|
||||
parent_id = params[:reference_id]
|
||||
author_id = User.current.id
|
||||
reply_user_id = params[:reference_user_id]
|
||||
reply_id = nil # 暂时不实现
|
||||
reply_id = params[:reference_message_id] # 暂时不实现
|
||||
content = params[:user_notes]
|
||||
@params.merge!({flag:'====', parent_id: parent_id, author_id: author_id, reply_user_id: reply_user_id, content: content})
|
||||
options = {:user_id => author_id,
|
||||
:m_parent_id => parent_id,
|
||||
:m_reply_id => reply_id,
|
||||
:reply_id => reply_user_id,
|
||||
:notes => content,
|
||||
:is_readed => false}
|
||||
jfm = User.current.add_jour(nil, nil, nil, options)
|
||||
@jfm = @user.add_jour(nil, nil, nil, options)
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if jfm.errors.empty?
|
||||
flash.notice = l(:label_feedback_success)
|
||||
else
|
||||
flash.errors = l(:label_feedback_fail)
|
||||
end
|
||||
render 'test/index'
|
||||
# format.html {
|
||||
# if @jfm.errors.empty?
|
||||
# flash.now.notice = l(:label_feedback_success)
|
||||
# else
|
||||
# flash.now.errors = l(:label_feedback_fail)
|
||||
# end
|
||||
# render 'test/index'
|
||||
# }
|
||||
format.js{
|
||||
@save_succ = true if @jfm.errors.empty?
|
||||
}
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<%= image_tag url_to_avatar(reply.user), :class => "avatar-3" %>
|
||||
</span>
|
||||
<span class="body">
|
||||
<% id = reply.id %>
|
||||
<% id = 'project_respond_form_'+ reply.id.to_s %>
|
||||
<span style="color: green;"><%= link_to reply.user.name, user_path(reply.user) %>: </span>
|
||||
<span style="max-width: 80%; word-wrap: break-word;"> <%= reply.notes %></span>
|
||||
<% ids = 'project_respond_form_'+ journal.id.to_s%>
|
||||
|
@ -13,7 +13,7 @@
|
|||
<span style="float: right;"><%= toggle_link l(:label_projects_feedback_respond), id, {:focus => 'project_respond'} %></span>
|
||||
</p>
|
||||
</span>
|
||||
<div id=<%= id %> style="display: none;">
|
||||
<div id='<%=id%>' style="display: none;">
|
||||
<%= render :partial => "words/new_respond", :locals => {:journal => journal, :m_reply_id => m_reply_id} %>
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<%= form_tag({:controller => 'words',
|
||||
:action => 'create_reply'}) do %>
|
||||
<%= form_tag({:controller => 'words', :action => 'create_reply'}, :remote => true) do %>
|
||||
<%= text_area_tag 'user_notes', "", :class => 'noline', :style => "resize: none;", :rows => 4, :placeholder => l(:label_projects_feedback_respond_content) %>
|
||||
|
||||
<%= hidden_field_tag 'reference_id', params[:reference_id], :value => journal.id %>
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<% if @save_succ %>
|
||||
$('#journal_reply_ul_<%=@jfm.m_parent_id%>').append(
|
||||
'<%= j(
|
||||
render :partial => "words/journal_reply_items",
|
||||
:locals => {:reply => @jfm, :journal => @jfm.parent, :m_reply_id => @jfm.id}
|
||||
) %>');
|
||||
$('#project_respond_form_<%=@jfm.m_reply_id.to_s%> textarea').val('');
|
||||
$('#project_respond_form_<%=@jfm.m_reply_id.to_s%>').hide();
|
||||
<% else %>
|
||||
alert("<%= l(:label_feedback_fail) %>");
|
||||
<% end %>
|
Loading…
Reference in New Issue