From a2d1b6d6464e8f5f7003918041c05a22949c639d Mon Sep 17 00:00:00 2001
From: yuanke <249218296@qq.com>
Date: Wed, 15 Jun 2016 17:01:53 +0800
Subject: [PATCH 1/3] =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=9B=9E=E5=A4=8D?=
=?UTF-8?q?=E7=82=B9=E7=99=BB=E5=BD=95=E7=9B=B4=E6=8E=A5=E8=B7=B3=E5=85=A5?=
=?UTF-8?q?=E7=99=BB=E5=BD=95=E7=95=8C=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/users/_show_unlogged.html.erb | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/app/views/users/_show_unlogged.html.erb b/app/views/users/_show_unlogged.html.erb
index cd59123b1..223ee3f40 100644
--- a/app/views/users/_show_unlogged.html.erb
+++ b/app/views/users/_show_unlogged.html.erb
@@ -1,13 +1,4 @@
-
登录后可添加回复
+
登录后可添加回复
<%#= link_to "登录", signin_path, :class => "linkBlue", :target => "_blank" %>
-
-
\ No newline at end of file
+
\ No newline at end of file
From 1023b94f0d6561f66253d9aadc1ff04dfd268d55 Mon Sep 17 00:00:00 2001
From: yuanke <249218296@qq.com>
Date: Wed, 15 Jun 2016 17:22:39 +0800
Subject: [PATCH 2/3] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E8=B4=B4=E5=90=A7?=
=?UTF-8?q?=E4=B9=8B=E5=90=8E=E8=BD=AC=E5=85=A5=E8=BF=99=E4=B8=AA=E8=B4=B4?=
=?UTF-8?q?=E5=90=A7=E7=95=8C=E9=9D=A2,=E7=BB=84=E7=BB=87=E9=85=8D?=
=?UTF-8?q?=E7=BD=AE=E6=A0=8F=E7=9B=AE=E9=BB=98=E8=AE=A4=E9=80=89=E6=8B=A9?=
=?UTF-8?q?=E7=AC=AC=E4=B8=80=E9=A1=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/org_subfields_controller.rb | 7 ++++---
app/views/forums/create.js.erb | 5 +++--
app/views/org_subfields/create.js.erb | 6 ++++--
3 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb
index 34e996494..2b41983cc 100644
--- a/app/controllers/org_subfields_controller.rb
+++ b/app/controllers/org_subfields_controller.rb
@@ -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
diff --git a/app/views/forums/create.js.erb b/app/views/forums/create.js.erb
index 88e535e72..8323ec6d7 100644
--- a/app/views/forums/create.js.erb
+++ b/app/views/forums/create.js.erb
@@ -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 %>
\ No newline at end of file
diff --git a/app/views/org_subfields/create.js.erb b/app/views/org_subfields/create.js.erb
index 952ed7b2c..2149f6dcd 100644
--- a/app/views/org_subfields/create.js.erb
+++ b/app/views/org_subfields/create.js.erb
@@ -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("");
\ No newline at end of file
+ $("#subfield_name").val("");
+ $("#sub_dir").val("");
\ No newline at end of file
From 278160567046973b54e623ac26dff097103f1555 Mon Sep 17 00:00:00 2001
From: yuanke <249218296@qq.com>
Date: Thu, 16 Jun 2016 14:04:12 +0800
Subject: [PATCH 3/3] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=B5=84=E6=BA=90?=
=?UTF-8?q?=E6=8F=8F=E8=BF=B0=E5=A2=9E=E5=8A=A0=E5=8F=AF=E7=BC=96=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/files_controller.rb | 9 ++++++--
app/views/files/_file_description.html.erb | 5 +++++
app/views/files/_resource_detail.html.erb | 21 ++++++++++++++++---
.../files/update_file_description.js.erb | 3 +++
config/routes.rb | 2 +-
public/javascripts/application.js | 18 ++++++++++++++++
6 files changed, 52 insertions(+), 6 deletions(-)
create mode 100644 app/views/files/_file_description.html.erb
create mode 100644 app/views/files/update_file_description.js.erb
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index 7ec796b61..1c05399c4 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -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
diff --git a/app/views/files/_file_description.html.erb b/app/views/files/_file_description.html.erb
new file mode 100644
index 000000000..5d46eaaeb
--- /dev/null
+++ b/app/views/files/_file_description.html.erb
@@ -0,0 +1,5 @@
+')>
+ 资源描述:<% if file.description.blank? %>点击添加描述<% else %><%= file.description %><% 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+");"%>
+
\ No newline at end of file
diff --git a/app/views/files/_resource_detail.html.erb b/app/views/files/_resource_detail.html.erb
index 2a03723ca..e7d43a9d4 100644
--- a/app/views/files/_resource_detail.html.erb
+++ b/app/views/files/_resource_detail.html.erb
@@ -35,10 +35,25 @@
文件大小:<%= number_to_human_size(file.filesize) %>
下载<%= file.downloads%> | 引用<%= file.quotes.nil? ? 0:file.quotes %>
- <% unless file.description.blank? %>
+ <%# unless file.description.blank? %>
- 资源描述:<%= file.description %>
- <% 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") %>
+
+
+ <%= render :partial => 'files/file_description', :locals => {:file => file} %>
+
+
+
+ <% else %>
+
+ <% unless file.description.blank? %>
+
+
资源描述:<%= file.description %>
+ <% end %>
+
+ <% end %>
+ <%# end %>
diff --git a/app/views/files/update_file_description.js.erb b/app/views/files/update_file_description.js.erb
new file mode 100644
index 000000000..2954fb567
--- /dev/null
+++ b/app/views/files/update_file_description.js.erb
@@ -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();
diff --git a/config/routes.rb b/config/routes.rb
index e4b462d93..a778a8016 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -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
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index 73b667740..0437125e8 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -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) {
+
+ }
+ );
+}
+