From f3ce91869949c2d3d82f89ccc5b1b6b0f02807d0 Mon Sep 17 00:00:00 2001 From: nieguanghui Date: Tue, 24 Dec 2013 16:42:56 +0800 Subject: [PATCH 01/18] =?UTF-8?q?=E7=95=99=E8=A8=80=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/words_controller.rb | 38 +++++ app/models/journals_for_message.rb | 3 +- app/models/reply_for_journal.rb | 4 + app/models/user.rb | 7 +- app/views/layouts/base_users.html.erb | 10 -- app/views/words/_message.html.erb | 19 ++- app/views/words/_new_respond.html.erb | 8 + app/views/words/new.js.erb | 1 + config/routes.rb | 1 + ...sing_attribute_to_journals_for_messages.rb | 8 + db/schema.rb | 143 +++++++++++++----- 11 files changed, 181 insertions(+), 61 deletions(-) create mode 100644 app/models/reply_for_journal.rb create mode 100644 app/views/words/_new_respond.html.erb create mode 100644 db/migrate/20131224021723_add_missing_attribute_to_journals_for_messages.rb diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 113adecc5..7198fc5ac 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -39,6 +39,44 @@ class WordsController < ApplicationController end end + def create_reply + if params[:new_form][:user_message].size>0 + unless params[:user_id].nil? + if params[:reference_content] + message = params[:new_form][:user_message] + "\n" + params[:reference_content] + else + message = params[:new_form][:user_message] + end + refer_user_id = params[:new_form][:reference_user_id].to_i + + # @user.add_jour(User.current, message, params[:object_id]) + @user.add_reply(params[:object_id], @user.current, message) + unless refer_user_id == 0 || refer_user_id == User.current.id + User.find(refer_user_id).add_jour(User.current, message, refer_user_id) + end + @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 + @jours = @user.journals_for_messages.reverse + @limit = 10 + @feedback_count = @jours.count + @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + @offset ||= @feedback_pages.offset + @jour = @jours[@offset, @limit] + + respond_to do |format| + # format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}} + format.js + #format.api { render_api_ok } + end + end + def destroy if User.current.admin? || User.current.id == @user.id JournalsForMessage.delete_message(params[:object_id]) diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index bb03ad121..e4e9164d6 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -6,6 +6,7 @@ class JournalsForMessage < ActiveRecord::Base belongs_to :jour, :polymorphic => true belongs_to :user has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy + has_many :reply_for_journals, :dependent => :destroy after_create :act_as_activity #huang def self.delete_message(message_id) @@ -24,7 +25,7 @@ class JournalsForMessage < ActiveRecord::Base def act_as_activity if self.jour_type == 'Principal' - unless self.user_id == self.jour.id && self.user_id != self.reply_id && self.reply_id !=0 + unless self.user_id == self.jour.id && self.user_id != self.reply_id && self.reply_id != 0 self.acts << Activity.new(:user_id => self.user_id) end end diff --git a/app/models/reply_for_journal.rb b/app/models/reply_for_journal.rb new file mode 100644 index 000000000..0ea6a04c7 --- /dev/null +++ b/app/models/reply_for_journal.rb @@ -0,0 +1,4 @@ +class ReplyForJournal < ActiveRecord::Base + # attr_accessible :title, :body + belongs_to :journals_for_messages +end diff --git a/app/models/user.rb b/app/models/user.rb index 6b1ee3d1b..a0bca8040 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -204,7 +204,12 @@ class User < Principal def count_new_jour count = self.new_jours.count end - + + #added by nie + def count_new_journal_reply + count = self.journal_reply.count + end + def set_mail_notification ##add byxianbo thread=Thread.new do diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index 33b296bfb..e829aec08 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -67,14 +67,10 @@ -
<%= link_to l(:label_user_watcher)+"("+User.watched_by(@user.id).count.to_s+")" ,:controller=>"users", :action=>"user_watchlist"%>   - <%= link_to l(:label_x_user_fans, :count => User.current.watcher_users(User.current.id).count)+"("+@user.watcher_users(@user.id).count.to_s+")", :controller=>"users", :action=>"user_fanslist" %>  - <%= link_to l(:label_requirement_focus)+"("+Bid.watched_by(@user).where('reward_type = ?', 1).count.to_s+")" ,:controller=>"users", :action=>"watch_bids"%>   - <% if @user.id == User.current.id %>

@@ -89,9 +85,7 @@

- <%= render :partial => "words/journal_reply", :locals => {:journal => journal} %> + <%#= render :partial => "words/journal_reply", :locals => {:journal => journal} %>
<% end %> From fbf73de68b8abecf15448c9082bc8a8c4a68e439 Mon Sep 17 00:00:00 2001 From: nieguanghui Date: Wed, 25 Dec 2013 15:37:03 +0800 Subject: [PATCH 07/18] 1234 --- app/helpers/words_helper.rb | 4 ++ app/views/words/_journal_reply.html.erb | 41 ++++++++++--- app/views/words/_message.html.erb | 80 +++++++++++++------------ 3 files changed, 79 insertions(+), 46 deletions(-) diff --git a/app/helpers/words_helper.rb b/app/helpers/words_helper.rb index 167c78e2c..2e37c7f69 100644 --- a/app/helpers/words_helper.rb +++ b/app/helpers/words_helper.rb @@ -43,5 +43,9 @@ module WordsHelper # content.present? ? content_tag('ul', content, :class => 'watchers') : content content end + + def find_reply_message + JournalsForMessage.where("jour_id = 4").take(2) + end end \ No newline at end of file diff --git a/app/views/words/_journal_reply.html.erb b/app/views/words/_journal_reply.html.erb index 9a4e77591..f65c973a0 100644 --- a/app/views/words/_journal_reply.html.erb +++ b/app/views/words/_journal_reply.html.erb @@ -1,9 +1,32 @@ - -<%= form_tag({:controller => 'words', -:action => 'create_reply'}) do %> -<%= text_area_tag 'project_respond', "", :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 %> -<%= submit_tag l(:button_projects_feedback_respond), :name => nil , :class => "bid_btn", :style => "margin-top: 1px;"%> - -<% end %> \ No newline at end of file + +
    + <% fetch_user_leaveWord_reply.each do |reply|%> +
  • +
    + <%= image_tag url_to_avatar(reply.user), :class => "avatar-3" %> +
    +
    + <% id = reply.id %> + <%= reply.user.name %> + <%= reply.notes %> + <% if @user == User.current %> + <% ids = 'project_respond_form_'+ journal.id.to_s%> + <%= toggle_link l(:label_projects_feedback_respond), id, {:focus => 'project_respond'} %> + <% end %> +

    <%= reply.created_on %>

    +
    +
    style="display: none;"> + <%= render :partial => "words/new_respond", :locals => {:journal => journal} %> +
    +
    +
  • + <% end %> +
diff --git a/app/views/words/_message.html.erb b/app/views/words/_message.html.erb index 40fc71e8c..857d76f65 100644 --- a/app/views/words/_message.html.erb +++ b/app/views/words/_message.html.erb @@ -1,48 +1,54 @@ + <% if jour.size >0 %> <% remove_allowed = (User.current.id == jour.first.user_id) %> - +
    <% for journal in jour%> - - - - - -
    <%= image_tag(url_to_avatar(journal.user), :class => "avatar") %> - - - - - - - - - - - - -
    <%= link_to journal.user, user_path(journal.user)%> - <% if @user == User.current %> - <%= l(:label_leave_me_message) %> - <% else %> - <%= l(:label_leave_others_message) %> - <% end %>
    -
    - <%= textilizable journal.notes%> -
    <%= l :label_comment_time %>:  <%= format_time journal.created_on %> +
  • + <%= image_tag(url_to_avatar(journal.user), :class => "avatar") %> + + <%= link_to journal.user, user_path(journal.user)%> + <% if @user == User.current %> + <%= l(:label_leave_me_message) %> + <% else %> + <%= l(:label_leave_others_message) %> + <% end %> + + <%= textilizable journal.notes%> + + <%= l :label_comment_time %>:  <%= format_time journal.created_on %> <% if @user == User.current %> <% ids = 'project_respond_form_'+ journal.id.to_s%> <%= toggle_link l(:label_projects_feedback_respond), ids, {:focus => 'project_respond'} %> <% end %> -
  • -
    -
    style="display: none;width: 80%; margin: auto;"> - <%= render :partial => 'words/new_respond', :locals => {:journal => journal} %> -
    -
    - <%= render :partial => "words/journal_reply", :locals => {:journal => journal} %> -
    -
    + +
    +
    style="display: none; width: 80%; margin: auto;"> + <%= render :partial => 'words/new_respond', :locals => {:journal => journal} %> +
    +
    + <%= render :partial => "words/journal_reply", :locals => {:journal => journal} %> +
    + <% end %> +
<% end %> From f05d2131bd9d4955dd3a08cfb351664936e64e17 Mon Sep 17 00:00:00 2001 From: yanxd Date: Wed, 25 Dec 2013 15:40:34 +0800 Subject: [PATCH 08/18] =?UTF-8?q?=E7=BB=84=E7=BB=87=E7=95=99=E8=A8=80?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/words_controller.rb | 28 +++++--- app/helpers/words_helper.rb | 102 +++++++++++++++------------- app/models/journals_for_message.rb | 13 ++-- app/models/user.rb | 10 ++- 4 files changed, 89 insertions(+), 64 deletions(-) diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index ee4e24ac7..0f11cc5e3 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 #####leave message fq class WordsController < ApplicationController @@ -40,23 +41,30 @@ class WordsController < ApplicationController end def create_reply - find_user @params = params parent_id = params[:reference_id] author_id = User.current.id reply_user_id = params[:reference_user_id] - # reply_id = nil # 暂时不实现 + reply_id = nil # 暂时不实现 content = params[:user_notes] - @params.merge({flag:'====', parent_id: parent_id, author_id: author_id, reply_user_id: reply_user_id, content: content}) - JournalsForMessage.new( :user_id => author_id, - :m_parent_id => parent_id, - :reply_id => reply_user_id, - :notes => content, - :is_readed => false - ) + @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) respond_to do |format| - format.html {render 'test/index'} + format.html { + if jfm.errors.empty? + flash.notice = l(:label_feedback_success) + else + flash.errors = l(:label_feedback_fail) + end + render 'test/index' + } format.js end end diff --git a/app/helpers/words_helper.rb b/app/helpers/words_helper.rb index 167c78e2c..fb9d3264f 100644 --- a/app/helpers/words_helper.rb +++ b/app/helpers/words_helper.rb @@ -1,47 +1,57 @@ -########fq -module WordsHelper - def message_list(object, state, user) - unless state - if object.size > 5 - object = object[-5, 5] - end - end - object = object.reverse - remove_allowed = (User.current.id == object.first.user_id) - content = ''.html_safe - lis = object.each do |t_object| - s = ''.html_safe - s << link_to(t_object.indice, {}, :class => "journal-link") - s << avatar(t_object.user, :size => "16").to_s - s << link_to_user(t_object.user, :class => 'user') - time = time_tag(t_object.created_at) - s << l(:field_add, :time => time).html_safe - if !t_object.notes.blank? - s << link_to(image_tag('comment.png'), - {:controller => 'words', :action => 'new', :id => user, :journal_id => t_object}, - :remote => true, - :method => 'post', - :title => l(:button_quote)) - if remove_allowed || t_object.jour_id == User.current.id - url = {:controller => 'words', - :action => 'destroy', - :object_id => t_object, - :user_id => user} - s << ' ' - s << link_to(image_tag('delete.png'), url, - :remote => true, :method => 'delete', :class => "delete", :title => l(:button_delete)) - end - end - #time = '更新于' + time_tag(t_object.created_at) + '之前' - - - # s << content_tag('div', time) - - content << content_tag('li', s, :class => "user-#{t_object.jour_id}") - content << textilizable(t_object.notes) - end - # content.present? ? content_tag('ul', content, :class => 'watchers') : content - content - end -end +########fq +module WordsHelper + def message_list(object, state, user) + unless state + if object.size > 5 + object = object[-5, 5] + end + end + object = object.reverse + remove_allowed = (User.current.id == object.first.user_id) + content = ''.html_safe + lis = object.each do |t_object| + s = ''.html_safe + s << link_to(t_object.indice, {}, :class => "journal-link") + s << avatar(t_object.user, :size => "16").to_s + s << link_to_user(t_object.user, :class => 'user') + time = time_tag(t_object.created_at) + s << l(:field_add, :time => time).html_safe + if !t_object.notes.blank? + s << link_to(image_tag('comment.png'), + {:controller => 'words', :action => 'new', :id => user, :journal_id => t_object}, + :remote => true, + :method => 'post', + :title => l(:button_quote)) + if remove_allowed || t_object.jour_id == User.current.id + url = {:controller => 'words', + :action => 'destroy', + :object_id => t_object, + :user_id => user} + s << ' ' + s << link_to(image_tag('delete.png'), url, + :remote => true, :method => 'delete', :class => "delete", :title => l(:button_delete)) + end + end + #time = '更新于' + time_tag(t_object.created_at) + '之前' + + + # s << content_tag('div', time) + + content << content_tag('li', s, :class => "user-#{t_object.jour_id}") + content << textilizable(t_object.notes) + end + # content.present? ? content_tag('ul', content, :class => 'watchers') : content + content + end + + def fetch_user_leaveWord_reply leaveWordObj + if leaveWordObj.kind_of? JournalsForMessage + leaveWordObj.children + elsif leaveWordObj.kind_of? Fixnum + JournalsForMessage.find(leaveWordObj).children + else + [] + end + end +end \ No newline at end of file diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 1c28b815e..2c5b40c74 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -1,6 +1,6 @@ # fq # 数据库字段中带有m前缀和is_readed是二次开发添加,之前的字段基本复用 -# 注意reply_id 是提到人的id,不是留言id, Base中叫做ator +# 注意reply_id 是提到人的id,不是留言id, Base中叫做 at_user class JournalsForMessage < ActiveRecord::Base include Redmine::SafeAttributes safe_attributes "jour_type", # 留言所属类型 @@ -17,7 +17,7 @@ class JournalsForMessage < ActiveRecord::Base belongs_to :jour, :polymorphic => true belongs_to :user - belongs_to :ator, :class_name => "User", :foreign_key => 'reply_id' + belongs_to :at_user, :class_name => "User", :foreign_key => 'reply_id' has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy has_many :reply_for_journals, :dependent => :destroy @@ -50,10 +50,11 @@ class JournalsForMessage < ActiveRecord::Base end def reset_counters! - self.class.reset_counters!(id) + self.class.reset_counters!(self) end - def self.reset_counters! journals_for_messages_id - jfm_id = journals_for_messages_id.to_i - update_all("m_reply_count = (SELECT COUNT(*) FROM #{JournalsForMssages.table_name} WHERE m_parent_id = #{jfm_id} )", ["id = ?", jfm_id]) + def self.reset_counters! journals_for_messages + # jfm_id = journals_for_messages.id.to_i + count = find_all_by_m_parent_id(journals_for_messages.m_parent_id).count #(SELECT COUNT(*) FROM #{JournalsForMessage.table_name} WHERE m_parent_id = #{jfm_id} ) + update_all("m_reply_count = #{count.to_i}", ["id = ?", journals_for_messages.m_parent_id]) end end diff --git a/app/models/user.rb b/app/models/user.rb index a0bca8040..3ee601b6a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -164,8 +164,14 @@ class User < Principal ###添加留言 fq - def add_jour(user, notes, reference_user_id = 0) - self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id, :status => true) + def add_jour(user, notes, reference_user_id = 0, options = {}) + if options.count == 0 + self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id, :status => true) + else + jfm = self.journals_for_messages.build(options) + jfm.save + jfm + end end # 判断用户是否加入了竞赛中 fq From 60489bdbfd4b427c33f3e196c95933f75878e07c Mon Sep 17 00:00:00 2001 From: yanxd Date: Wed, 25 Dec 2013 15:45:14 +0800 Subject: [PATCH 09/18] 'fix' --- app/views/words/_message.html.erb | 83 +++++++++++++++++-------------- 1 file changed, 46 insertions(+), 37 deletions(-) diff --git a/app/views/words/_message.html.erb b/app/views/words/_message.html.erb index 1201bae22..857d76f65 100644 --- a/app/views/words/_message.html.erb +++ b/app/views/words/_message.html.erb @@ -1,45 +1,54 @@ + <% if jour.size >0 %> <% remove_allowed = (User.current.id == jour.first.user_id) %> - +
    <% for journal in jour%> - - - - - -
    <%= image_tag(url_to_avatar(journal.user), :class => "avatar") %> - - - - - - - - - - - - <% else %> - <%= link_to(l(:label_newfeedback_quote), {:controller => 'words', :action => 'new', :id => user, :journal_id => journal}, :remote => true, - :method => 'post', :title => l(:button_quote))%> +
  • + <%= image_tag(url_to_avatar(journal.user), :class => "avatar") %> + + <%= link_to journal.user, user_path(journal.user)%> + <% if @user == User.current %> + <%= l(:label_leave_me_message) %> + <% else %> + <%= l(:label_leave_others_message) %> + <% end %> + + <%= textilizable journal.notes%> + + <%= l :label_comment_time %>:  <%= format_time journal.created_on %> + <% if @user == User.current %> + <% ids = 'project_respond_form_'+ journal.id.to_s%> + <%= toggle_link l(:label_projects_feedback_respond), ids, {:focus => 'project_respond'} %> <% end %> -
  • -
    <%= link_to journal.user, user_path(journal.user)%> - <% if @user == User.current %> - <%= l(:label_leave_me_message) %> - <% else %> - <%= l(:label_leave_others_message) %> - <% end %>
    -
    - <%= textilizable journal.notes%> -
    <%= l :label_comment_time %>:  <%= format_time journal.created_on %> <% if @user == User.current %> - <%= link_to(l(:label_newfeedback_quote), {:controller => 'words', :action => 'new', :id => user, :journal_id => journal}, :remote => true, - :method => 'post', :title => l(:button_quote))%> - <%= link_to(l(:label_newfeedback_delete), {:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => user}, - :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) if remove_allowed || journal.jour_id == User.current.id %>
    -
    -
    + +
    +
    style="display: none; width: 80%; margin: auto;"> + <%= render :partial => 'words/new_respond', :locals => {:journal => journal} %> +
    +
    + <%= render :partial => "words/journal_reply", :locals => {:journal => journal} %> +
    + <% end %> +
<% end %> From b716b60c0b66d5e792b85236e69fa6b08212fa98 Mon Sep 17 00:00:00 2001 From: nieguanghui Date: Wed, 25 Dec 2013 15:57:19 +0800 Subject: [PATCH 10/18] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9B=9E=E5=A4=8D?= =?UTF-8?q?=E6=A1=86=E9=BB=98=E8=AE=A4=E5=B1=95=E5=BC=80=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/words/_journal_reply.html.erb | 2 +- app/views/words/_message.html.erb | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/views/words/_journal_reply.html.erb b/app/views/words/_journal_reply.html.erb index f65c973a0..3acf762db 100644 --- a/app/views/words/_journal_reply.html.erb +++ b/app/views/words/_journal_reply.html.erb @@ -8,7 +8,7 @@ }
    - <% fetch_user_leaveWord_reply.each do |reply|%> + <% fetch_user_leaveWord_reply(journal).each do |reply|%>
  • <%= image_tag url_to_avatar(reply.user), :class => "avatar-3" %> diff --git a/app/views/words/_message.html.erb b/app/views/words/_message.html.erb index 857d76f65..31e05cbdb 100644 --- a/app/views/words/_message.html.erb +++ b/app/views/words/_message.html.erb @@ -35,10 +35,8 @@ <%= textilizable journal.notes%> <%= l :label_comment_time %>:  <%= format_time journal.created_on %> - <% if @user == User.current %> <% ids = 'project_respond_form_'+ journal.id.to_s%> - <%= toggle_link l(:label_projects_feedback_respond), ids, {:focus => 'project_respond'} %> - <% end %> + <%= toggle_link l(:label_projects_feedback_respond), ids, {:focus => 'project_respond'} %>
    style="display: none; width: 80%; margin: auto;"> From 6b3c3516cd0977fccc74c1812e14798b8a3f3372 Mon Sep 17 00:00:00 2001 From: yanxd Date: Wed, 25 Dec 2013 16:04:14 +0800 Subject: [PATCH 11/18] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E7=BB=99=E7=95=99?= =?UTF-8?q?=E8=A8=80=E7=9A=84=E5=9B=9E=E5=A4=8D=E6=98=BE=E7=A4=BA=E5=9C=A8?= =?UTF-8?q?=E7=95=99=E8=A8=80=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ea8109dd0..3bcfcf6fc 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -222,7 +222,7 @@ class UsersController < ApplicationController # modified by fq def user_newfeedback - @jours = @user.journals_for_messages.reverse + @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 From c05dd4f900f8a73405bf5fc9c8988cc25ede13d3 Mon Sep 17 00:00:00 2001 From: nieguanghui Date: Wed, 25 Dec 2013 21:00:40 +0800 Subject: [PATCH 12/18] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=95=99=E8=A8=80=E6=98=BE=E7=A4=BA=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/words/_journal_reply.html.erb | 33 +++---------------- app/views/words/_journal_reply_items.html.erb | 20 +++++++++++ app/views/words/_message.html.erb | 27 ++++++++++++--- app/views/words/_new_respond.html.erb | 2 +- public/stylesheets/application.css | 2 ++ .../stylesheets/application.css | 15 +++++++-- 6 files changed, 63 insertions(+), 36 deletions(-) create mode 100644 app/views/words/_journal_reply_items.html.erb diff --git a/app/views/words/_journal_reply.html.erb b/app/views/words/_journal_reply.html.erb index 3acf762db..eed80421d 100644 --- a/app/views/words/_journal_reply.html.erb +++ b/app/views/words/_journal_reply.html.erb @@ -1,32 +1,7 @@ - -
      + +<% id = "journal_reply_ul_" + journal.id.to_s%> +
        > <% fetch_user_leaveWord_reply(journal).each do |reply|%> -
      • -
        - <%= image_tag url_to_avatar(reply.user), :class => "avatar-3" %> -
        -
        - <% id = reply.id %> - <%= reply.user.name %> - <%= reply.notes %> - <% if @user == User.current %> - <% ids = 'project_respond_form_'+ journal.id.to_s%> - <%= toggle_link l(:label_projects_feedback_respond), id, {:focus => 'project_respond'} %> - <% end %> -

        <%= reply.created_on %>

        -
        -
        style="display: none;"> - <%= render :partial => "words/new_respond", :locals => {:journal => journal} %> -
        -
        -
      • + <%= render :partial => "words/journal_reply_items", :locals => {:reply => reply, :journal => journal, :m_reply_id => reply.id} %> <% end %>
      diff --git a/app/views/words/_journal_reply_items.html.erb b/app/views/words/_journal_reply_items.html.erb new file mode 100644 index 000000000..406ead1db --- /dev/null +++ b/app/views/words/_journal_reply_items.html.erb @@ -0,0 +1,20 @@ +
    • + + <%= image_tag url_to_avatar(reply.user), :class => "avatar-3" %> + + + <% id = reply.id %> + <%= link_to reply.user.name, user_path(reply.user) %>:  + <%= reply.notes %> + <% ids = 'project_respond_form_'+ journal.id.to_s%> + +

      + <%= format_time reply.created_on %> + <%= toggle_link l(:label_projects_feedback_respond), id, {:focus => 'project_respond'} %> +

      +
      +
      style="display: none;"> + <%= render :partial => "words/new_respond", :locals => {:journal => journal, :m_reply_id => m_reply_id} %> +
      +
      +
    • \ No newline at end of file diff --git a/app/views/words/_message.html.erb b/app/views/words/_message.html.erb index 31e05cbdb..c3e97b360 100644 --- a/app/views/words/_message.html.erb +++ b/app/views/words/_message.html.erb @@ -1,5 +1,23 @@ <% if jour.size >0 %> <% remove_allowed = (User.current.id == jour.first.user_id) %> -
        +
          <% for journal in jour%>
        • <%= image_tag(url_to_avatar(journal.user), :class => "avatar") %> @@ -40,10 +59,10 @@
          style="display: none; width: 80%; margin: auto;"> - <%= render :partial => 'words/new_respond', :locals => {:journal => journal} %> + <%= render :partial => 'words/new_respond', :locals => {:journal => journal, :m_reply_id => journal.id} %>
          - <%= render :partial => "words/journal_reply", :locals => {:journal => journal} %> + <%= render :partial => "words/journal_reply", :locals => {:journal => journal } %>
        • <% end %> diff --git a/app/views/words/_new_respond.html.erb b/app/views/words/_new_respond.html.erb index 30babb3eb..dd3886812 100644 --- a/app/views/words/_new_respond.html.erb +++ b/app/views/words/_new_respond.html.erb @@ -4,7 +4,7 @@ <%= hidden_field_tag 'reference_id', params[:reference_id], :value => journal.id %> <%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => journal.user.id %> -<%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => 1 %> +<%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => m_reply_id %> <%= submit_tag l(:button_projects_feedback_respond), :name => nil , :class => "bid_btn", :style => "margin-top: 1px;"%> <% end %> \ No newline at end of file diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 533126eb2..65c8be921 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -2676,3 +2676,5 @@ div.repos_explain{ #admin-index{ margin-left: -220px; } + + diff --git a/public/themes/redpenny-master/stylesheets/application.css b/public/themes/redpenny-master/stylesheets/application.css index cf1a76d72..7c7f648a5 100644 --- a/public/themes/redpenny-master/stylesheets/application.css +++ b/public/themes/redpenny-master/stylesheets/application.css @@ -2035,7 +2035,7 @@ div.avatar_user{ .teacher { display: inline-block; word-spacing: 22px; - width: 55px; + width: 60px; text-justify:inter-ideograph; text-align: justify; } @@ -2048,4 +2048,15 @@ div.avatar_user{ white-space: nowrap; text-overflow: ellipsis; -o-text-overflow: ellipsis; -} \ No newline at end of file +} + + .avatar-3{ + width: 35px; + height: 35px; + } + .inner-right{ + float: left; + } + .messages-for_user-reply{ + margin-top: 10px; + } From 64d85a9ab22d25374d6c9777e188cd8d45b3ee8d Mon Sep 17 00:00:00 2001 From: yanxd Date: Wed, 25 Dec 2013 22:21:16 +0800 Subject: [PATCH 13/18] =?UTF-8?q?=E4=B8=80=E9=83=A8=E5=88=86ajax=E7=95=99?= =?UTF-8?q?=E8=A8=80=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 5 ++-- app/controllers/words_controller.rb | 27 ++++++++++--------- app/views/words/_journal_reply_items.html.erb | 4 +-- app/views/words/_new_respond.html.erb | 3 +-- app/views/words/create_reply.js.erb | 11 ++++++++ 5 files changed, 31 insertions(+), 19 deletions(-) create mode 100644 app/views/words/create_reply.js.erb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3bcfcf6fc..4b7f04547 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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'] diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 0f11cc5e3..da5bbb8bd 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -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 diff --git a/app/views/words/_journal_reply_items.html.erb b/app/views/words/_journal_reply_items.html.erb index 406ead1db..9f5bceeef 100644 --- a/app/views/words/_journal_reply_items.html.erb +++ b/app/views/words/_journal_reply_items.html.erb @@ -3,7 +3,7 @@ <%= image_tag url_to_avatar(reply.user), :class => "avatar-3" %> - <% id = reply.id %> + <% id = 'project_respond_form_'+ reply.id.to_s %> <%= link_to reply.user.name, user_path(reply.user) %>:  <%= reply.notes %> <% ids = 'project_respond_form_'+ journal.id.to_s%> @@ -13,7 +13,7 @@ <%= toggle_link l(:label_projects_feedback_respond), id, {:focus => 'project_respond'} %>

          -
          style="display: none;"> +
          diff --git a/app/views/words/_new_respond.html.erb b/app/views/words/_new_respond.html.erb index dd3886812..61953457a 100644 --- a/app/views/words/_new_respond.html.erb +++ b/app/views/words/_new_respond.html.erb @@ -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 %> diff --git a/app/views/words/create_reply.js.erb b/app/views/words/create_reply.js.erb new file mode 100644 index 000000000..20964d9b0 --- /dev/null +++ b/app/views/words/create_reply.js.erb @@ -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 %> \ No newline at end of file From 605d7ec565c01ca530e93ebc5819b0f9895b7779 Mon Sep 17 00:00:00 2001 From: yanxd Date: Thu, 26 Dec 2013 08:39:43 +0800 Subject: [PATCH 14/18] ajax message fix --- app/controllers/words_controller.rb | 4 ++-- app/models/journals_for_message.rb | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index da5bbb8bd..3063ec5fd 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -41,8 +41,8 @@ class WordsController < ApplicationController end def create_reply - user_id_str = request.headers["Referer"].match((%r|/[0-9]{1,}/|))[0] - user_id = user_id_str[1, user_id_str.size-2] + # deny api. api useless + user_id = request.headers["Referer"].match((%r|/([0-9]{1,})/|))[1] @user = User.find(user_id) parent_id = params[:reference_id] author_id = User.current.id diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 2c5b40c74..df2e2a162 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -26,6 +26,8 @@ class JournalsForMessage < ActiveRecord::Base after_create :act_as_activity #huang after_create :reset_counters! after_destroy :reset_counters! + + default_scope { where('m_parent_id IS NULL') } def self.delete_message(message_id) self.delete_all "id = #{message_id}" From a01123c5bffc7c95f6cd1c2b03957eb92e99e4cc Mon Sep 17 00:00:00 2001 From: yanxd Date: Thu, 26 Dec 2013 08:43:16 +0800 Subject: [PATCH 15/18] d --- app/controllers/words_controller.rb | 2 +- app/models/journals_for_message.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 3063ec5fd..7c05c5af5 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -26,7 +26,7 @@ class WordsController < ApplicationController # @message_count = a_message.count end end - @jours = @user.journals_for_messages.reverse + @jours = @user.journals_for_messages.where('m_parent_id IS NULL').reverse @limit = 10 @feedback_count = @jours.count @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index df2e2a162..e00564f18 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -27,7 +27,7 @@ class JournalsForMessage < ActiveRecord::Base after_create :reset_counters! after_destroy :reset_counters! - default_scope { where('m_parent_id IS NULL') } + # default_scope { where('m_parent_id IS NULL') } def self.delete_message(message_id) self.delete_all "id = #{message_id}" From 7130347f390bfab26e3e7a7b711c1d76007befce Mon Sep 17 00:00:00 2001 From: yanxd Date: Thu, 26 Dec 2013 10:52:16 +0800 Subject: [PATCH 16/18] =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E6=A1=86=20=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=A7=93=E5=90=8D=20=E4=B8=83=E5=85=AB=E7=B3=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/words/_journal_reply_items.html.erb | 13 +++++++++---- app/views/words/_message.html.erb | 6 +++++- public/javascripts/application.js | 5 +++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/views/words/_journal_reply_items.html.erb b/app/views/words/_journal_reply_items.html.erb index 9f5bceeef..1a92c79d2 100644 --- a/app/views/words/_journal_reply_items.html.erb +++ b/app/views/words/_journal_reply_items.html.erb @@ -2,7 +2,7 @@ <%= image_tag url_to_avatar(reply.user), :class => "avatar-3" %> - +
          <% id = 'project_respond_form_'+ reply.id.to_s %> <%= link_to reply.user.name, user_path(reply.user) %>:  <%= reply.notes %> @@ -10,10 +10,15 @@

          <%= format_time reply.created_on %> - <%= toggle_link l(:label_projects_feedback_respond), id, {:focus => 'project_respond'} %> + + <%#= toggle_link l(:label_projects_feedback_respond), id, {:focus => 'project_respond'} %> + <%= link_to l(:label_projects_feedback_respond),'', + {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{id}'), $('##{id} textarea'), '#{l(:label_reply_plural)} #{reply.user.show_name}: '); return false;"} + %> +

          - - +
          diff --git a/app/views/words/_message.html.erb b/app/views/words/_message.html.erb index c3e97b360..2f8d5ecc2 100644 --- a/app/views/words/_message.html.erb +++ b/app/views/words/_message.html.erb @@ -55,7 +55,11 @@ ul.message-for-user li { <%= l :label_comment_time %>:  <%= format_time journal.created_on %> <% ids = 'project_respond_form_'+ journal.id.to_s%> - <%= toggle_link l(:label_projects_feedback_respond), ids, {:focus => 'project_respond'} %> + <%#= toggle_link l(:label_projects_feedback_respond), ids, {:focus => 'project_respond'} %> + + <%= link_to l(:label_projects_feedback_respond),'', + {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{journal.user.show_name}:'); return false;"} + %>
          style="display: none; width: 80%; margin: auto;"> diff --git a/public/javascripts/application.js b/public/javascripts/application.js index fea17ee12..65af8714e 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -590,6 +590,11 @@ function blockEventPropagation(event) { event.preventDefault(); } +function toggleAndSettingWordsVal(parent_widget, text_widget, value){ + text_widget.val(value) + parent_widget.toggle(400) +} + $(document).ready(setupAjaxIndicator); $(document).ready(hideOnLoad); $(document).ready(addFormObserversForDoubleSubmit); From d0c28a60bc5892eb78c9abb32161a494d9def1e1 Mon Sep 17 00:00:00 2001 From: nieguanghui Date: Thu, 26 Dec 2013 11:05:09 +0800 Subject: [PATCH 17/18] =?UTF-8?q?=E7=95=99=E8=A8=80=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/words/_journal_reply.html.erb | 2 +- app/views/words/_journal_reply_items.html.erb | 11 ++- app/views/words/_message.html.erb | 42 +-------- .../stylesheets/application.css | 87 ++++++++++++++++--- 4 files changed, 84 insertions(+), 58 deletions(-) diff --git a/app/views/words/_journal_reply.html.erb b/app/views/words/_journal_reply.html.erb index eed80421d..a909362d9 100644 --- a/app/views/words/_journal_reply.html.erb +++ b/app/views/words/_journal_reply.html.erb @@ -1,6 +1,6 @@ <% id = "journal_reply_ul_" + journal.id.to_s%> -
            > +
              > <% fetch_user_leaveWord_reply(journal).each do |reply|%> <%= render :partial => "words/journal_reply_items", :locals => {:reply => reply, :journal => journal, :m_reply_id => reply.id} %> <% end %> diff --git a/app/views/words/_journal_reply_items.html.erb b/app/views/words/_journal_reply_items.html.erb index 1a92c79d2..40dbc274a 100644 --- a/app/views/words/_journal_reply_items.html.erb +++ b/app/views/words/_journal_reply_items.html.erb @@ -1,15 +1,14 @@ -
            • +
            • <%= image_tag url_to_avatar(reply.user), :class => "avatar-3" %>
              <% id = 'project_respond_form_'+ reply.id.to_s %> - <%= link_to reply.user.name, user_path(reply.user) %>:  - <%= reply.notes %> + <%= link_to reply.user.name, user_path(reply.user) %>:  + <%= reply.notes %> <% ids = 'project_respond_form_'+ journal.id.to_s%> - -

              - <%= format_time reply.created_on %> +

              + <%= format_time reply.created_on %> <%#= toggle_link l(:label_projects_feedback_respond), id, {:focus => 'project_respond'} %> <%= link_to l(:label_projects_feedback_respond),'', diff --git a/app/views/words/_message.html.erb b/app/views/words/_message.html.erb index 2f8d5ecc2..b756141bd 100644 --- a/app/views/words/_message.html.erb +++ b/app/views/words/_message.html.erb @@ -1,47 +1,9 @@ - - <% if jour.size >0 %> <% remove_allowed = (User.current.id == jour.first.user_id) %>

                <% for journal in jour%> -
              • +
              • <%= image_tag(url_to_avatar(journal.user), :class => "avatar") %> <%= link_to journal.user, user_path(journal.user)%> @@ -62,7 +24,7 @@ ul.message-for-user li { %>
                -
                style="display: none; width: 80%; margin: auto;"> +
                class="respond-form"> <%= render :partial => 'words/new_respond', :locals => {:journal => journal, :m_reply_id => journal.id} %>
                diff --git a/public/themes/redpenny-master/stylesheets/application.css b/public/themes/redpenny-master/stylesheets/application.css index 7c7f648a5..61b2b13cd 100644 --- a/public/themes/redpenny-master/stylesheets/application.css +++ b/public/themes/redpenny-master/stylesheets/application.css @@ -310,7 +310,7 @@ ul.projects li.root padding:5%; /*项目界面的宽度 */ height:25px; background-color:#0ee; /* 项目界面 #eee*/ - margin:0 0 10px; + margin:0 0 0 10px; display:inline-block; width:90%; vertical-align:top; @@ -2050,13 +2050,78 @@ div.avatar_user{ -o-text-overflow: ellipsis; } - .avatar-3{ - width: 35px; - height: 35px; - } - .inner-right{ - float: left; - } - .messages-for_user-reply{ - margin-top: 10px; - } +/* + * * + *Designed for message. + */ +li { + list-style-type: none; +} +.avatar-3{ + width: 35px; + height: 35px; +} +.inner-right{ + float: left; +} +.messages-for-user-reply{ + margin-top: 10px; + padding-left: 60px; +} + +ul.message-for-user { + list-style-type: none; + margin: 0px; + padding: 0px; + font-family: 微软雅黑,Verdana,sans-serif,宋体; + text-align: left; + font-size: 10pt; + width: 100%; + +} + +ul.message-for-user li.outer-message-for-user { + margin-left: 20px; + border-bottom: 1px solid rgb(213, 222, 233); + margin-bottom: 10px; + margin-top: 10px; +} + +.portrait{ + float: left; + width: 40px; + padding-top: 3px; + margin: 0px; + padding: 0px; + display: block; + } + +span.body{ + float: left; + width: 80%; + overflow: hidden; + font-size: 9pt; + margin: 0px 10px; + padding: 0px; + display: block; + margin-left: 20px; + } + + span.time{ + color: rgb(172,174,174); + } + + .message-notes{ + max-width: 80%; + word-wrap: break-word; + } + +ul.messages-for-user-reply li { + padding-bottom: 4px; +} + +.respond-form{ + display: none; + width: 80%; + margin: auto; +} \ No newline at end of file From 6d47031d724de3d907a52f6d819dfc7769cef250 Mon Sep 17 00:00:00 2001 From: nieguanghui Date: Thu, 26 Dec 2013 11:13:30 +0800 Subject: [PATCH 18/18] =?UTF-8?q?=E6=94=B9=E5=8F=98=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/words/_journal_reply_items.html.erb | 2 +- public/themes/redpenny-master/stylesheets/application.css | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/words/_journal_reply_items.html.erb b/app/views/words/_journal_reply_items.html.erb index 40dbc274a..92ed24c65 100644 --- a/app/views/words/_journal_reply_items.html.erb +++ b/app/views/words/_journal_reply_items.html.erb @@ -17,7 +17,7 @@

                -