课程资源上传允许多选tag

This commit is contained in:
lizanle 2015-11-13 11:17:47 +08:00
parent 2c5cd1a4b3
commit e7d53f5e16
2 changed files with 41 additions and 25 deletions

View File

@ -374,30 +374,29 @@ class FilesController < ApplicationController
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
Mailer.run.attachments_added(attachments[:files]) Mailer.run.attachments_added(attachments[:files])
end end
if params[:course_attachment_type] && params[:course_attachment_type].is_a?(Array)
if params[:course_attachment_type] && params[:course_attachment_type] != "5" params[:course_attachment_type].each do |type|
case params[:course_attachment_type] tag_name = get_tag_name_by_type_number type
when "1" if !attachments.empty? && attachments[:files] && tag_name != ""
tag_name = l(:label_courseware) attachments[:files].each do |attachment|
when "2" attachment.tag_list.add(tag_name)
tag_name = l(:label_software) attachment.save
when "3" end
tag_name = l(:label_media) end
when "4"
tag_name = l(:label_code)
when "6"
tag_name = "论文"
else
tag_name = ""
end end
if !attachments.empty? && attachments[:files] && tag_name != "" else
attachments[:files].each do |attachment| if params[:course_attachment_type] && params[:course_attachment_type] != "5"
attachment.tag_list.add(tag_name) tag_name = get_tag_name_by_type_number params[:course_attachment_type]
attachment.save if !attachments.empty? && attachments[:files] && tag_name != ""
attachments[:files].each do |attachment|
attachment.tag_list.add(tag_name)
attachment.save
end
end end
end end
end end
# TODO: 临时用 nyan # TODO: 临时用 nyan
sort_init 'created_on', 'desc' sort_init 'created_on', 'desc'
sort_update 'created_on' => "#{Attachment.table_name}.created_on", sort_update 'created_on' => "#{Attachment.table_name}.created_on",
@ -424,6 +423,23 @@ class FilesController < ApplicationController
end end
end end
def get_tag_name_by_type_number type
case type
when "1"
tag_name = l(:label_courseware)
when "2"
tag_name = l(:label_software)
when "3"
tag_name = l(:label_media)
when "4"
tag_name = l(:label_code)
when "6"
tag_name = "论文"
else
tag_name = ""
end
end
def tag_saveEx def tag_saveEx
@tags = params[:tag_name][:name] @tags = params[:tag_name][:name]
@obj_id = params[:object_id] @obj_id = params[:object_id]

View File

@ -10,12 +10,12 @@
<input type="hidden" name="in_course_toolbar" value="Y"> <input type="hidden" name="in_course_toolbar" value="Y">
<!--<p class="c_grey fr mt10 mr5">--> <!--<p class="c_grey fr mt10 mr5">-->
<div class="c_dark"> <div class="c_dark">
<input name="course_attachment_type" type="radio" value="1" checked class="c_dark" >课件</input>&nbsp;<span class="c_grey">|</span>&nbsp; <input name="course_attachment_type[]" type="checkbox" value="1" checked class="c_dark" >课件</input>&nbsp;<span class="c_grey">|</span>&nbsp;
<input name="course_attachment_type" type="radio" value="2" class="c_dblue">软件</input>&nbsp;<span class="c_grey">|</span>&nbsp; <input name="course_attachment_type[]" type="checkbox" value="2" class="c_dblue">软件</input>&nbsp;<span class="c_grey">|</span>&nbsp;
<input name="course_attachment_type" type="radio" value="3" class="c_dblue">媒体</input>&nbsp;<span class="c_grey">|</span>&nbsp; <input name="course_attachment_type[]" type="checkbox" value="3" class="c_dblue">媒体</input>&nbsp;<span class="c_grey">|</span>&nbsp;
<input name="course_attachment_type" type="radio" value="4" class="c_dblue">代码</input>&nbsp;<span class="c_grey">|</span>&nbsp; <input name="course_attachment_type[]" type="checkbox" value="4" class="c_dblue">代码</input>&nbsp;<span class="c_grey">|</span>&nbsp;
<input name="course_attachment_type" type="radio" value="6" class="c_dblue">论文</input>&nbsp;<span class="c_grey">|</span>&nbsp; <input name="course_attachment_type[]" type="checkbox" value="6" class="c_dblue">论文</input>&nbsp;<span class="c_grey">|</span>&nbsp;
<input name="course_attachment_type" type="radio" value="5" class="c_dblue">其他</input></a> <input name="course_attachment_type[]" type="checkbox" value="5" class="c_dblue">其他</input></a>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<div> <div>