Merge branch 'yuanke' into develop

This commit is contained in:
yuanke 2016-06-16 14:04:53 +08:00
commit 82ebd1e4c9
9 changed files with 63 additions and 13 deletions

View File

@ -26,7 +26,7 @@ class FilesController < ApplicationController
before_filter :authorize, :except => [:create,:getattachtype,:quote_resource_show,:search,:searchone4reload,:search_project,:quote_resource_show_project,
:search_tag_attachment,:subfield_upload_file,:search_org_subfield_tag_attachment,
:search_tag_attachment,:quote_resource_show_org_subfield,:find_org_subfield_attache,
:search_files_in_subfield,:upload_files_menu,:file_hidden,:republish_file]
:search_files_in_subfield,:upload_files_menu,:file_hidden,:republish_file,:update_file_description]
helper :sort
include SortHelper
@ -911,5 +911,10 @@ class FilesController < ApplicationController
def upload_files_menu
end
end
def update_file_description
@attachment = Attachment.find(params[:id])
@attachment.description = params[:description]
@attachment.save
end
end

View File

@ -9,14 +9,15 @@ class OrgSubfieldsController < ApplicationController
@subfield = OrgSubfield.create(:name => params[:name], :organization_id => params[:organization_id], :priority => @organization.org_subfields.order("priority").last.priority + 1)
if !params[:sub_dir].blank?
sql = "select subfield_subdomain_dirs.* from subfield_subdomain_dirs, org_subfields where subfield_subdomain_dirs.org_subfield_id = org_subfields.id "+
"and org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir]}'"
"and org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir]}'"
if SubfieldSubdomainDir.find_by_sql(sql).count == 0
SubfieldSubdomainDir.create(:org_subfield_id => @subfield.id, :name => params[:sub_dir].downcase)
end
end
@subfield.update_attributes(:field_type => params[:field_type])
#默认类型为帖子
@subfield.update_attributes(:field_type => params[:field_type]||"Post")
# admin配置的类型
update_status_by_type(@subfield, params[:field_type])
update_status_by_type(@subfield, params[:field_type]||"Post")
else
@res = false
end

View File

@ -0,0 +1,5 @@
<p ondblclick=show_edit_file_description('<%= file.id %>')>
资源描述:<% if file.description.blank? %><span style="color:#C5C5BE; cursor:pointer;" title="双击可编辑">点击添加描述</span><% else %><span style="cursor:pointer;" title="双击可编辑"><%= file.description %></span><% end %>
<%#= file.description.blank? ? "该资源暂无描述" : file.description %>
<%= link_to image_tag("../images/signature_edit.png",width:"12px", height: "12px"), "javascript:void(0);", :onclick => "show_edit_file_description("+file.id.to_s+");"%>
</p>

View File

@ -35,10 +35,25 @@
<p class="f_l mb5 fontGrey2">文件大小:<%= number_to_human_size(file.filesize) %></p>
<p class="fl ml15 fontGrey2">下载<%= file.downloads%>&nbsp;&nbsp;|&nbsp;&nbsp;引用<%= file.quotes.nil? ? 0:file.quotes %> </p>
</div>
<% unless file.description.blank? %>
<%# unless file.description.blank? %>
<div class="cl"></div>
<div class="fontGrey2 mb4">资源描述:<%= file.description %></div>
<% end %>
<% if User.current.logged? && ((is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file)) && ((delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course") %>
<div>
<div id="file_description_show_<%= file.id %>" class="fontGrey2 mb4">
<%= render :partial => 'files/file_description', :locals => {:file => file} %>
</div>
<textarea class="homepageSignatureTextarea none" placeholder="请编辑资源描述" id="file_description_edit_<%= file.id %>"
onblur="edit_file_description('<%= update_file_description_course_file_path(@course,file)%>','<%= file.id %>');"><%= file.description %></textarea>
</div>
<% else %>
<div class="fontGrey2 mb4">
<% unless file.description.blank? %>
<div class="cl"></div>
<div class="fontGrey2 mb4">资源描述:<%= file.description %></div>
<% end %>
</div>
<% end %>
<%# end %>
<div class="cl"></div>
<div class="tag_h">
<!-- container_type = 1 代表是课程里的资源 -->

View File

@ -0,0 +1,3 @@
$("#file_description_show_<%= @attachment.id %>").html("<%= escape_javascript render(:partial => "files/file_description", :locals => {:file => @attachment}) %>");
$("#file_description_show_<%= @attachment.id %>").show();
$("#file_description_edit_<%= @attachment.id %>").hide();

View File

@ -1,6 +1,7 @@
<%if @save_flag%>
$('#new_forum_div').slideToggle();$('#create_btn').parent().slideToggle();
$('#reorder_time').click();
//$('#new_forum_div').slideToggle();$('#create_btn').parent().slideToggle();
//$('#reorder_time').click();
window.location.href= "http://"+"<%= Setting.host_name%>"+"/forums/" + "<%= @forum.id%>"
<%else%>
$("#error").html("<%= @forum.errors.full_messages[0]%>").show();
<%end %>

View File

@ -4,6 +4,8 @@
$("#sub_field_left_lists").html("");
$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>");
$("#org_custom_admin").html("<%= escape_javascript(render :partial => 'organizations/org_custom_admin') %>");
//默认选中第一个
$("input[name='field_type']").get(0).checked=true;
<% end %>
$("#subfield_name").val("");
$("#sub_dir").val("");
$("#subfield_name").val("");
$("#sub_dir").val("");

View File

@ -975,7 +975,6 @@ RedmineApp::Application.routes.draw do
match 'delete_softapplications', :via => [:get, :post]
end
end
resources :groups do
member do
get 'autocomplete_for_user'
@ -1114,6 +1113,7 @@ RedmineApp::Application.routes.draw do
match "quote_resource_show", :via => [:get]
get "file_hidden"
post "republish_file"
get "update_file_description"
end
end
resources :memberships, :shallow => true, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do

View File

@ -1480,3 +1480,21 @@ function autoUrl(id){
}
}
//编辑资源描述
function show_edit_file_description(id) {
$("#file_description_show_"+id).hide();
$("#file_description_edit_"+id).show();
$("#file_description_edit_"+id).focus();
}
//编辑资源描述之后提交
function edit_file_description(url,id){
$.get(
url,
{id: id ,description: $("#file_description_edit_"+id).val() },
function (data) {
}
);
}