diff --git a/app/controllers/sub_document_comments_controller.rb b/app/controllers/sub_document_comments_controller.rb index ed12ac8f7..502e815d2 100644 --- a/app/controllers/sub_document_comments_controller.rb +++ b/app/controllers/sub_document_comments_controller.rb @@ -65,25 +65,30 @@ class SubDocumentCommentsController < ApplicationController end def update - @org_document = OrgDocumentComment.find(params[:id]) - @org_document.update_attributes(:title => params[:org_document_comment][:title], :content => params[:org_document_comment][:content]) - Attachment.attach_files(@org_document, params[:attachments]) + @sub_document = SubDocumentComment.find(params[:id]) + @sub_document.update_attributes(:title => params[:sub_document_comment][:title], :content => params[:sub_document_comment][:content]) + @organization = OrgSubfield.find(params[:org_subfield_id]).organization + # Attachment.attach_files(@org_document, params[:attachments]) # @org_document.save_attachments(params[:attachments]) - if @org_document.parent.nil? - act = OrgActivity.where("org_act_type='OrgDocumentComment' and org_act_id =?", @org_document.id).first - act.update_attributes(:updated_at => @org_document.updated_at) - EditorOfDocument.create(:editor_id => User.current.id, :org_document_comment_id => @org_document.id, :created_at => Time.now) + if @sub_document.parent.nil? + act = OrgActivity.where("org_act_type='SubDocumentComment' and org_act_id =?", @sub_document.id).first + act.update_attributes(:updated_at => @sub_document.updated_at) + # EditorOfDocument.create(:editor_id => User.current.id, :org_document_comment_id => @org_document.id, :created_at => Time.now) end respond_to do |format| format.html { if params[:flag].to_i == 0 - redirect_to organization_org_document_comments_path(:organization_id => @org_document.organization.id) + + # render :action => 'index', :layout => @organization.switch_type ? 'base_sub_domain' : 'base_org' + redirect_to org_subfield_sub_domain_sub_document_comments_path(:org_subfield_id => params[:org_subfield_id], :sub_domain_id => params[:sub_domain_id]) + # render :layout => @organization.switch_type ? 'base_sub_domain' : 'base_org' + # redirect_to organization_path(@organization) else - if params[:flag].to_i == 1 - redirect_to org_document_comment_path(@org_document.root.id, :organization_id => @org_document.organization.id) - else - redirect_to organization_path(@org_document.organization.id, :org_subfield_id => params[:org_subfield_id]) - end + # if params[:flag].to_i == 1 + # redirect_to org_document_comment_path(@org_document.root.id, :organization_id => @org_document.organization.id) + # else + # redirect_to organization_path(@org_document.organization.id, :org_subfield_id => params[:org_subfield_id]) + # end end } end @@ -92,6 +97,7 @@ class SubDocumentCommentsController < ApplicationController def edit @sub_document = SubDocumentComment.find(params[:id]) @flag = params[:flag] + render :layout => @organization.switch_type ? 'base_sub_domain' : 'base_org' end def add_reply diff --git a/app/models/sub_domain.rb b/app/models/sub_domain.rb index 831edf17d..0ae325e1a 100644 --- a/app/models/sub_domain.rb +++ b/app/models/sub_domain.rb @@ -1,5 +1,5 @@ class SubDomain < ActiveRecord::Base attr_accessible :field_type, :hide, :name, :org_subfield_id, :priority, :status belongs_to :org_subfield, :foreign_key => :org_subfield_id - has_many :sub_document_comments + has_many :sub_document_comments, :dependent => :destroy 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 0027417ab..cc09042e3 100644 --- a/app/views/sub_document_comments/_show_sub_document.html.erb +++ b/app/views/sub_document_comments/_show_sub_document.html.erb @@ -46,7 +46,7 @@
  • - <%= link_to "编辑文章", edit_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 => 'update', :class => "postOptionLink" %> + <%= link_to "编辑文章", edit_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), :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', diff --git a/app/views/sub_document_comments/edit.html.erb b/app/views/sub_document_comments/edit.html.erb index 70b79fcc8..7fe93d79b 100644 --- a/app/views/sub_document_comments/edit.html.erb +++ b/app/views/sub_document_comments/edit.html.erb @@ -27,15 +27,15 @@
    - <%= form_tag url_for(:controller => 'org_document_comments',:action => 'update', :id => @org_document.id, :flag => @flag, :org_subfield_id => params[:org_subfield_id]),:method => 'put', :id => 'new_org_document_form' do |f| %> + <%= form_tag url_for(:controller => 'sub_document_comments',:action => 'update', :id => @sub_document.id, :flag => @flag, :org_subfield_id => params[:org_subfield_id], :sub_domain_id => params[:sub_domain_id]), :method => 'put', :id => 'new_org_document_form' do |f| %>
    - +
    - + <%#= kindeditor_tag 'org_document_comment[content]','', :editor_id => 'org_document_description_editor', :height => "150px" %>
    @@ -45,11 +45,11 @@

    -
    -
    - <%= render :partial => 'org_document_comments/attachment', :locals => {:container => @org_document} %> -
    -
    + + + + +
    确定 diff --git a/app/views/sub_document_comments/update.js.erb b/app/views/sub_document_comments/update.js.erb new file mode 100644 index 000000000..e69de29bb diff --git a/config/routes.rb b/config/routes.rb index 848234bd7..8cc4d1134 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -123,14 +123,14 @@ 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, :update, :destroy] do + resources :sub_document_comments, :only => [:index, :new, :create, :show, :update, :destroy, :edit] do member do post 'add_reply' get 'quote' post 'reply' post 'add_reply_in_doc' delete 'delete_reply' - get 'edit' + match 'edit' end collection do end