1、作品评论回复以及相关界面刷新

2、调整回复框宽度
This commit is contained in:
sw 2015-05-27 14:58:55 +08:00
parent a0324f5e39
commit 2bb59ffd79
8 changed files with 46 additions and 29 deletions

View File

@ -103,13 +103,18 @@ class StudentWorkController < ApplicationController
#添加评分的回复
def add_score_reply
respond_to do |format|
format.js
@score = StudentWorksScore.find params[:id]
@jour = @score.journals_for_messages.new(:user_id => User.current.id,:notes =>params[:message], :reply_id => 0)
if @jour.save
respond_to do |format|
format.js
end
end
end
#删除评分的回复
def destroy_score_reply
respond_to do |format|
format.js
end

View File

@ -29,6 +29,7 @@ class JournalsForMessage < ActiveRecord::Base
belongs_to :jour, :polymorphic => true
belongs_to :user
belongs_to :homework_attach
belongs_to :student_works_score
belongs_to :at_user, :class_name => "User", :foreign_key => 'reply_id'
acts_as_event :title => Proc.new {|o| "#{l(:label_my_message)}"},

View File

@ -4,7 +4,7 @@ class StudentWorksScore < ActiveRecord::Base
belongs_to :user
belongs_to :student_work
has_many :journals_for_messages, :dependent => :destroy
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
acts_as_attachable
end

View File

@ -0,0 +1,4 @@
<%= form_for('', :remote => true, :method => :post,:url => add_score_reply_student_work_path(score.id)) do |f|%>
<%= f.text_area 'message', :class => 'ping_text', :placeholder => l(:text_caracters_maximum,:count=>250),:maxlength => 250 %>
<a href="javascript:void(0);" class="fr blue_n_btn" onclick="$('#add_score_reply_<%= score.id%>').find('form').submit();">回复</a>
<% end%>

View File

@ -0,0 +1,20 @@
<div class="ping_back mt10">
<%= link_to image_tag(url_to_avatar(jour.user), :width => "32", :height => "32"), user_path(jour.user),:class => "st_img fl" %>
<div class="ping_back_tit">
<a href="javascript:void(0);" class="c_blue fl" >
<%= link_to jour.user.show_name, user_path(jour.user), :title => jour.user.show_name, :class => "c_blue fl" %>
</a>
<% if jour.user==User.current || User.current.admin? %>
<%= link_to(l(:label_bid_respond_delete), destroy_score_reply_student_work_index_path(:jour_id => jour.id),
:remote => true, :confirm => l(:text_are_you_sure), :title => l(:button_delete), :class => "fr c_purple") %>
<% end %>
<span class=" fr c_grey mr10">
<%=format_time jour.created_on %>
</span>
<div class="cl mb5"></div>
<p class="break_word">
<%= jour.notes%>
</p>
</div><!---ping_box_tit end--->
<div class="cl"></div>
</div><!---ping_back end--->

View File

@ -56,32 +56,17 @@
<%= score.comment%>
</p>
<%form_for "", add_score_reply_student_work_path(@work)%>
<textarea class="ping_text undis"></textarea>
<a href="javascript:void(0);" class="fr blue_n_btn undis" >回复</a>
<div class="cl"></div>
<div id="add_score_reply_<%= score.id%>">
<%= render :partial => 'add_score_reply',:locals => {:score => score}%>
</div>
<div class="cl"></div>
<% score.journals_for_messages.each do |jour|%>
<div class="ping_back mt10">
<%= link_to image_tag(url_to_avatar(jour.user), :width => "32", :height => "32"), user_path(jour.user),:class => "st_img fl" %>
<div class="ping_back_tit">
<a href="javascript:void(0);" class="c_blue fl" >
<%= link_to jour.user.show_name, user_path(jour.user), :title => jour.user.show_name, :class => "c_blue fl" %>
</a>
<% if jour.user==User.current || User.current.admin? %>
<%= link_to(l(:label_bid_respond_delete), destroy_score_reply_student_work_index_path(:jour_id => jour.id),
:remote => true, :confirm => l(:text_are_you_sure), :title => l(:button_delete), :class => "fr c_purple") %>
<% end %>
<span class=" fr c_grey mr10">
<%=jour score.created_at %>
</span>
<div class="cl mb5"></div>
<p class="break_word">
<%= jour.comment%>
</p>
</div><!---ping_box_tit end--->
<div class="cl"></div>
</div><!---ping_back end--->
<% end%>
<div id="replay_histroy_<%= score.id%>">
<% score.journals_for_messages.order("created_on desc").each do |jour|%>
<%= render :partial => 'jour_replay',:locals => {:jour => jour}%>
<% end%>
</div>
</div>
<div class="cl"></div>
</ul>

View File

@ -0,0 +1,2 @@
$("#add_score_reply_<%= @score.id%>").html("<%= escape_javascript(render :partial => 'add_score_reply', :locals => {:score => @score}) %>");
$("#replay_histroy_<%= @score.id%>").prepend("<%= escape_javascript(render :partial => 'jour_replay', :locals => {:jour => @jour}) %>");

View File

@ -653,7 +653,7 @@ a:hover.ping_pic{border:1px solid #64bdd9;}
.ping_box_tit{ float:left; width:575px; margin-left:10px;}
.ping_box_ul{}
.ping_line{ border-bottom:1px dashed #CCCCCC; padding-bottom:8px; margin-bottom:8px;}
.ping_text{border:1px solid #CCCCCC; margin:5px; padding:5px; width:560px; height:20px; }
.ping_text{border:1px solid #CCCCCC; margin:5px; padding:5px; width:560px; height:50px; }
.ping_back_tit{ float:left; width:523px; margin-left:10px; }
a.down_btn{ border:1px solid #CCC; color:#999; padding:0px 5px; font-size:12px; text-align:center; display:block;}
a:hover.down_btn{ background:#14ad5a; color:#fff; border:1px solid #14ad5a;}