用户留言后界面的刷新,留言的分页显示

This commit is contained in:
sw 2015-07-29 18:26:04 +08:00
parent d790fb31e4
commit ce89c7d119
4 changed files with 25 additions and 18 deletions

View File

@ -18,17 +18,10 @@ class WordsController < ApplicationController
list = User.find(refer_user_id).add_jour(User.current, message, refer_user_id) list = User.find(refer_user_id).add_jour(User.current, message, refer_user_id)
end end
@jour = list.last @jour = list.last
# @user.count_new_jour
# if a_message.size > 5
# @message = a_message[-5, 5]
# else
# @message = a_message
# end
# @message_count = a_message.count
end end
end end
# @jours = @user.journals_for_messages.where('m_parent_id IS NULL').reverse jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
# @jour = paginateHelper @jours,10 @jour = paginateHelper jours,10
respond_to do |format| respond_to do |format|
format.js format.js
@ -91,7 +84,6 @@ class WordsController < ApplicationController
end end
respond_to do |format| respond_to do |format|
format.js format.js
#format.api { render_api_ok }
end end
end end
@ -204,7 +196,15 @@ class WordsController < ApplicationController
flash[:error] = feedback.errors.full_messages[0] flash[:error] = feedback.errors.full_messages[0]
redirect_to project_feedback_url(params[:id]) redirect_to project_feedback_url(params[:id])
end end
end
#给用户留言
def leave_user_message
@user = User.find(params[:id])
if params[:new_form][:user_message].size>0 && User.current.logged? && @user
@user.add_jour(User.current, params[:new_form][:user_message])
end
redirect_to feedback_path(@user)
end end
# add by nwb # add by nwb

View File

@ -15,6 +15,7 @@
</span> </span>
<div class="fr cr"> <div class="fr cr">
<%= link_to l(:button_reply),'javascript:void(0);',:nhname=>"reply_btn", :class => "ml5 c_purple" %> <%= link_to l(:button_reply),'javascript:void(0);',:nhname=>"reply_btn", :class => "ml5 c_purple" %>
<% if User.current.admin? || jour.user == User.current%> <% if User.current.admin? || jour.user == User.current%>
<%= link_to(l(:label_newfeedback_delete), {:controller => 'words', :action => 'destroy', :object_id => jour, :user_id => jour.user}, <%= link_to(l(:label_newfeedback_delete), {:controller => 'words', :action => 'destroy', :object_id => jour, :user_id => jour.user},
:remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "ml5 c_purple", :title => l(:button_delete)) %> :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "ml5 c_purple", :title => l(:button_delete)) %>

View File

@ -5,22 +5,27 @@
</div> </div>
<div class="message_box mb10"> <div class="message_box mb10">
<div nhname='new_message' style="display:none;"> <div nhname='new_message' style="display:none;">
<form action="<%= url_for(:controller => 'words', :action => 'create', :user_id => @user.id) %>" data-remote="true" method="post"> <%= form_for('new_form',:url => leave_user_message_path(@user.id),:method => "post") do |f|%>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" nhname='new_message_textarea' name="new_form[user_message]"></textarea> <textarea placeholder="有问题或有建议,请直接给我留言吧!" nhname='new_message_textarea' name="new_form[user_message]"></textarea>
<p nhname='contentmsg'></p> <p nhname='contentmsg'></p>
<div nhname='toolbar_container' style="float:left;padding-top:3px;"></div> <div nhname='toolbar_container' style="float:left;padding-top:3px;"></div>
<a id="new_message_cancel_btn" href="javascript:void(0)" class="grey_n_btn fr " style="margin-top:3px;">取消</a> <a id="new_message_cancel_btn" href="javascript:void(0)" class="grey_n_btn fr " style="margin-top:3px;">取消</a>
<a id="new_message_submit_btn" href="javascript:void(0)" class="blue_n_btn fr mr5 " style="margin-top:3px;">留言</a> <a id="new_message_submit_btn" href="javascript:void(0)" class="blue_n_btn fr mr5 " style="margin-top:3px;">留言</a>
</form> <% end%>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<div class="message_list_box"> <div class="message_list_box" id="user_jour_list">
<%if @jour%> <%if @jour%>
<% @jour.each do |jour|%> <% @jour.each do |jour|%>
<%= render :partial => 'user_jours_new', :locals => {:jour => jour} %> <%= render :partial => 'user_jours_new', :locals => {:jour => jour} %>
<%end%> <%end%>
<% end%> <% end%>
<ul class="wlist" style=" border:none;">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
</ul>
<div class="cl"></div>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
</div><!--message_box end--> </div><!--message_box end-->

View File

@ -791,6 +791,7 @@ RedmineApp::Application.routes.draw do
match 'words/:id/leave_project_message', :to => 'words#leave_project_message' match 'words/:id/leave_project_message', :to => 'words#leave_project_message'
match 'projects/:id/feedback', :to => 'projects#feedback', :via => :get, :as => 'project_feedback' match 'projects/:id/feedback', :to => 'projects#feedback', :via => :get, :as => 'project_feedback'
match 'project/:id/share', :to => 'projects#share', :as => 'share_show' #share match 'project/:id/share', :to => 'projects#share', :as => 'share_show' #share
post 'words/:id/leave_user_message', :to => 'words#leave_user_message', :as => "leave_user_message"
post 'join_in/join', :to => 'courses#join', :as => 'join' post 'join_in/join', :to => 'courses#join', :as => 'join'
delete 'join_in/join', :to => 'courses#unjoin' delete 'join_in/join', :to => 'courses#unjoin'