From 66dfa1ce4f2dadcef019f15fa61f82d5b901bdf8 Mon Sep 17 00:00:00 2001
From: linhk <304431313@.com>
Date: Thu, 21 Aug 2014 08:58:48 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=88=A0=E9=99=A4?=
=?UTF-8?q?=E9=A1=B9=E7=9B=AE=E4=B8=BB=E7=95=99=E8=A8=80=E5=88=86=E9=A1=B5?=
=?UTF-8?q?Url=E9=94=99=E8=AF=AF=E5=92=8C=E9=A1=B5=E6=95=B0=E9=94=99?=
=?UTF-8?q?=E8=AF=AF=E7=9A=84Bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/projects_controller.rb | 26 ++++++++++----
app/controllers/words_controller.rb | 29 +++++++++++++++
app/views/projects/feedback.html.erb | 8 +++--
app/views/words/_feedback.html.erb | 50 ++++++++++++++++++++++++++
app/views/words/destroyJournal.js.erb | 4 ++-
5 files changed, 107 insertions(+), 10 deletions(-)
create mode 100644 app/views/words/_feedback.html.erb
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index ea37766b6..3fea454de 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -403,17 +403,29 @@ class ProjectsController < ApplicationController
#Ended by young
def feedback
- page = params[:page]
+ @page = params[:page]
+ @page = @page.to_i
# Find the page of the requested reply
@jours = @project.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
- @limit = 10
- if params[:r] && page.nil?
- offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i])
- page = 1 + offset / @limit
+ @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
-
+
+ puts @page
+ if @page < 0
+ @page = 1
+ end
+ if @page > page
+ @page = page
+ end
+
+
@feedback_count = @jours.count
- @feedback_pages = Paginator.new @feedback_count, @limit, page
+ @feedback_pages = Paginator.new @feedback_count, @limit, @page
@offset ||= @feedback_pages.offset
@jour = @jours[@offset, @limit]
@state = false
diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb
index af850d626..e31bb2738 100644
--- a/app/controllers/words_controller.rb
+++ b/app/controllers/words_controller.rb
@@ -90,8 +90,37 @@ class WordsController < ApplicationController
end
def destroyJournal
+
@journalP=JournalsForMessage.find(params[:object_id])
@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|
format.js
end
diff --git a/app/views/projects/feedback.html.erb b/app/views/projects/feedback.html.erb
index 13e123b35..8e36b8c59 100644
--- a/app/views/projects/feedback.html.erb
+++ b/app/views/projects/feedback.html.erb
@@ -36,7 +36,8 @@ function checkMaxLength() {
-<% reply_allow = JournalsForMessage.create_by_user? User.current %>
+
+
<%= l(:label_user_response) %>
@@ -59,6 +60,8 @@ function checkMaxLength() {
<% end %>
+
+ <% reply_allow = JournalsForMessage.create_by_user? User.current %>
<% if @jour.size >0 %>
<% for journal in @jour%>
@@ -81,7 +84,7 @@ function checkMaxLength() {
<% 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},
+ <%= 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 %>
@@ -106,4 +109,5 @@ function checkMaxLength() {
<%= pagination_links_full @feedback_pages %>
+
\ No newline at end of file
diff --git a/app/views/words/_feedback.html.erb b/app/views/words/_feedback.html.erb
new file mode 100644
index 000000000..774ee3b64
--- /dev/null
+++ b/app/views/words/_feedback.html.erb
@@ -0,0 +1,50 @@
+<% reply_allow = JournalsForMessage.create_by_user? User.current %>
+<% if @jour.size >0 %>
+
+ <% for journal in @jour%>
+ -
+ <%= image_tag(url_to_avatar(journal.user), :class => "avatar") %>
+
+ <%= link_to journal.user, user_path(journal.user)%>
+ <%= textilizable journal.notes%>
+ <%= l :label_update_time %>: <%= format_time journal.created_on %>
+ <% id = 'project_respond_form_'+journal.id.to_s%>
+
+ <% 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 %>
+
+
+
+ <% if reply_allow %>
+
+ <%= render :partial => 'words/new_respond', :locals => {:journal => journal, :m_reply_id => journal} %>
+
+ <% end %>
+
+
+ <%= render :partial => "words/journal_reply", :locals => {:journal => journal } %>
+
+
+ <% end %>
+
+<% end %>
+
+
\ No newline at end of file
diff --git a/app/views/words/destroyJournal.js.erb b/app/views/words/destroyJournal.js.erb
index 5c91c6053..3600c3fd6 100644
--- a/app/views/words/destroyJournal.js.erb
+++ b/app/views/words/destroyJournal.js.erb
@@ -1,3 +1,5 @@
+
<% 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 %>
\ No newline at end of file
From 075b43f836a3392666909dd0e5175efe0a4714ec Mon Sep 17 00:00:00 2001
From: luguo
Date: Thu, 21 Aug 2014 09:18:10 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=89=88=E6=9D=83?=
=?UTF-8?q?=E7=AC=A6=E5=8F=B7=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/layouts/_base_footer.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/layouts/_base_footer.html.erb b/app/views/layouts/_base_footer.html.erb
index 990a6d3c8..46fc0debd 100644
--- a/app/views/layouts/_base_footer.html.erb
+++ b/app/views/layouts/_base_footer.html.erb
@@ -10,7 +10,7 @@
<%=l(:label_organizers)%>
- <%=l(:label_copyright)%>@2007~2014
+ <%=l(:label_copyright)%>©2007~2014