实现课程资源TAG云功能
This commit is contained in:
parent
73ed8b9558
commit
0cc809c3e0
|
@ -23,7 +23,7 @@ class FilesController < ApplicationController
|
||||||
before_filter :auth_login1, :only => [:index]
|
before_filter :auth_login1, :only => [:index]
|
||||||
before_filter :logged_user_by_apptoken,:only => [:index]
|
before_filter :logged_user_by_apptoken,:only => [:index]
|
||||||
before_filter :find_project_by_project_id#, :except => [:getattachtype]
|
before_filter :find_project_by_project_id#, :except => [:getattachtype]
|
||||||
before_filter :authorize, :except => [:getattachtype,:quote_resource_show,:search,:search_project,:quote_resource_show_project]
|
before_filter :authorize, :except => [:getattachtype,:quote_resource_show,:search,:search_project,:quote_resource_show_project,:search_tag_attachment]
|
||||||
|
|
||||||
helper :sort
|
helper :sort
|
||||||
include SortHelper
|
include SortHelper
|
||||||
|
@ -51,6 +51,7 @@ class FilesController < ApplicationController
|
||||||
@sort = ""
|
@sort = ""
|
||||||
@order = ""
|
@order = ""
|
||||||
@is_remote = true
|
@is_remote = true
|
||||||
|
@q = params[:name].strip
|
||||||
if params[:sort]
|
if params[:sort]
|
||||||
order_by = params[:sort].split(":")
|
order_by = params[:sort].split(":")
|
||||||
@sort = order_by[0]
|
@sort = order_by[0]
|
||||||
|
@ -518,9 +519,32 @@ class FilesController < ApplicationController
|
||||||
format.js
|
format.js
|
||||||
format.html
|
format.html
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#查找指定TAG的按条件过滤的资源列表
|
||||||
|
def search_tag_attachment
|
||||||
|
@q,@tag_name,@order = params[:q],params[:tag_name]
|
||||||
|
@is_remote = true
|
||||||
|
if params[:sort]
|
||||||
|
order_by = params[:sort].split(":")
|
||||||
|
@sort = order_by[0]
|
||||||
|
if order_by.count > 1
|
||||||
|
@order = order_by[1]
|
||||||
|
end
|
||||||
|
sort = "#{@sort} #{@order}"
|
||||||
|
end
|
||||||
|
|
||||||
|
q = "%#{@q.strip}%"
|
||||||
|
@result = find_course_attache q,@course,sort
|
||||||
|
@result = visable_attachemnts @result
|
||||||
|
@result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)}
|
||||||
|
@searched_attach = paginateHelper @result,10
|
||||||
|
@tag_list = attachment_tag_list @result
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
# format.html
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -128,6 +128,12 @@ module FilesHelper
|
||||||
tag_list.sort {|a,b| b[1]<=>a[1]}
|
tag_list.sort {|a,b| b[1]<=>a[1]}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_attachments_by_tag attachments,tag
|
||||||
|
attachments.each do |attachment|
|
||||||
|
attachment.tag_list.include?(tag)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def visable_attachemnts_insite attachments,obj
|
def visable_attachemnts_insite attachments,obj
|
||||||
result = []
|
result = []
|
||||||
if obj.is_a?(Course)
|
if obj.is_a?(Course)
|
||||||
|
|
|
@ -48,7 +48,6 @@
|
||||||
$('#incourse').attr("class", "re_schbtn b_lblue");
|
$('#incourse').attr("class", "re_schbtn b_lblue");
|
||||||
$('#insite').attr("class", "re_schbtn b_lblue");
|
$('#insite').attr("class", "re_schbtn b_lblue");
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<div class="files_tag">
|
<div class="files_tag">
|
||||||
<% unless @tag_list.nil?%>
|
<% unless @tag_list.nil?%>
|
||||||
<% @tag_list.each do |k,v|%>
|
<% @tag_list.each do |k,v|%>
|
||||||
<a href="javascript:void(0);" class="files_tag_icon"><%= k%>(<span class="c_red"><%= v%></span>)</a>
|
<a href="javascript:void(0);" class="files_tag_icon" onclick="search_tag_attachment('<%= search_tag_attachment_course_files_path(@course)%>','<%= k%>','<%= @q%>','<%= course.id%>');"><%= k%>(<span class="c_red"><%= v%></span>)</a>
|
||||||
<% end%>
|
<% end%>
|
||||||
<% end%>
|
<% end%>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
$("#course_list").html("<%= escape_javascript(render :partial => 'course_list',:locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach})%>");
|
|
@ -709,6 +709,7 @@ RedmineApp::Application.routes.draw do
|
||||||
collection do
|
collection do
|
||||||
match "getattachtype", :via => [:get, :post]
|
match "getattachtype", :via => [:get, :post]
|
||||||
match "search",:via => [:post,:get]
|
match "search",:via => [:post,:get]
|
||||||
|
match "search_tag_attachment", :via => [:post,:get]
|
||||||
end
|
end
|
||||||
member do
|
member do
|
||||||
match "quote_resource_show", :via => [:get]
|
match "quote_resource_show", :via => [:get]
|
||||||
|
|
|
@ -449,3 +449,19 @@ $(function(){
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//查找TAG资源
|
||||||
|
function search_tag_attachment(url,tag_name,q,course_id,sort)
|
||||||
|
{
|
||||||
|
$.get(
|
||||||
|
url,
|
||||||
|
{
|
||||||
|
tag_name: tag_name,
|
||||||
|
q: q,
|
||||||
|
course_id:course_id
|
||||||
|
},
|
||||||
|
function (data) {
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue