From 2e94fbee8144fe707dbb99c3fabe211e7d0e34cf Mon Sep 17 00:00:00 2001 From: huang Date: Sun, 9 Oct 2016 15:09:18 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E3=80=81=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E3=80=81=E7=BB=84=E7=BB=87=E8=B5=84=E6=BA=90=E6=8F=8F=E8=BF=B0?= =?UTF-8?q?=E8=BF=87=E9=95=BF=E4=B8=8D=E8=83=BD=E6=8F=90=E4=BA=A4=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 9 ++++++++- app/views/files/_org_subfield_list.html.erb | 11 +++++++++-- app/views/files/_project_list.html.erb | 11 +++++++++-- app/views/files/_resource_detail.html.erb | 13 ++++++++++--- app/views/files/edit_file_description.js.erb | 3 +++ config/routes.rb | 3 +++ 6 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 app/views/files/edit_file_description.js.erb diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 7318a4dc2..54babdd64 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,:update_file_description] + :search_files_in_subfield,:upload_files_menu,:file_hidden,:republish_file,:update_file_description, :edit_file_description] helper :sort include SortHelper @@ -981,6 +981,13 @@ class FilesController < ApplicationController def upload_files_menu end + + def edit_file_description + @attachment = Attachment.find(params[:id]) + @attachment.description = params[:file_description_edit] + @attachment.save + end + def update_file_description @attachment = Attachment.find(params[:id]) @attachment.description = params[:description] diff --git a/app/views/files/_org_subfield_list.html.erb b/app/views/files/_org_subfield_list.html.erb index de37ed054..45aa7095b 100644 --- a/app/views/files/_org_subfield_list.html.erb +++ b/app/views/files/_org_subfield_list.html.erb @@ -43,8 +43,10 @@
<%= render :partial => 'files/file_description', :locals => {:file => file} %>
- + <%= form_tag(edit_file_description_org_subfield_file_path(file, :org_subfield_id => org_subfield.id ),:remote=>'true', :method => :post, :id=>"files_query_form_#{file.id}") do %> + + <% end %> <% else %>
@@ -108,3 +110,8 @@ <%end%> <% end%> + \ No newline at end of file diff --git a/app/views/files/_project_list.html.erb b/app/views/files/_project_list.html.erb index faf254015..3193f4b42 100644 --- a/app/views/files/_project_list.html.erb +++ b/app/views/files/_project_list.html.erb @@ -40,8 +40,10 @@
<%= render :partial => 'files/file_description', :locals => {:file => file} %>
- + <%= form_tag(edit_file_description_project_file_path(file, :project_id => project.id),:remote=>'true', :method => :post, :id=>"files_query_form_#{file.id}") do %> + + <% end %>
<% else %>
@@ -70,6 +72,11 @@ <%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true%> + diff --git a/app/views/files/_resource_detail.html.erb b/app/views/files/_resource_detail.html.erb index b60814afd..08b85ab2f 100644 --- a/app/views/files/_resource_detail.html.erb +++ b/app/views/files/_resource_detail.html.erb @@ -42,8 +42,10 @@
<%= render :partial => 'files/file_description', :locals => {:file => file} %>
- + <%= form_tag(edit_file_description_course_file_path(file, :course_id => @course.id),:remote=>'true', :method => :post, :id=>"files_query_form_#{file.id}") do %> + + <% end %>
<% else %>
@@ -99,4 +101,9 @@
-
\ No newline at end of file +
+ diff --git a/app/views/files/edit_file_description.js.erb b/app/views/files/edit_file_description.js.erb new file mode 100644 index 000000000..40b47a2ec --- /dev/null +++ b/app/views/files/edit_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(); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 4ff75cbf9..7ca24d861 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -133,6 +133,7 @@ RedmineApp::Application.routes.draw do member do match "quote_resource_show_org_subfield", :via => [:get] get "update_file_description" + post "edit_file_description" end end @@ -809,6 +810,7 @@ RedmineApp::Application.routes.draw do match "quote_resource_show", :via => [:get] get "file_hidden" get "update_file_description" + post "edit_file_description" end end @@ -1219,6 +1221,7 @@ RedmineApp::Application.routes.draw do get "file_hidden" post "republish_file" get "update_file_description" + post "edit_file_description" end end resources :memberships, :shallow => true, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do