From 02d61860454cc9cd5406353d8626f88188613c88 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 5 May 2016 16:43:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E7=BA=A7=E5=9F=9F=E5=90=8D=E8=AE=A8?= =?UTF-8?q?=E8=AE=BA=E5=B8=96=E5=AD=90=E6=B7=BB=E5=8A=A0=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sub_document_comments_controller.rb | 15 +++++++-------- .../_show_sub_document.html.erb | 4 ++-- app/views/sub_document_comments/destroy.js.erb | 6 ++++++ config/routes.rb | 2 +- 4 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 app/views/sub_document_comments/destroy.js.erb diff --git a/app/controllers/sub_document_comments_controller.rb b/app/controllers/sub_document_comments_controller.rb index e5a004bf8..9bd0db8de 100644 --- a/app/controllers/sub_document_comments_controller.rb +++ b/app/controllers/sub_document_comments_controller.rb @@ -1,5 +1,5 @@ class SubDocumentCommentsController < ApplicationController - before_filter :find_subdomain_and_subfield, :only => [:new, :create, :show, :index] + before_filter :find_subdomain_and_subfield, :only => [:new, :create, :show, :index, :destroy] before_filter :find_subfield_content, :only => [:show, :index] helper :attachments,:organizations layout 'base_sub_domain' @@ -122,14 +122,13 @@ class SubDocumentCommentsController < ApplicationController end def destroy - @sub_document_comment = OrgDocumentComment.find(params[:id]) - org = @sub_document_comment.organization - if @sub_document_comment.id == org.home_id - org.update_attributes(:home_id => nil) - end - if @sub_document_comment.destroy - end + @sub_document_comment = SubDocumentComment.find(params[:id]) + @sub_document_comment.destroy + rescue ActiveRecord::RecordNotFound respond_to do |format| + # format.html{ + # redirect_to org_subfield_sub_domain_sub_document_comments_path(:id => params[:sub_domain_id], :org_subfield_id => params[:org_subfield_id]) + # } format.js end end diff --git a/app/views/sub_document_comments/_show_sub_document.html.erb b/app/views/sub_document_comments/_show_sub_document.html.erb index 83607f046..c71e14a0c 100644 --- a/app/views/sub_document_comments/_show_sub_document.html.erb +++ b/app/views/sub_document_comments/_show_sub_document.html.erb @@ -46,10 +46,10 @@
  • - <%#= link_to "编辑文章", org_subfield_sub_domain_sub_document_comment_path(document, :org_subfield_id=> params[:org_subfield_id], :sub_domain_id => document.sub_domain.id, :flag => flag), :method => 'edit', :class => "postOptionLink" %> + <%= link_to "编辑文章", org_subfield_sub_domain_sub_document_comment_path(document, :org_subfield_id=> params[:org_subfield_id], :sub_domain_id => document.sub_domain.id, :flag => flag), :method => 'edit', :class => "postOptionLink" %>
  • - <%#= link_to "删除文章", org_subfield_sub_domain_sub_document_comment_path(document, :org_subfield_id=> params[:org_subfield_id], :sub_domain_id => document.sub_domain.id, :flag => flag), :method => 'delete', + <%= link_to "删除文章", org_subfield_sub_domain_sub_document_comment_path(document, :org_subfield_id=> params[:org_subfield_id], :sub_domain_id => document.sub_domain.id, :flag => flag), :method => 'delete', :data => {:confirm => l(:text_are_you_sure)}, :remote => true, :class => 'postOptionLink' %>
  • diff --git a/app/views/sub_document_comments/destroy.js.erb b/app/views/sub_document_comments/destroy.js.erb new file mode 100644 index 000000000..cc63e66d8 --- /dev/null +++ b/app/views/sub_document_comments/destroy.js.erb @@ -0,0 +1,6 @@ +//location.reload(); +<% if params[:detail_page] %> +window.location.href = '<%= org_subfield_sub_domain_sub_document_comments_path(@subdomain, :org_subfield_id => @org_subfield.id)%>'; +<% else %> +window.location.reload(); +<% end %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 0816dadc7..14e3b409d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -119,7 +119,7 @@ RedmineApp::Application.routes.draw do end resources :sub_domains, :only => [:index, :new, :create, :show, :update, :destroy] do - resources :sub_document_comments, :only => [:index, :new, :create, :show] do + resources :sub_document_comments, :only => [:index, :new, :create, :show, :update, :destroy] do member do post 'add_reply' get 'quote'