From 3b180aca90990ed1bbd5366e396172577a55e55b Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 20 Jan 2016 18:37:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=B8=AA=E4=BA=BA=E7=95=99?= =?UTF-8?q?=E8=A8=80=E9=A1=B5=E9=9D=A2=E7=9A=84=E6=94=B9=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 24 ++++++- app/controllers/words_controller.rb | 6 +- app/views/users/_jour_form.html.erb | 19 ++++++ app/views/users/_user_jours_list.html.erb | 32 +++++++++ app/views/users/user_newfeedback.html.erb | 78 +++++++--------------- app/views/users/user_newfeedback.js.erb | 1 + public/images/mes_icon.png | Bin 0 -> 2459 bytes public/javascripts/new_user.js | 37 ++++++++++ public/stylesheets/share.css | 2 +- 9 files changed, 140 insertions(+), 59 deletions(-) create mode 100644 app/views/users/_jour_form.html.erb create mode 100644 app/views/users/_user_jours_list.html.erb create mode 100644 app/views/users/user_newfeedback.js.erb create mode 100644 public/images/mes_icon.png 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 %> - - -
    +
    -
    留言
    -
    - +
    留言
    +
      +
    • +
        +
      • <%= link_to "全部", {:controller => "users", :action => "user_newfeedback", :type => nil}, :class =>"resourcesTypeAll resourcesGrey"%>
      • +
      • <%= link_to "留言", {:controller => "users", :action => "user_newfeedback", :type => "public"}, :class => "mesIcon resourcesGrey"%>
      • +
      • <%= link_to "私信", {:controller => "users", :action => "user_newfeedback", :type => "private"}, :class => "personalIcon resourcesGrey"%>
      • +
      +
    • +
    +
    -
    -
    - <%= 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%> - -
      - <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> -
    -
    +
    +
    <%= 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 0000000000000000000000000000000000000000..4a37cca0cabf24a62cfcdb371b03e048afd1e5ee GIT binary patch literal 2459 zcmeAS@N?(olHy`uVBq!ia0vp^xeN@9%Q)D8tg;1MQ-PFZiEBhjaDG}zd16s2gJVj5 zQmTSyZen_BP-l zO)W`OsL0L9E4HezRRWu91!RMS^_3LBN=mYAl^~9a@C{IK&M!(;Fx4~GO*SwzR4_Bs zGc++ZGc(jtFfuSS(l-DiGhIUyD^oKoBXb2PPy*Ukl#*r@}n3+2no0=FJx|%v!SeRHkTNpVz zIvW}}SvbS=y5uL9=BDPA!1Sgd^jhH53rY&P1wfl!Qj0RnQd8WD@^clyUbf1_?G{s< z=0WwQ;C71{PQCg-$LND17Ac}(Lcr7mV#1RxkONQnsd>QEUIa|mZ*GYBF)*<4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ngUdxCqzGtxt)Lim(^>bP0l+XkKGm_$b literal 0 HcmV?d00001 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;}