资源库 修改

This commit is contained in:
lizanle 2015-08-20 17:38:30 +08:00
parent 0e8c1d1b66
commit 705d31b1d0
7 changed files with 17 additions and 10 deletions

View File

@ -1015,7 +1015,7 @@ class UsersController < ApplicationController
# 重命名资源 # 重命名资源
def rename_resource def rename_resource
@attachment = Attachment.find(params[:res_id]) @attachment = Attachment.find(params[:res_id]) if params[:res_id].present?
if @attachment != nil if @attachment != nil
@attachment.filename = params[:res_name] @attachment.filename = params[:res_name]
@flag = @attachment.save @flag = @attachment.save
@ -1260,13 +1260,14 @@ class UsersController < ApplicationController
end end
elsif params[:type] == "4" #附件 elsif params[:type] == "4" #附件
if User.current.id.to_i == params[:id].to_i if User.current.id.to_i == params[:id].to_i
@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc")
else else
@attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc")
end end
end end
@type = params[:type] @type = params[:type]
@limit = 10 @limit = 10
@is_remote = true
@obj_count = @attachments.count @obj_count = @attachments.count
@obj_pages = Paginator.new @obj_count, @limit, params['page'] || 1 @obj_pages = Paginator.new @obj_count, @limit, params['page'] || 1
@offset ||= @obj_pages.offset @offset ||= @obj_pages.offset
@ -1315,6 +1316,7 @@ class UsersController < ApplicationController
end end
@type = params[:type] @type = params[:type]
@limit = 10 @limit = 10
@is_remote = true
@obj_count = @attachments.count @obj_count = @attachments.count
@obj_pages = Paginator.new @obj_count, @limit, params['page'] || 1 @obj_pages = Paginator.new @obj_count, @limit, params['page'] || 1
@offset ||= @obj_pages.offset @offset ||= @obj_pages.offset

View File

@ -1,5 +1,5 @@
<%= form_tag( url_for(:controller => 'users',:action => 'resource_search',:id=>user.id), <%= form_tag( url_for(:controller => 'users',:action => 'resource_search',:id=>user.id),
:remote=>true ,:method => 'post',:class=>'resourcesSearchloadBox',:id=>'resource_search_form') do %> :remote=>true ,:method => 'get',:class=>'resourcesSearchloadBox',:id=>'resource_search_form') do %>
<input type="text" name="search" placeholder="输入资源关键词进行搜索" class="searchResource" /> <input type="text" name="search" placeholder="输入资源关键词进行搜索" class="searchResource" />
<%= hidden_field_tag(:type,type) %> <%= hidden_field_tag(:type,type) %>
<%= submit_tag '',:class=>'homepageSearchIcon',:onfocus=>'this.blur();',:style=>'border-style:none' %> <%= submit_tag '',:class=>'homepageSearchIcon',:onfocus=>'this.blur();',:style=>'border-style:none' %>

View File

@ -1,3 +1,4 @@
<% if attachments.nil? || attachments.empty? %> <% if attachments.nil? || attachments.empty? %>
<% else %> <% else %>
<% attachments.each do |attach| %> <% attachments.each do |attach| %>

View File

@ -1 +1,2 @@
$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>');
$("#pages").html('<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');

View File

@ -103,9 +103,11 @@
</div> </div>
</form> </form>
</div> </div>
<ul class="wlist"> <div>
<ul class="wlist" id="pages">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true%> <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true%>
</ul> </ul>
</div>
<div class="cl"></div> <div class="cl"></div>
<div id="upload_box" style="display: none"> <div id="upload_box" style="display: none">
<%= render :partial => 'upload_resource' ,:locals => {:user=>@user}%> <%= render :partial => 'upload_resource' ,:locals => {:user=>@user}%>
@ -326,7 +328,7 @@ $(".resourcesList").click(function(e) {
'<input name="res_name" id="res_name" ' + '<input name="res_name" id="res_name" ' +
'style="height: 2em;line-height: 2em;overflow: hidden;" onblur="restore();" ' + 'style="height: 2em;line-height: 2em;overflow: hidden;" onblur="restore();" ' +
'value="'+res_name+ 'value="'+res_name+
'"/> <input type="hidden" name="res_id" value="'+id+'"/>'+ '"/> <input type="hidden" id ="res_id" name="res_id" value="'+id+'"/>'+
'<% end %>'); '<% end %>');
$("#res_name").focus(); $("#res_name").focus();
$("html,body").animate({scrollTop:$("#res_name").offset().top},1000) $("html,body").animate({scrollTop:$("#res_name").offset().top},1000)
@ -355,7 +357,7 @@ $(".resourcesList").click(function(e) {
if(confirm('确定修改为 '+name)){ if(confirm('确定修改为 '+name)){
$.post( $.post(
'<%=rename_resource_user_path(@user) %>', '<%=rename_resource_user_path(@user) %>',
$("#res_name_form").serialize(), "res_name="+$('#res_name').val()+"&res_id="+$("#res_id").val(),
function (data){ function (data){
if(data != 'fail'){//修改成功,那么将链接恢复,并且将链接的显示内容改变。链接可以不变 if(data != 'fail'){//修改成功,那么将链接恢复,并且将链接的显示内容改变。链接可以不变
last_line.children().eq(1).html(res_link); last_line.children().eq(1).html(res_link);

View File

@ -1,2 +1,3 @@
$("#search_div").html('<%= escape_javascript( render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} ) %>'); $("#search_div").html('<%= escape_javascript( render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} ) %>');
$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>');
$("#pages").html('<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');

View File

@ -345,7 +345,7 @@ RedmineApp::Application.routes.draw do
match 'code_submit_score_index', :to => 'projects#code_submit_score_index', :via => [:get, :post] match 'code_submit_score_index', :to => 'projects#code_submit_score_index', :via => [:get, :post]
match 'projects_topic_score_index', :to => 'projects#projects_topic_score_index', :via => [:get, :post] match 'projects_topic_score_index', :to => 'projects#projects_topic_score_index', :via => [:get, :post]
get "user_resource" get "user_resource"
post "resource_search" get "resource_search"
post "user_resource_create" post "user_resource_create"
post "user_resource_delete" post "user_resource_delete"
get "search_user_course" get "search_user_course"