班级留言改版

This commit is contained in:
cxt 2017-01-16 16:34:51 +08:00
parent 1fadbcee22
commit 9ccef85600
9 changed files with 107 additions and 21 deletions

View File

@ -1151,6 +1151,7 @@ class CoursesController < ApplicationController
page = params[:page]
# Find the page of the requested reply
@jours = @course.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
@jour_count = @jours.count
@limit = 10
if params[:r] && page.nil?
offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i])

View File

@ -95,6 +95,14 @@ class WordsController < ApplicationController
@jours_count = @course.journals_for_messages.where('m_parent_id IS NULL').count
@user_activity_id = params[:user_activity_id] if params[:user_activity_id]
@activity = JournalsForMessage.where("id = #{params[:activity_id].to_i}").first if params[:activity_id]
unless @activity
if params[:user_activity_id] == params[:activity_id]
redirect_to course_feedback_path(@course)
else
redirect_to course_path(@course)
end
return
end
elsif @journal_destroyed.jour_type == "Principal"
@user = User.find(@journal_destroyed.jour_id)
@jours_count = @user.journals_for_messages.where('m_parent_id IS NULL').count
@ -282,7 +290,7 @@ class WordsController < ApplicationController
# add by nwb
def leave_course_message
user = User.current
message = params[:new_form][:course_message]
message = params[:new_form][:content]
feedback = Course.add_new_jour(user, message, params[:id])
if(feedback.errors.empty?)
if params[:asset_id]

View File

@ -0,0 +1,17 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: true, prettify: false, init_activity: true) %>
<% end %>
<%if jours %>
<% jours.each do |jour|%>
<script type="text/javascript">
$(function(){
sd_create_editor_from_data(<%= jour.id%>, null, "100%", "<%=jour.class.to_s%>");
});
</script>
<%= render :partial => 'users/course_journalsformessage', :locals => {:activity => jour,:user_activity_id =>jour.id, :is_course => 1} %>
<%end%>
<% end%>
<% if (jours.count + page * 10) < count %>
<%= link_to "点击展开更多",course_feedback_path(@course.id, :page => page),:id => "show_more_jours",:remote => "true",:class => "loadMore mt10 f_grey"%>
<% end %>

View File

@ -1,15 +1,28 @@
<% reply_allow = JournalsForMessage.create_by_user? User.current %>
<!-- <#%= stylesheet_link_tag 'css', :media => 'all' %> -->
<div class="courseRSide fl">
<div class="homepageRight mt0 ml10">
<div class="homepageRightBanner mb10">
<div class="NewsBannerName pr"><span id="mesLabel">班级留言</span></div>
</div>
<div class="cl"></div>
<div class="project_r_h" style="width:730px;">
<h2 class="project_h2"><%= l(:label_contest_userresponse) %></h2>
</div>
<%= render :partial => 'courses_jours',
:locals => { :contest => @contest, :journals => @jour, :state => false}
%>
<% html_title(l(:label_course_feedback)) -%>
<div id="messageContent">
<div class="resources"><%= link_to image_tag(url_to_avatar(User.current),:class=>"fl mr10", :width => "50", :height => "50"), :alt => "用户头像" %>
<div class="fl" style="width:658px;">
<%= form_for('new_form',:url => leave_course_message_path(@course.id), :html =>{:id => "course_feedback_new"}, :method => "post") do |f|%>
<%= render :partial => "users/jour_form", :locals => {:f => f, :object => @course} %>
<input id="private_flag" name="private" type="hidden" value="0"/>
<a href="javascript:void(0);" class="blue_n_btn fr mt5" id="submit_feedback_user" >留言</a>
<a href="javascript:void(0);" onclick="cancel_jour_submit()" class="greyBtn2 postReplySubmit mt5 mr15">取消</a>
<% end %>
</div>
</div>
<%=render :partial => "course_jours_list", :locals => {:jours =>@jours, :page => 0, :count => @jour_count} %>
<div class="cl"></div>
</div><!--message_box end-->
</div>
<script type="text/javascript">
$(function(){
$("#submit_feedback_user").one('click',function() {
course_jour_submit();
});
});
</script>

View File

@ -36,6 +36,20 @@
更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %>
</div>
<div class="cl"></div>
<% if defined?(is_course) && is_course == 1 && (activity.user == User.current || User.current.admin? || User.current.allowed_to?(:as_teacher, course))%>
<div class="homepagePostSetting">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li>
<a href="javascript:void(0)" class="postOptionLink" title="删除"
onclick="delete_confirm_box_3('<%= words_destroy_path(:object_id => activity, :user_id => activity.user.id,:user_activity_id => user_activity_id, :activity_id => activity.id)%>', '确定要删除该留言吗?')">删除</a>
</li>
</ul>
</li>
</ul>
</div>
<% end%>
</div>
<div class="cl"></div>
</div>

View File

@ -1405,7 +1405,7 @@ RedmineApp::Application.routes.draw do
end # end of resources :courses
match 'courses/:id/feedback', :to => 'courses#feedback', :via => :get, :as => 'course_feedback'
match '/courses/search', :via => [:get, :post]
match 'words/:id/leave_course_message', :to => 'words#leave_course_message'
match 'words/:id/leave_course_message', :to => 'words#leave_course_message', :as => "leave_course_message"
match 'workflows', :to => 'workflows#index', :via => :get

View File

@ -158,6 +158,7 @@ function jourReplyVerify() {
if (jour_content_editor.isEmpty()) {
$("#jour_content_span").text("留言不能为空");
$("#jour_content_span").css('color', '#ff0000');
$("#jour_content_span").show();
$("#submit_feedback_user").one('click',function() {
contest_jour_submit();
});

View File

@ -1606,3 +1606,35 @@ function submit_course_feedback() {
function show_more_tool(){
$('#navContentCourse').css('display', 'block');
}
//留言
function course_jour_submit(){
if(jourReplyVerify()){
jour_content_editor.sync();//提交内容之前要sync不然服务器端取不到值
$("#course_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").show();
$("#jour_content_span").css('color', '#ff0000');
$("#submit_feedback_user").one('click',function() {
course_jour_submit();
});
return false;
}
else {
$("#jour_content_span").text("填写正确");
$("#jour_content_span").css('color', '#008000');
return true;
}
}
function cancel_jour_submit(){
jour_content_editor.html("");
$("#jour_content_span").text("");
$("#jour_content_span").hide();
}