From acf4a64e6ae833a2a9662df644094d2a0c941712 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 7 Jun 2016 15:40:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E7=BA=A7=E5=B8=96=E5=AD=90=E5=AD=90?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org_document_comments_controller.rb | 7 +- ..._show_custom_org_document_comment.html.erb | 111 ++++++++++ app/views/org_document_comments/show.html.erb | 196 +++++++++--------- 3 files changed, 217 insertions(+), 97 deletions(-) create mode 100644 app/views/org_document_comments/_show_custom_org_document_comment.html.erb diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index dd237de17..43e95a0e9 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -38,6 +38,11 @@ class OrgDocumentCommentsController < ApplicationController def show @document = OrgDocumentComment.find(params[:id]) + @org_subfield = OrgSubfield.where(:id => @document.org_subfield_id).first + @subfield_content = @organization.org_subfields.order("priority") + respond_to do |format| + format.html {render :layout => @organization.switch_type ? 'base_org_custom' : 'base_org'} + end end def index @@ -91,7 +96,7 @@ class OrgDocumentCommentsController < ApplicationController 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] + @comment.content = params[:org_content] @document.children << @comment @document.save respond_to do |format| diff --git a/app/views/org_document_comments/_show_custom_org_document_comment.html.erb b/app/views/org_document_comments/_show_custom_org_document_comment.html.erb new file mode 100644 index 000000000..ec2a1ca8f --- /dev/null +++ b/app/views/org_document_comments/_show_custom_org_document_comment.html.erb @@ -0,0 +1,111 @@ +
+
+
您的位置:<%= link_to "首页", organization_path(@organization), :class => "sn-link-grey2" %> > + <%=link_to @org_subfield.name, organization_path(@organization, :org_subfield_id => @org_subfield.id), :class => "sn-link-grey2" %> > + <%= @document.title %> +
+
+
+

<%= @document.title %>

+
+

来源:<%= @org_subfield.name %> 发布时间:<%= format_date(@document.created_at) %>

+

<%= @document.content.html_safe %>

+
+
+ + <% if User.current.logged? %> + <% comments_for_doc = @document.children.reorder("created_at desc") %> + <% count = @document.children.count() %> +
+

留言板<%= count %>条留言

+ <%= form_for :org_comment, :url => {:action => 'add_reply_in_doc',:controller => 'org_document_comments', :id => @document.id, :flag => true}, :html => {:multipart => true, :id => 'message_form', :class => "sn-reply-form", } do |f| %> + + <%#= f.kindeditor :sub_content,:width=>'99%',:height => '100px;',:editor_id=>'message_content_editor', :class => "sn-reply-text" %> +
+ 发表 +
+ + <%#= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'message_content_editor.html("");', :class => " grey_btn fr c_white mt10 mr5" %> + <% end %> + +
+

全部评论

+ +
+ <% comments_for_doc.each_with_index do |reply,i| %> +
+ + <%= link_to User.find(reply.creator_id).realname, user_url_in_org(reply.creator_id), :class => "sn-reply-username fl" %><%= time_from_now(reply.created_at) %> +
+ <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id => reply.id, :content=> reply.content} %> + <%#= reply.content.html_safe unless reply.content.nil? %> +
+ +
+
+ <% end %> +
+ <% if count > 3 %> + + <% end %> +
+
+ <% end %> +
+ + \ No newline at end of file diff --git a/app/views/org_document_comments/show.html.erb b/app/views/org_document_comments/show.html.erb index c7adc39fb..dfa37bfb6 100644 --- a/app/views/org_document_comments/show.html.erb +++ b/app/views/org_document_comments/show.html.erb @@ -1,72 +1,75 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"create_kindeditor",'blog' %> - -
-
-
- <%= link_to image_tag(url_to_avatar(User.find(@document.creator_id)), :width => 45, :heigth => 45), user_url_in_org(@document.creator_id) %> -
-
-
- <%= link_to User.find(@document.creator_id), user_url_in_org(@document.creator_id), :class => "newsBlue mr15" %> - TO  <%= link_to @document.organization.name, organization_path(@document.organization), :class => "newsBlue" %> - | - <% if @document.organization.home_id == @document.id %> - 首页 - <% else %> - 组织文章 - <% end %> -
-
<%= link_to @document.title, org_document_comment_path(:id => @document.id, :organization_id => @document.organization.id) %>
-
- 发布时间:<%= format_activity_day(@document.created_at) %> <%= format_time(@document.created_at, false) %>
- <% unless @document.content.blank? %> -
- <%= @document.content.html_safe %> +<% if @organization.switch_type %> + <%= render :partial => 'show_custom_org_document_comment' %> +<% else %> + <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"create_kindeditor",'blog' %> + +
+
+
+ <%= link_to image_tag(url_to_avatar(User.find(@document.creator_id)), :width => 45, :heigth => 45), user_url_in_org(@document.creator_id) %> +
+
+
+ <%= link_to User.find(@document.creator_id), user_url_in_org(@document.creator_id), :class => "newsBlue mr15" %> + TO  <%= link_to @document.organization.name, organization_path(@document.organization), :class => "newsBlue" %> + | + <% if @document.organization.home_id == @document.id %> + 首页 + <% else %> + 组织文章 + <% end %>
- <% end %> -
- <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => @document} %> - <%#= link_to_attachments_course @document, :author => false %> -
- - <% if User.current.admin? || User.current.admin_of_org?(Organization.find(@document.organization_id) || User.current.id == @document.creator_id) %> -
-
    -
  • -
      -
    • - <%= form_for('new_form', :url => {:controller => 'organizations', :action => 'set_homepage', :id => @document.organization_id, :home_id => @document.id}, :method => "put", :remote => true) do |f| %> - 设为首页 - <% end %> -
    • -
    • - <%= link_to "编辑文章", edit_org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id, :flag => 1), :class => "postOptionLink" %> -
    • -
    • - <%= link_to "删除文章", org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id, :detail_page => 1), :method => 'delete', - :data => {:confirm => l(:text_are_you_sure)}, - :remote => true, :class => 'postOptionLink' %> + <% if User.current.admin? || User.current.admin_of_org?(Organization.find(@document.organization_id) || User.current.id == @document.creator_id) %> +
      +
        +
      • +
          +
        • + <%= form_for('new_form', :url => {:controller => 'organizations', :action => 'set_homepage', :id => @document.organization_id, :home_id => @document.id}, :method => "put", :remote => true) do |f| %> + 设为首页 + <% end %> +
        • +
        • + <%= link_to "编辑文章", edit_org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id, :flag => 1), :class => "postOptionLink" %> +
        • +
        • + <%= link_to "删除文章", org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id, :detail_page => 1), :method => 'delete', + :data => {:confirm => l(:text_are_you_sure)}, + :remote => true, :class => 'postOptionLink' %> +
        • +
      -
    • -
    -
-
- <% end %> -
-
- <% comments_for_doc = @document.children.reorder("created_at desc") %> - <% count = @document.children.count() %> +
+
+ <% end %> +
+
+ <% comments_for_doc = @document.children.reorder("created_at desc") %> + <% count = @document.children.count() %> -
- <%# if count > 0 %> +
+ <%# if count > 0 %>
回复 <%= count>0 ? "(#{count})" : "" %> @@ -123,50 +126,51 @@ <% end %>
- <%# end %> - <%# if User.current.logged?%> + <%# end %> + <%# if User.current.logged?%>
<%= form_for :org_comment, :url => {:action => 'add_reply_in_doc',:controller => 'org_document_comments', :id => @document.id}, :html => {:multipart => true, :id => 'message_form'} do |f| %> - <%= f.kindeditor :org_content,:width=>'99%',:height => '100px;',:editor_id=>'message_content_editor' %> + <%= f.kindeditor :org_content,:width=>'99%',:height => '100px;',:editor_id=>'message_content_editor' %> <%= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'message_content_editor.html("");', :class => " grey_btn fr c_white mt10 mr5" %> <%= link_to l(:button_reply), "javascript:void(0)", :onclick => "message_content_editor.sync();$('#message_form').submit();", :class => "blue_btn fr c_white mt10 mb10", :style => "margin-right: 5px;" %> <% end %>
- <%# end %> -
-
+ <%# end %> +
+
- \ No newline at end of file + +<% end %>