diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index fee4ec60f..7685b77a8 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -1,166 +1,169 @@ -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 - if @org_document_comment.save - flash.keep[:notice] = l(:notice_successful_create) - EditorOfDocument.create(:editor_id => User.current.id, :org_document_comment_id => @org_document_comment.id, :created_at => @org_document_comment.updated_at) - if params[:field_id] - redirect_to organization_path(@organization, :org_subfield_id => params[:field_id]) - else - redirect_to organization_org_document_comments_path(@organization) - end - else - redirect_to new_org_document_comment_path(:organization_id => @organization.id) - end - end - def show - @document = OrgDocumentComment.find(params[:id]) - end - - def index - if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) - @documents = @organization.org_document_comments.where("parent_id is null").order("created_at desc") - else - render_403 - end - 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]) - @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) - 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) - 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 - end - } - end - end - - def edit - @org_document = OrgDocumentComment.find(params[:id]) - @flag = params[:flag] - @organization = Organization.find(params[:organization_id]) - end - - def add_reply - @document = OrgDocumentComment.find(params[:id]).root - @act = OrgActivity.find(params[:id]) - @comment = OrgDocumentComment.new(:organization_id => @document.organization_id, :creator_id => User.current.id, :reply_id => params[:id]) - @comment.content = params[:org_content] - @document.children << @comment - @document.save - end - - def add_reply_in_doc - @document = OrgDocumentComment.find(params[:id]).root - @comment = OrgDocumentComment.new(:organization_id => @document.organization_id, :creator_id => User.current.id, :reply_id => params[:id]) - @comment.content = params[:org_comment][:org_content] - @document.children << @comment - @document.save - respond_to do |format| - format.html {redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id)} - end - end - - def find_organization - @organization = Organization.find(params[:organization_id]) - end - - def destroy - @org_document_comment = OrgDocumentComment.find(params[:id]) - org = @org_document_comment.organization - if @org_document_comment.id == org.home_id - org.update_attributes(:home_id => nil) - end - if @org_document_comment.destroy - end - respond_to do |format| - format.js - end - end - - def delete_reply - @org_document_comment = OrgDocumentComment.find(params[:id]) - @document = @org_document_comment.root - org = @org_document_comment.organization - @org_document_comment.destroy - respond_to do |format| - format.html {redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id)} - end - end - def quote - @org_comment = OrgDocumentComment.find(params[:id]) - @subject = @org_comment.content - @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') - - @content = "> #{ll(Setting.default_language, :text_user_wrote, User.find(@org_comment.creator_id).realname)}\n> " - @temp = OrgDocumentComment.new - #@course_id = params[:course_id] - @temp.content = "
#{ll(Setting.default_language, :text_user_wrote, User.find(@org_comment.creator_id).realname)}
#{@org_comment.content.html_safe}
".html_safe - respond_to do | format| - format.js - end - end - - def reply - @document = OrgDocumentComment.find(params[:id]).root - @quote = params[:quote][:quote] - @org_document = OrgDocumentComment.new(:creator_id => User.current.id, :reply_id => params[:id]) - - # params[:blog_comment][:sticky] = params[:blog_comment][:sticky] || 0 - # params[:blog_comment][:locked] = params[:blog_comment][:locked] || 0 - @org_document.title = params[:org_document_comment][:title] - @org_document.content = params[:org_document_comment][:content] - @org_document.content = @quote + @org_document.content - #@org_document.title = "RE: #{@article.title}" unless params[:blog_comment][:title] - @document.children << @org_document - # @user_activity_id = params[:user_activity_id] - # user_activity = UserActivity.where("act_type='BlogComment' and act_id =#{@article.id}").first - # if user_activity - # user_activity.updated_at = Time.now - # user_activity.save - # end - # attachments = Attachment.attach_files(@org_document, params[:attachments]) - # render_attachment_warning_if_needed(@org_document) - #@article.save - # redirect_to user_blogs_path(:user_id=>params[:user_id]) - respond_to do |format| - format.html { - # if params[:course_id] #如果呆了course_id过来了,那么这是要跳到课程大纲去的 - # redirect_to syllabus_course_path(:id=>params[:course_id]) - # else - redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id) - # end - - } - format.js - end - end -end +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 + if @org_document_comment.save + flash.keep[:notice] = l(:notice_successful_create) + EditorOfDocument.create(:editor_id => User.current.id, :org_document_comment_id => @org_document_comment.id, :created_at => @org_document_comment.updated_at) + if params[:field_id] + redirect_to organization_path(@organization, :org_subfield_id => params[:field_id]) + else + redirect_to organization_org_document_comments_path(@organization) + end + else + redirect_to new_org_document_comment_path(:organization_id => @organization.id) + end + end + + def show + @document = OrgDocumentComment.find(params[:id]) + end + + def index + if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) + @documents = @organization.org_document_comments.where("parent_id is null").order("created_at desc") + else + render_403 + end + 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]) + # @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) + 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) + 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 + end + } + end + end + + def edit + @org_document = OrgDocumentComment.find(params[:id]) + @flag = params[:flag] + @organization = Organization.find(params[:organization_id]) + end + + def add_reply + @document = OrgDocumentComment.find(params[:id]).root + @act = OrgActivity.find(params[:id]) + @comment = OrgDocumentComment.new(:organization_id => @document.organization_id, :creator_id => User.current.id, :reply_id => params[:id]) + @comment.content = params[:org_content] + @document.children << @comment + @document.save + end + + def add_reply_in_doc + @document = OrgDocumentComment.find(params[:id]).root + @comment = OrgDocumentComment.new(:organization_id => @document.organization_id, :creator_id => User.current.id, :reply_id => params[:id]) + @comment.content = params[:org_comment][:org_content] + @document.children << @comment + @document.save + respond_to do |format| + format.html {redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id)} + end + end + + def find_organization + @organization = Organization.find(params[:organization_id]) + end + + def destroy + @org_document_comment = OrgDocumentComment.find(params[:id]) + org = @org_document_comment.organization + if @org_document_comment.id == org.home_id + org.update_attributes(:home_id => nil) + end + if @org_document_comment.destroy + end + respond_to do |format| + format.js + end + end + + def delete_reply + @org_document_comment = OrgDocumentComment.find(params[:id]) + @document = @org_document_comment.root + org = @org_document_comment.organization + @org_document_comment.destroy + respond_to do |format| + format.html {redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id)} + end + end + def quote + @org_comment = OrgDocumentComment.find(params[:id]) + @subject = @org_comment.content + @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') + + @content = "> #{ll(Setting.default_language, :text_user_wrote, User.find(@org_comment.creator_id).realname)}\n> " + @temp = OrgDocumentComment.new + #@course_id = params[:course_id] + @temp.content = "
#{ll(Setting.default_language, :text_user_wrote, User.find(@org_comment.creator_id).realname)}
#{@org_comment.content.html_safe}
".html_safe + respond_to do | format| + format.js + end + end + + def reply + @document = OrgDocumentComment.find(params[:id]).root + @quote = params[:quote][:quote] + @org_document = OrgDocumentComment.new(:creator_id => User.current.id, :reply_id => params[:id]) + + # params[:blog_comment][:sticky] = params[:blog_comment][:sticky] || 0 + # params[:blog_comment][:locked] = params[:blog_comment][:locked] || 0 + @org_document.title = params[:org_document_comment][:title] + @org_document.content = params[:org_document_comment][:content] + @org_document.content = @quote + @org_document.content + #@org_document.title = "RE: #{@article.title}" unless params[:blog_comment][:title] + @document.children << @org_document + # @user_activity_id = params[:user_activity_id] + # user_activity = UserActivity.where("act_type='BlogComment' and act_id =#{@article.id}").first + # if user_activity + # user_activity.updated_at = Time.now + # user_activity.save + # end + # attachments = Attachment.attach_files(@org_document, params[:attachments]) + # render_attachment_warning_if_needed(@org_document) + #@article.save + # redirect_to user_blogs_path(:user_id=>params[:user_id]) + respond_to do |format| + format.html { + # if params[:course_id] #如果呆了course_id过来了,那么这是要跳到课程大纲去的 + # redirect_to syllabus_course_path(:id=>params[:course_id]) + # else + redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id) + # end + + } + format.js + end + end +end diff --git a/app/views/attachments/_form_course.html.erb b/app/views/attachments/_form_course.html.erb index ef5385647..348c5339d 100644 --- a/app/views/attachments/_form_course.html.erb +++ b/app/views/attachments/_form_course.html.erb @@ -61,8 +61,7 @@ :are_you_sure => l(:text_are_you_sure), :file_count => l(:label_file_count), :delete_all_files => l(:text_are_you_sure_all), - :lebel_file_uploding => l(:lebel_file_uploding), - :containerid => "#{container.id}" + :lebel_file_uploding => l(:lebel_file_uploding) } %> <% if container.nil? %> <%= l(:label_no_file_uploaded)%> diff --git a/app/views/boards/_project_message_edit.html.erb b/app/views/boards/_project_message_edit.html.erb new file mode 100644 index 000000000..88297bd79 --- /dev/null +++ b/app/views/boards/_project_message_edit.html.erb @@ -0,0 +1,16 @@ + +
+
+
+ 编辑帖子 +
+
+ <%= render :partial => 'boards/project_new_topic', + :locals => {:f => f, :edit_mode => edit_mode, :topic => topic, :project => project} %> +
\ No newline at end of file diff --git a/app/views/messages/edit.html.erb b/app/views/messages/edit.html.erb index 624174b14..7543e16e2 100644 --- a/app/views/messages/edit.html.erb +++ b/app/views/messages/edit.html.erb @@ -1,26 +1,16 @@ <% if @message.project %> -
-

<%= l(:label_course_board) %>

-
- - - <%#= board_breadcrumb(@message) %> - -
- -
+ <%= render :partial => 'boards/project_message_edit', + :locals => {:f => f, :edit_mode => true, :topic => @message, :project => @message.project} %> + + <%#= link_to l(:button_cancel), board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id)), :class => "blue_btn grey_btn fl c_white" %> <% end %> + <% elsif @message.course %> <%= form_for @message, { :as => :message, @@ -31,7 +21,6 @@ } do |f| %> <%= render :partial => 'boards/course_message_edit', :locals => {:f => f, :edit_mode => true, :topic => @message, :course => @message.course} %> - <% end %> <% end %> diff --git a/app/views/org_document_comments/_attachment.html.erb b/app/views/org_document_comments/_attachment.html.erb index 9a0cbc0cf..86298a330 100644 --- a/app/views/org_document_comments/_attachment.html.erb +++ b/app/views/org_document_comments/_attachment.html.erb @@ -1,79 +1,79 @@ - -
- -<% if defined?(container) && container && container.saved_attachments %> - <% container.attachments.each_with_index do |attachment, i| %> - - <%= 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;") %><%= l(:field_is_public) %>: - <%= 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}" %> - -
- <% end %> - <% container.saved_attachments.each_with_index do |attachment, i| %> - - <%= 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;") %> - <%= l(:field_is_public) %>: - <%= 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}" %> - -
- <% end %> -<% end %> -
-
- - <%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %> - - <%#= button_tag "文件浏览", :type=>"button", :onclick=>"$('#_file').click();",:onmouseover => 'this.focus()',:class => 'sub_btn' %> - 上传附件 - <%= 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) - } %> - - <%= l(:label_no_file_uploaded) %> - - (<%= l(:label_max_size) %>: - <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) - - - <% content_for :header_tags do %> - <%= javascript_include_tag 'attachments' %> - <% end %> -
- + +
+ +<% if defined?(container) && container && container.saved_attachments %> + <% container.attachments.each_with_index do |attachment, i| %> + + <%= 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;") %><%= l(:field_is_public) %>: + <%= 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}" %> + +
+ <% end %> + <% container.saved_attachments.each_with_index do |attachment, i| %> + + <%= 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;") %> + <%= l(:field_is_public) %>: + <%= 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}" %> + +
+ <% end %> +<% end %> +
+
+ + <%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %> + + <%#= button_tag "文件浏览", :type=>"button", :onclick=>"$('#_file').click();",:onmouseover => 'this.focus()',:class => 'sub_btn' %> + 上传附件 + <%= 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) + } %> + + <%= l(:label_no_file_uploaded) %> + + (<%= l(:label_max_size) %>: + <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) + + + <% content_for :header_tags do %> + <%= javascript_include_tag 'attachments' %> + <% end %> +
+ diff --git a/app/views/org_document_comments/_new.html.erb b/app/views/org_document_comments/_new.html.erb index 8d9eb6b02..3d8e8bc23 100644 --- a/app/views/org_document_comments/_new.html.erb +++ b/app/views/org_document_comments/_new.html.erb @@ -45,10 +45,14 @@
-

- +
+
+ <%= render :partial => 'org_document_comments/attachment', :locals => {:container => nil} %> +
+
+
确定 diff --git a/app/views/organizations/_project_message.html.erb b/app/views/organizations/_project_message.html.erb index 2708bb546..037dfe61b 100644 --- a/app/views/organizations/_project_message.html.erb +++ b/app/views/organizations/_project_message.html.erb @@ -16,10 +16,10 @@
<% if activity.parent_id.nil? %> - <%= link_to activity.subject.to_s.html_safe, project_boards_path(activity.project,:parent_id =>activity.id, :topic_id => activity.id), :class=> "postGrey" + <%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board,activity), :class=> "postGrey" %> <% else %> - <%= link_to activity.parent.subject.to_s.html_safe, project_boards_path(activity.project,:parent_id =>activity.parent_id, :topic_id => activity.id), :class=> "postGrey" + <%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board,activity), :class=> "postGrey" %> <% end %>