二级目录帖子列表中添加编辑功能
This commit is contained in:
parent
df1c70880a
commit
a5be092c16
|
@ -65,25 +65,30 @@ class SubDocumentCommentsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@org_document = OrgDocumentComment.find(params[:id])
|
@sub_document = SubDocumentComment.find(params[:id])
|
||||||
@org_document.update_attributes(:title => params[:org_document_comment][:title], :content => params[:org_document_comment][:content])
|
@sub_document.update_attributes(:title => params[:sub_document_comment][:title], :content => params[:sub_document_comment][:content])
|
||||||
Attachment.attach_files(@org_document, params[:attachments])
|
@organization = OrgSubfield.find(params[:org_subfield_id]).organization
|
||||||
|
# Attachment.attach_files(@org_document, params[:attachments])
|
||||||
# @org_document.save_attachments(params[:attachments])
|
# @org_document.save_attachments(params[:attachments])
|
||||||
if @org_document.parent.nil?
|
if @sub_document.parent.nil?
|
||||||
act = OrgActivity.where("org_act_type='OrgDocumentComment' and org_act_id =?", @org_document.id).first
|
act = OrgActivity.where("org_act_type='SubDocumentComment' and org_act_id =?", @sub_document.id).first
|
||||||
act.update_attributes(:updated_at => @org_document.updated_at)
|
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)
|
# EditorOfDocument.create(:editor_id => User.current.id, :org_document_comment_id => @org_document.id, :created_at => Time.now)
|
||||||
end
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
if params[:flag].to_i == 0
|
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
|
else
|
||||||
if params[:flag].to_i == 1
|
# if params[:flag].to_i == 1
|
||||||
redirect_to org_document_comment_path(@org_document.root.id, :organization_id => @org_document.organization.id)
|
# redirect_to org_document_comment_path(@org_document.root.id, :organization_id => @org_document.organization.id)
|
||||||
else
|
# else
|
||||||
redirect_to organization_path(@org_document.organization.id, :org_subfield_id => params[:org_subfield_id])
|
# redirect_to organization_path(@org_document.organization.id, :org_subfield_id => params[:org_subfield_id])
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -92,6 +97,7 @@ class SubDocumentCommentsController < ApplicationController
|
||||||
def edit
|
def edit
|
||||||
@sub_document = SubDocumentComment.find(params[:id])
|
@sub_document = SubDocumentComment.find(params[:id])
|
||||||
@flag = params[:flag]
|
@flag = params[:flag]
|
||||||
|
render :layout => @organization.switch_type ? 'base_sub_domain' : 'base_org'
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_reply
|
def add_reply
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class SubDomain < ActiveRecord::Base
|
class SubDomain < ActiveRecord::Base
|
||||||
attr_accessible :field_type, :hide, :name, :org_subfield_id, :priority, :status
|
attr_accessible :field_type, :hide, :name, :org_subfield_id, :priority, :status
|
||||||
belongs_to :org_subfield, :foreign_key => :org_subfield_id
|
belongs_to :org_subfield, :foreign_key => :org_subfield_id
|
||||||
has_many :sub_document_comments
|
has_many :sub_document_comments, :dependent => :destroy
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
<!--<%# end %>-->
|
<!--<%# end %>-->
|
||||||
<!--</li>-->
|
<!--</li>-->
|
||||||
<li>
|
<li>
|
||||||
<%= 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" %>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<%= 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',
|
||||||
|
|
|
@ -27,15 +27,15 @@
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<div>
|
<div>
|
||||||
<div class="resources" nhname="new_topic_form">
|
<div class="resources" nhname="new_topic_form">
|
||||||
<%= 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| %>
|
||||||
<div>
|
<div>
|
||||||
<input class="postDetailInput fl mr15" style="margin-bottom:15px;" name="org_document_comment[title]" id="document_title" style="resize:none;" onfocus = "$('#org_document_editor').show();" onblur="check_org_title();" value="<%= @org_document.title %>" />
|
<input class="postDetailInput fl mr15" style="margin-bottom:15px;" name="sub_document_comment[title]" id="document_title" style="resize:none;" onfocus = "$('#org_document_editor').show();" onblur="check_org_title();" value="<%= @sub_document.title %>" />
|
||||||
</div>
|
</div>
|
||||||
<div id="doc_title_hint"></div>
|
<div id="doc_title_hint"></div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<div>
|
<div>
|
||||||
<div class="mt10">
|
<div class="mt10">
|
||||||
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='description_textarea' name="org_document_comment[content]"><%=@org_document.content.html_safe %></textarea>
|
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='description_textarea' name="sub_document_comment[content]"><%=@sub_document.content.html_safe %></textarea>
|
||||||
<%#= kindeditor_tag 'org_document_comment[content]','', :editor_id => 'org_document_description_editor', :height => "150px" %>
|
<%#= kindeditor_tag 'org_document_comment[content]','', :editor_id => 'org_document_description_editor', :height => "150px" %>
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
@ -45,11 +45,11 @@
|
||||||
<p id="e_tips" class="c_grey"></p>
|
<p id="e_tips" class="c_grey"></p>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
|
||||||
<div class="mt10">
|
<!--<div class="mt10">-->
|
||||||
<div class="fl" id="topic_attachments">
|
<!--<div class="fl" id="topic_attachments">-->
|
||||||
<%= render :partial => 'org_document_comments/attachment', :locals => {:container => @org_document} %>
|
<!--<%#= render :partial => 'org_document_comments/attachment', :locals => {:container => @sub_document} %>-->
|
||||||
</div>
|
<!--</div>-->
|
||||||
</div>
|
<!--</div>-->
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<div class="mt5">
|
<div class="mt5">
|
||||||
<a href="javascript:void(0);" class="BlueCirBtnMini fr" id="new_topic_submit_btn">确定</a>
|
<a href="javascript:void(0);" class="BlueCirBtnMini fr" id="new_topic_submit_btn">确定</a>
|
||||||
|
|
|
@ -123,14 +123,14 @@ RedmineApp::Application.routes.draw do
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :sub_domains, :only => [:index, :new, :create, :show, :update, :destroy] do
|
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
|
member do
|
||||||
post 'add_reply'
|
post 'add_reply'
|
||||||
get 'quote'
|
get 'quote'
|
||||||
post 'reply'
|
post 'reply'
|
||||||
post 'add_reply_in_doc'
|
post 'add_reply_in_doc'
|
||||||
delete 'delete_reply'
|
delete 'delete_reply'
|
||||||
get 'edit'
|
match 'edit'
|
||||||
end
|
end
|
||||||
collection do
|
collection do
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue