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'