添加组织文章附件功能
This commit is contained in:
parent
2220e0b7cc
commit
9dc2cb8541
|
@ -242,6 +242,8 @@ class AttachmentsController < ApplicationController
|
|||
format.html { redirect_to_referer_or mobile_version_path }
|
||||
elsif !@attachment.container.nil? && @attachment.container.is_a?(OrgSubfield)
|
||||
format.html {redirect_to_referer_or org_subfield_files_path(@attachment.container)}
|
||||
elsif !@attachment.container.nil? && @attachment.container.is_a?(OrgDocumentComment)
|
||||
format.html {redirect_to_referer_or org_document_comment_path(@attachment.container)}
|
||||
else
|
||||
if @project.nil?
|
||||
format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) }
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
class OrgDocumentCommentsController < ApplicationController
|
||||
before_filter :find_organization, :only => [:new, :create, :show, :index]
|
||||
|
||||
helper :attachments
|
||||
layout 'base_org'
|
||||
|
||||
def new
|
||||
@org_document_comment = OrgDocumentComment.new
|
||||
end
|
||||
|
||||
|
||||
def create
|
||||
@org_document_comment = OrgDocumentComment.new(:organization_id => @organization.id, :creator_id => User.current.id)
|
||||
@org_document_comment.title = params[:org_document_comment][:title]
|
||||
@org_document_comment.content = params[:org_document_comment][:content]
|
||||
@org_document_comment.save_attachments(params[:attachments])
|
||||
if params[:field_id]
|
||||
@org_document_comment.org_subfield_id = params[:field_id].to_i
|
||||
end
|
||||
|
@ -40,6 +42,7 @@ class OrgDocumentCommentsController < ApplicationController
|
|||
def update
|
||||
@org_document = OrgDocumentComment.find(params[:id])
|
||||
@org_document.update_attributes(:title => params[:org_document_comment][:title], :content => params[:org_document_comment][:content])
|
||||
@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)
|
||||
|
|
|
@ -5,6 +5,7 @@ class OrgDocumentComment < ActiveRecord::Base
|
|||
belongs_to :creator, :class_name => 'User', :foreign_key => 'creator_id'
|
||||
has_many :editor_of_documents, :dependent => :destroy
|
||||
acts_as_tree :order => "#{OrgDocumentComment.table_name}.sticky asc, #{OrgDocumentComment.table_name}.created_at desc"
|
||||
acts_as_attachable
|
||||
has_many :org_acts, :class_name => 'OrgActivity',:as =>:org_act ,:dependent => :destroy
|
||||
after_create :document_save_as_org_activity
|
||||
|
||||
|
@ -17,4 +18,9 @@ class OrgDocumentComment < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
def project
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
<style type="text/css">
|
||||
input.is_public,input.is_public_checkbox{height:12px;}
|
||||
input.is_public_checkbox{margin-left:4px;margin-right:4px;}
|
||||
</style>
|
||||
<div class="fl">
|
||||
<span id="attachments_fields" xmlns="http://www.w3.org/1999/html">
|
||||
<% if defined?(container) && container && container.saved_attachments %>
|
||||
<% container.attachments.each_with_index do |attachment, i| %>
|
||||
<span id="attachments_p<%= i %>" class="attachment">
|
||||
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly => 'readonly') %><%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style => "display: inline-block;") %><span class="ispublic-label"><%= l(:field_is_public) %>:</span>
|
||||
<%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public, attachment.is_public == 1 ? true : false, :class => 'is_public') %>
|
||||
<%= if attachment.id.nil?
|
||||
#待补充代码
|
||||
else
|
||||
link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload')
|
||||
end
|
||||
%>
|
||||
<%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %>
|
||||
|
||||
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
|
||||
</span>
|
||||
<div class="cl"></div>
|
||||
<% end %>
|
||||
<% container.saved_attachments.each_with_index do |attachment, i| %>
|
||||
<span id="attachments_p<%= i %>" class="attachment">
|
||||
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly => 'readonly') %>
|
||||
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style => "display: inline-block;") %>
|
||||
<span class="ispublic-label"><%= l(:field_is_public) %>:</span>
|
||||
<%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public, attachment.is_public == 1 ? true : false, :class => 'is_public') %>
|
||||
<%= if attachment.id.nil?
|
||||
#待补充代码
|
||||
else
|
||||
link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload')
|
||||
end
|
||||
%>
|
||||
<%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %>
|
||||
|
||||
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
|
||||
</span>
|
||||
<div class="cl"></div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</span>
|
||||
<div class="cl"></div>
|
||||
<span class="add_attachment" style="font-weight:normal;">
|
||||
<%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %>
|
||||
<!--%= link_to image_tag(),"javascript:void(0)", :onclick => "_file.click()"%-->
|
||||
<%#= button_tag "文件浏览", :type=>"button", :onclick=>"$('#_file').click();",:onmouseover => 'this.focus()',:class => 'sub_btn' %>
|
||||
<a href="javascript:void(0);" onclick="_file.click();" class="AnnexBtn fl mr15">上传附件</a>
|
||||
<%= file_field_tag 'attachments[dummy][file]',
|
||||
:id => '_file',
|
||||
:class => 'file_selector',
|
||||
:multiple => true,
|
||||
:onchange => 'addInputFiles(this);',
|
||||
:style => ie8? ? '' : 'display:none',
|
||||
:data => {
|
||||
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
|
||||
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
|
||||
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
|
||||
:upload_path => uploads_path(:format => 'js'),
|
||||
:description_placeholder => l(:label_optional_description),
|
||||
:field_is_public => l(:field_is_public),
|
||||
:are_you_sure => l(:text_are_you_sure),
|
||||
:file_count => l(:label_file_count),
|
||||
:lebel_file_uploding => l(:lebel_file_uploding),
|
||||
:delete_all_files => l(:text_are_you_sure_all)
|
||||
} %>
|
||||
<span id="upload_file_count">
|
||||
<%= l(:label_no_file_uploaded) %>
|
||||
</span>
|
||||
(<%= l(:label_max_size) %>:
|
||||
<%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
|
||||
</span>
|
||||
|
||||
<% content_for :header_tags do %>
|
||||
<%= javascript_include_tag 'attachments' %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
@ -33,10 +33,15 @@
|
|||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
|
||||
<p id="homework_course_id_span" class="c_red mt5"></p>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="mt10">
|
||||
<div class="fl" id="topic_attachments">
|
||||
<%= render :partial => 'org_document_comments/attachment', :locals => {:container => @org_document} %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="mt5">
|
||||
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="org_document_description_editor.sync();$('#new_org_document_form').submit();">确定</a>
|
||||
<span class="fr mr10 mt3">或</span>
|
||||
|
|
|
@ -39,10 +39,14 @@
|
|||
<%= kindeditor_tag 'org_document_comment[content]','', :editor_id => 'org_document_description_editor', :height => "150px" %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
|
||||
<p id="homework_course_id_span" class="c_red mt5"></p>
|
||||
<div class="cl"></div>
|
||||
<div class="mt10">
|
||||
<div class="fl" id="topic_attachments">
|
||||
<%= render :partial => 'org_document_comments/attachment', :locals => {:container => nil} %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="mt5">
|
||||
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="create_org_document();">确定</a>
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
<%= @document.content.html_safe %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class=" fl" style="width: 600px">
|
||||
<%= link_to_attachments_course @document, :author => false %>
|
||||
</div>
|
||||
<!-- <%# if defined?(home_id) %>
|
||||
<div style="float:right;">最后编辑:<%#= User.find() %></div>
|
||||
<%# end %>-->
|
||||
|
|
Loading…
Reference in New Issue