解决删除项目主留言分页Url错误和页数错误的Bug
This commit is contained in:
parent
cc08cdc140
commit
66dfa1ce4f
|
@ -403,17 +403,29 @@ class ProjectsController < ApplicationController
|
||||||
#Ended by young
|
#Ended by young
|
||||||
|
|
||||||
def feedback
|
def feedback
|
||||||
page = params[:page]
|
@page = params[:page]
|
||||||
|
@page = @page.to_i
|
||||||
# Find the page of the requested reply
|
# Find the page of the requested reply
|
||||||
@jours = @project.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
@jours = @project.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
||||||
@limit = 10
|
@limit = 3
|
||||||
if params[:r] && page.nil?
|
|
||||||
offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i])
|
offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i])
|
||||||
page = 1 + offset / @limit
|
page = 1 + offset / @limit
|
||||||
|
if params[:r] && @page.nil?
|
||||||
|
@page = page
|
||||||
end
|
end
|
||||||
|
|
||||||
|
puts @page
|
||||||
|
if @page < 0
|
||||||
|
@page = 1
|
||||||
|
end
|
||||||
|
if @page > page
|
||||||
|
@page = page
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
@feedback_count = @jours.count
|
@feedback_count = @jours.count
|
||||||
@feedback_pages = Paginator.new @feedback_count, @limit, page
|
@feedback_pages = Paginator.new @feedback_count, @limit, @page
|
||||||
@offset ||= @feedback_pages.offset
|
@offset ||= @feedback_pages.offset
|
||||||
@jour = @jours[@offset, @limit]
|
@jour = @jours[@offset, @limit]
|
||||||
@state = false
|
@state = false
|
||||||
|
|
|
@ -90,8 +90,37 @@ class WordsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroyJournal
|
def destroyJournal
|
||||||
|
|
||||||
@journalP=JournalsForMessage.find(params[:object_id])
|
@journalP=JournalsForMessage.find(params[:object_id])
|
||||||
@journalP.destroy
|
@journalP.destroy
|
||||||
|
|
||||||
|
@page = params[:page]
|
||||||
|
@page = @page.to_i
|
||||||
|
@project = Project.find params[:project_id]
|
||||||
|
# Find the page of the requested reply
|
||||||
|
@jours = @project.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
||||||
|
@limit = 3
|
||||||
|
|
||||||
|
offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i])
|
||||||
|
page = 1 + offset / @limit
|
||||||
|
if params[:r] && @page.nil?
|
||||||
|
@page = page
|
||||||
|
end
|
||||||
|
|
||||||
|
if @page < 0
|
||||||
|
@page = 1
|
||||||
|
end
|
||||||
|
if @page > page
|
||||||
|
@page = page
|
||||||
|
end
|
||||||
|
|
||||||
|
@feedback_count = @jours.count
|
||||||
|
@feedback_pages = Paginator.new @feedback_count, @limit, @page
|
||||||
|
@offset ||= @feedback_pages.offset
|
||||||
|
@jour = @jours[@offset, @limit]
|
||||||
|
@state = false
|
||||||
|
@base_courses_tag = @project.project_type
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,7 +36,8 @@ function checkMaxLength() {
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<!-- fq -->
|
<!-- fq -->
|
||||||
<% reply_allow = JournalsForMessage.create_by_user? User.current %>
|
|
||||||
|
|
||||||
|
|
||||||
<h3><%= l(:label_user_response) %></h3>
|
<h3><%= l(:label_user_response) %></h3>
|
||||||
|
|
||||||
|
@ -59,6 +60,8 @@ function checkMaxLength() {
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div style="clear: both;"></div>
|
<div style="clear: both;"></div>
|
||||||
|
<div id="project_feedback">
|
||||||
|
<% reply_allow = JournalsForMessage.create_by_user? User.current %>
|
||||||
<% if @jour.size >0 %>
|
<% if @jour.size >0 %>
|
||||||
<ul class="message-for-user">
|
<ul class="message-for-user">
|
||||||
<% for journal in @jour%>
|
<% for journal in @jour%>
|
||||||
|
@ -81,7 +84,7 @@ function checkMaxLength() {
|
||||||
|
|
||||||
<% if User.current.logged? %>
|
<% if User.current.logged? %>
|
||||||
<% if journal.user_id==User.current.id|| User.current.admin? %>
|
<% if journal.user_id==User.current.id|| User.current.admin? %>
|
||||||
<%= link_to(l(:button_delete),{:controller => 'words', :action => 'destroyJournal', :object_id => journal.id},
|
<%= link_to(l(:button_delete),{:controller => 'words', :action => 'destroyJournal', :object_id => journal.id, :project_id=>@project.id, :page=>@page},
|
||||||
:remote => true, :title => l(:button_delete)) %>
|
:remote => true, :title => l(:button_delete)) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -107,3 +110,4 @@ function checkMaxLength() {
|
||||||
<%= pagination_links_full @feedback_pages %>
|
<%= pagination_links_full @feedback_pages %>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
|
@ -0,0 +1,50 @@
|
||||||
|
<% reply_allow = JournalsForMessage.create_by_user? User.current %>
|
||||||
|
<% if @jour.size >0 %>
|
||||||
|
<ul class="message-for-user">
|
||||||
|
<% for journal in @jour%>
|
||||||
|
<li id='word_li_<%=journal.id.to_s%>' class="outer-message-for-user">
|
||||||
|
<span class="portrait"><%= image_tag(url_to_avatar(journal.user), :class => "avatar") %></span>
|
||||||
|
<span class="body">
|
||||||
|
<span class="user"><%= link_to journal.user, user_path(journal.user)%></span>
|
||||||
|
<%= textilizable journal.notes%>
|
||||||
|
<span class="font_lighter"> <%= l :label_update_time %>: <%= format_time journal.created_on %></span>
|
||||||
|
<% id = 'project_respond_form_'+journal.id.to_s%>
|
||||||
|
<span>
|
||||||
|
<% if reply_allow %>
|
||||||
|
<%= link_to l(:label_projects_feedback_respond),'#',
|
||||||
|
{:focus => 'project_respond',
|
||||||
|
:onclick => "toggleAndSettingWordsVal($('##{id}'),
|
||||||
|
$('##{id} textarea'),
|
||||||
|
'#{l(:label_reply_plural)} #{journal.user.name}: ');
|
||||||
|
return false;"} %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if User.current.logged? %>
|
||||||
|
<% if journal.user_id==User.current.id|| User.current.admin? %>
|
||||||
|
<%= link_to(l(:button_delete),{:controller => 'words', :action => 'destroyJournal', :object_id => journal.id, :project_id=>@project.id, :page=>@page},
|
||||||
|
:remote => true, :title => l(:button_delete)) %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<div style="clear: both;"></div>
|
||||||
|
<% if reply_allow %>
|
||||||
|
<div id='<%= id %>' class="respond-form">
|
||||||
|
<%= render :partial => 'words/new_respond', :locals => {:journal => journal, :m_reply_id => journal} %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<div style="clear: both;"></div>
|
||||||
|
<div>
|
||||||
|
<%= render :partial => "words/journal_reply", :locals => {:journal => journal } %>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<div class="pagination" style="float:left;">
|
||||||
|
<ul>
|
||||||
|
<%= pagination_links_full(@feedback_pages,@feedback_count, :per_page_links => false){|text, parameters, options|
|
||||||
|
link_to text, project_feedback_path(@project,parameters.merge(:q => params[:q])) }%>
|
||||||
|
</ul>
|
||||||
|
</div>
|
|
@ -1,3 +1,5 @@
|
||||||
|
|
||||||
<% if @journalP!=nil %>
|
<% if @journalP!=nil %>
|
||||||
$(".message-for-user").children("#word_li_<%=@journalP.id%>").remove();
|
//$(".message-for-user").children("#word_li_<%#=@journalP.id%>").remove();
|
||||||
|
$("#project_feedback").html("<%= escape_javascript(render :partial => 'words/feedback') %>");
|
||||||
<% end %>
|
<% end %>
|
Loading…
Reference in New Issue