diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 449d8b9de..b7e507b28 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -746,14 +746,34 @@ class UsersController < ApplicationController end end # end - jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') + @page = params[:page] ? params[:page].to_i + 1 : 0 + if params[:type].present? + case params[:type] + when "public" + jours = @user.journals_for_messages.where('m_parent_id IS NULL and private = 0').order('created_on DESC') + @jour_count = jours.count + @jour = jours.limit(10).offset(@page * 10) + when "private" + jours = @user.journals_for_messages.where('m_parent_id IS NULL and private = 1').order('created_on DESC') + @jour_count = jours.count + @jour = jours.limit(10).offset(@page * 10) + else + jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') + @jour_count = jours.count + @jour = jours.limit(10).offset(@page * 10) + end + else + jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') + @jour_count = jours.count + @jour = jours.limit(10).offset(@page * 10) + end + @type = params[:type] if User.current == @user jours.update_all(:is_readed => true, :status => false) jours.each do |journal| fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false) end end - @jour = paginateHelper jours,10 @state = false render :layout=>'new_base_user' end diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index ebd46caa7..8115f3f91 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -225,11 +225,11 @@ class WordsController < ApplicationController def leave_user_message if User.current.logged? @user = User.find(params[:id]) - if params[:new_form][:user_message].size>0 && User.current.logged? && @user + if params[:new_form][:content].size>0 && User.current.logged? && @user if params[:private] && params[:private] == '1' - @user.journals_for_messages << JournalsForMessage.new(:user_id => User.current.id, :notes => params[:new_form][:user_message], :reply_id => 0, :status => true, :is_readed => false, :private => 1) + @user.journals_for_messages << JournalsForMessage.new(:user_id => User.current.id, :notes => params[:new_form][:content], :reply_id => 0, :status => true, :is_readed => false, :private => 1) else - @user.add_jour(User.current, params[:new_form][:user_message]) + @user.add_jour(User.current, params[:new_form][:content]) end end redirect_to feedback_path(@user) diff --git a/app/views/users/_jour_form.html.erb b/app/views/users/_jour_form.html.erb new file mode 100644 index 000000000..13bf6d79a --- /dev/null +++ b/app/views/users/_jour_form.html.erb @@ -0,0 +1,19 @@ +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> +<% end %> + +<%= error_messages_for 'message' %> +
  • + <%= text_area :quote,:quote,:style => 'display:none' %> + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + <%= f.kindeditor :content, :editor_id => 'jour_content_editor', + :width => '99.7%', + :height => 40, + :minHeight=>40, + :input_html => { :id => 'jour_content', + :class => 'talk_text fl', + :maxlength => 5000 }%> +
    +

    +
  • +
    diff --git a/app/views/users/_user_jours_list.html.erb b/app/views/users/_user_jours_list.html.erb new file mode 100644 index 000000000..cc5a589b5 --- /dev/null +++ b/app/views/users/_user_jours_list.html.erb @@ -0,0 +1,32 @@ +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: false, init_activity: true) %> + <%#= javascript_include_tag "init_KindEditor","user" %> +<% end %> + +<%if jours %> + <% jours.each do |jour|%> + <% unless jour.private == 1 && (!User.current || (User.current && jour.jour_id != User.current.id && jour.user_id != User.current.id)) %> + + <%= render :partial => 'user_journalsformessage', :locals => {:activity => jour,:user_activity_id =>jour.id} %> + <%#= render :partial => 'user_jours_new', :locals => {:jour => jour} %> + <% end %> + <%end%> +<% end%> +<% if (jours.count + page * 10) < count %> + <%= link_to "点击展开更多",feedback_path(@user.id, :type => type, :page => page),:id => "show_more_jours",:remote => "true",:class => "loadMore mt10 f_grey"%> +<% end %> \ No newline at end of file diff --git a/app/views/users/user_newfeedback.html.erb b/app/views/users/user_newfeedback.html.erb index 1035f5656..24f625e03 100644 --- a/app/views/users/user_newfeedback.html.erb +++ b/app/views/users/user_newfeedback.html.erb @@ -1,68 +1,40 @@ -<%= content_for(:header_tags) do %> - <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> - <%= javascript_include_tag "init_KindEditor","user" %> -<% end %> - - -
    +
    -
    留言
    -
    - +
    留言
    + +
    -
    -
    - <%= form_for('new_form',:url => leave_user_message_path(@user.id), :html =>{:id => "user_feedback_new"}, :method => "post") do |f|%> - -

    - -
    - - 留言 - 私信
    - <% end%> -
    -
    - -
    - <%if @jour%> - <% @jour.each do |jour|%> - <% unless jour.private == 1 && (!User.current || (User.current && jour.jour_id != User.current.id && jour.user_id != User.current.id)) %> - <%= render :partial => 'user_jours_new', :locals => {:jour => jour} %> - <% end %> - <%end%> - <% end%> - - -
    +
    +
    <%= link_to image_tag(url_to_avatar(User.current),:class=>"fl mr10", :width => "50", :height => "50"), :alt => "用户头像" %> +
    + <%= form_for('new_form',:url => leave_user_message_path(@user.id), :html =>{:id => "user_feedback_new"}, :method => "post") do |f|%> + <%=render :partial => "jour_form", :locals => {:f => f} %> + + 留言 + 私信 + <% end %> +
    + <%=render :partial => "users/user_jours_list", :locals => {:jours =>@jour, :page => 0, :type => @type, :count => @jour_count} %>
    - \ No newline at end of file diff --git a/app/views/users/user_newfeedback.js.erb b/app/views/users/user_newfeedback.js.erb new file mode 100644 index 000000000..cfac4cef2 --- /dev/null +++ b/app/views/users/user_newfeedback.js.erb @@ -0,0 +1 @@ +$("#show_more_jours").replaceWith("<%= escape_javascript( render :partial => 'users/user_jours_list',:locals => {:jours => @jour, :page => @page,:type => @type, :count => @jour_count} )%>"); diff --git a/public/images/mes_icon.png b/public/images/mes_icon.png new file mode 100644 index 000000000..4a37cca0c Binary files /dev/null and b/public/images/mes_icon.png differ diff --git a/public/javascripts/new_user.js b/public/javascripts/new_user.js index 567d2322f..f273f0b77 100644 --- a/public/javascripts/new_user.js +++ b/public/javascripts/new_user.js @@ -55,6 +55,43 @@ function show_more_project(url){ ); } +//个人留言 +function jour_submit(){ + if(jourReplyVerify()){ + $("#private_flag").val("0"); + jour_content_editor.sync();//提交内容之前要sync,不然服务器端取不到值 + $("#user_feedback_new").submit(); + } +} + +function private_jour_submit(){ + if(jourReplyVerify()){ + $("#private_flag").val("1"); + jour_content_editor.sync();//提交内容之前要sync,不然服务器端取不到值 + $("#user_feedback_new").submit(); + } +} + +function jourReplyVerify() { + var content = jour_content_editor.html();//$.trim($("#message_content").val()); + if (jour_content_editor.isEmpty()) { + $("#jour_content_span").text("回复不能为空"); + $("#jour_content_span").css('color', '#ff0000'); + $("#submit_feedback_user").one('click',function() { + jour_submit(); + }); + $("#private_submit_feedback_user").one('click',function() { + private_jour_submit(); + }); + return false; + } + else { + $("#jour_content_span").text("填写正确"); + $("#jour_content_span").css('color', '#008000'); + return true; + } +} + //老师提交 新建/修改 作业 function submit_homework(id){ if(!regex_homework_name()){ diff --git a/public/stylesheets/share.css b/public/stylesheets/share.css index 43e0bc8f6..02d91304f 100644 --- a/public/stylesheets/share.css +++ b/public/stylesheets/share.css @@ -35,7 +35,7 @@ ul.subNavArrow:hover li ul {display:block;} a.mesIcon {background:url(../images/mes_icon.png) -5px -73px no-repeat; padding-left:23px;} a.personalIcon {background:url(../images/mes_icon.png) -6px -16px no-repeat; padding-left:23px;} .mesType {background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:15px; padding:10px 15px; left:-50px; font-size:12px; color:#888888; display:none; line-height:2; z-index:999; white-space:nowrap;} -a.greyBtn2 {float:right; text-align:center; font-size:12px; color:#ffffff; background-color:#cecece; padding:3px 10px;} +a.greyBtn2 {float:right; text-align:center; font-size:12px; color:#ffffff; background-color:#aaaaaa; padding:3px 10px;} .PMTag {padding:0px 5px; background-color:#555555; border-radius:3px; color:#ffffff;} .upload_con h2{ display:block; background:#eaeaea; font-size:14px; color:#343333; height:31px; width: auto; margin-top:25px; padding-left:20px; padding-top:5px;} .upload_box{ width:430px; margin:15px auto;}