添加课程资源文件分类显示视图
This commit is contained in:
parent
59051972e1
commit
7677e092e0
|
@ -162,16 +162,21 @@ class FilesController < ApplicationController
|
|||
end
|
||||
|
||||
# 返回制定资源类型的资源列表
|
||||
# added by nwb
|
||||
def getattachtype
|
||||
sort_init 'created_on', 'desc'
|
||||
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
||||
'filename' => "#{Attachment.table_name}.filename",
|
||||
'size' => "#{Attachment.table_name}.filesize",
|
||||
'downloads' => "#{Attachment.table_name}.downloads"
|
||||
|
||||
@containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] #modify by Long Jun
|
||||
@containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort
|
||||
|
||||
|
||||
if @project
|
||||
@containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)]
|
||||
@containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort
|
||||
elsif @course
|
||||
@containers = [ Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)]
|
||||
end
|
||||
|
||||
@attachtype = params[:type].to_i
|
||||
@contenttype = params[:contentType].to_s
|
||||
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
<% selAttachType =@attachtype %>
|
||||
<% selContentType =@contenttype %>
|
||||
<% attachmenttypes = @course.attachmenttypes %>
|
||||
<% delete_allowed = User.current.allowed_to?(:manage_files, @course) %>
|
||||
<% edit_allowed = User.current.allowed_to?(:manage_files, @course) %>
|
||||
<table class="list files" id="ver-zebra">
|
||||
<colgroup>
|
||||
<col class="vzebra-odd"/>
|
||||
<col class="vzebra-even"/>
|
||||
<col class="vzebra-odd"/>
|
||||
<col class="vzebra-even"/>
|
||||
<!-- <col class="vzebra-odd"/> -->
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<%= sort_header_tag('filename', :caption => l(:field_filename), :scope => "col", :id => "vzebra-adventure") %>
|
||||
<%#= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope => "col", :id => "vzebra-comedy") %>
|
||||
<%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope => "col", :id => "vzebra-children") %>
|
||||
<%= sort_header_tag('attach_type', :caption => l(:attachment_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-attachmenttype") %>
|
||||
<%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope =>"col", :id=> "vzebra-contenttype")%>
|
||||
<%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %>
|
||||
<%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %>
|
||||
<!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> -->
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @containers.each do |container| %>
|
||||
<% next if container.attachments.empty? -%>
|
||||
<% container.attachments.each do |file| %>
|
||||
<% if isTypeOk(file,selAttachType,selContentType) %>
|
||||
<tr class="file <%= cycle("odd", "odd") %>">
|
||||
<td class="filename" style="font-size: 13px; "><%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %></td>
|
||||
<!-- <td class="created_on"><%#= format_time(file.created_on) %></td> -->
|
||||
<td class="filesize"><%= number_to_human_size(file.filesize) %></td>
|
||||
<td class="attach_type">
|
||||
<span id="attach_type_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.attachmentstype.typeName %></span>
|
||||
|
||||
<span id="attach_type_id_edit<%= file.id %>" style="white-space:nowrap;">
|
||||
<%= render :partial => 'attachments/type_edit', :locals => {:attachmenttypes => attachmenttypes,
|
||||
:attachment => file,:contentype=>selContentType} %>
|
||||
</span>
|
||||
</td>
|
||||
<td class="content_type"><%= file.show_suffix_type %></td>
|
||||
<td class="downloads"><%= file.downloads %></td>
|
||||
<!-- <td class="digest" width="300px"><%= file.description %></td> -->
|
||||
<td align="center">
|
||||
<%= link_to(image_tag('delete.png'), attachment_path(file),
|
||||
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='description' colspan="6">
|
||||
<div class="tags_area">
|
||||
<%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %>
|
||||
<%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %>
|
||||
<div class="tags_gradint"></div>
|
||||
</div>
|
||||
<div class="read-more hidden"><a href="javascript:void(0);" onclick="readmore(this);"> 更多 </a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
<% reset_cycle %>
|
||||
<% end -%>
|
||||
<!-- %= h downloadAll(@containers) % -->
|
||||
<!-- %= link_to "download all file", (downloadAll(@containers)) % -->
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
@ -9,9 +9,7 @@ $('#name-issue').val("");
|
|||
$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty();
|
||||
$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/tag_name',
|
||||
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
|
||||
//$("#put-tag-form-
|
||||
<%=@obj.class%>-
|
||||
<%=@obj.id%>").hide();
|
||||
$("#put-tag-form- <%=@obj.class%>- <%=@obj.id%>").hide();
|
||||
$("#put-tag-form-<%=@obj.class%>-<%=@obj.id%> #name").val("");
|
||||
<% else %>
|
||||
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
<% if @attachtype==0 && @contenttype=='0' %>
|
||||
<% if @project%>
|
||||
$("#all_browse_div").html('<%= j(render partial: "show_all_attachment")%>');
|
||||
<%else%>
|
||||
$("#all_browse_div").html('<%= j(render partial: "sort_by_attachtypel")%>');
|
||||
<% elsif @course%>
|
||||
$("#all_browse_div").html('<%= j(render partial: "course_show_all_attachment")%>');
|
||||
<%end%>
|
||||
<%else%>
|
||||
<% if @project%>
|
||||
$("#all_browse_div").html('<%= j(render partial: "sort_by_attachtypel")%>')
|
||||
<% elsif @course%>
|
||||
$("#all_browse_div").html('<%= j(render partial: "course_sort_by_attachtypel")%>')
|
||||
<%end%>;
|
||||
<%end%>
|
||||
|
|
|
@ -90,6 +90,19 @@
|
|||
<%end%>
|
||||
}
|
||||
|
||||
function attachmenttypes_searchex(value) {
|
||||
<% if @project%>
|
||||
$.ajax({
|
||||
url: '<%=getattachtype_project_files_path(project_id: @project)%>',
|
||||
type: "POST",
|
||||
data: {
|
||||
type: encodeURIComponent(value),
|
||||
contentType: $('#attach_sufix_browse').val()
|
||||
}
|
||||
|
||||
}).complete(eval_ajax);
|
||||
<%end%>
|
||||
}
|
||||
|
||||
function course_attachmenttypes_searchex(value) {
|
||||
<% if @course%>
|
||||
|
|
Loading…
Reference in New Issue