diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index 7685b77a8..f250b46de 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -20,7 +20,12 @@ class OrgDocumentCommentsController < ApplicationController 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]) + @org_subfield = OrgSubfield.find(params[:field_id]) + if @org_subfield.subfield_subdomain_dir.nil? + redirect_to organization_path(@organization, :org_subfield_id => params[:field_id]) + else + redirect_to show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => @org_subfield.subfield_subdomain_dir.name) + end else redirect_to organization_org_document_comments_path(@organization) end diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb index 6bd6ecbf0..9b8cbcf93 100644 --- a/app/controllers/org_subfields_controller.rb +++ b/app/controllers/org_subfields_controller.rb @@ -1,4 +1,5 @@ class OrgSubfieldsController < ApplicationController + helper :attachments layout 'base_org' def create if OrgSubfield.where("organization_id=#{params[:organization_id]} and name=?",params[:name]).count == 0 @@ -25,54 +26,56 @@ class OrgSubfieldsController < ApplicationController "subfield_subdomain_dirs where org_subfields.id = subfield_subdomain_dirs.org_subfield_id and "+ " org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir_name]}'").first if @org_subfield.field_type == 'Post' - redirect_to organization_path(@organization, :org_subfield_id => @org_subfield.id) - end - if params[:sort] - params[:sort].split(",").each do |sort_type| - order_by = sort_type.split(":") - - case order_by[0] - when "filename" - attribute = "filename" - when "size" - attribute = "filesize" - when "attach_type" - attribute = "attachtype" - when "content_type" - attribute = "created_on" - when "field_file_dense" - attribute = "is_public" - when "downloads" - attribute = "downloads" - when "created_on" - attribute = "created_on" - when "quotes" - attribute = "quotes" - else - attribute = "created_on" - end - @sort = order_by[0] - @order = order_by[1] - if order_by.count == 1 && attribute - sort += "#{Attachment.table_name}.#{attribute} asc " - if sort_type != params[:sort].split(",").last - sort += "," - end - elsif order_by.count == 2 && order_by[1] - sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " - if sort_type != params[:sort].split(",").last - sort += "," - end - end - end + @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0 + @org_activities = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10) + #redirect_to organization_path(@organization, :org_subfield_id => @org_subfield.id) else - sort = "#{Attachment.table_name}.created_on desc" + if params[:sort] + params[:sort].split(",").each do |sort_type| + order_by = sort_type.split(":") + case order_by[0] + when "filename" + attribute = "filename" + when "size" + attribute = "filesize" + when "attach_type" + attribute = "attachtype" + when "content_type" + attribute = "created_on" + when "field_file_dense" + attribute = "is_public" + when "downloads" + attribute = "downloads" + when "created_on" + attribute = "created_on" + when "quotes" + attribute = "quotes" + else + attribute = "created_on" + end + @sort = order_by[0] + @order = order_by[1] + if order_by.count == 1 && attribute + sort += "#{Attachment.table_name}.#{attribute} asc " + if sort_type != params[:sort].split(",").last + sort += "," + end + elsif order_by.count == 2 && order_by[1] + sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " + if sort_type != params[:sort].split(",").last + sort += "," + end + end + end + else + sort = "#{Attachment.table_name}.created_on desc" + end + @container_type = 2 + @containers = [ OrgSubfield.includes(:attachments).reorder(sort).find(@org_subfield.id)] + @organization = Organization.find(@containers.first.organization_id) + show_attachments @containers + @tag_list = attachment_tag_list @all_attachments end - @container_type = 2 - @containers = [ OrgSubfield.includes(:attachments).reorder(sort).find(@org_subfield.id)] - @organization = Organization.find(@containers.first.organization_id) - show_attachments @containers - @tag_list = attachment_tag_list @all_attachments @page = params[:page] || 1 #render :layout => 'base_org' end diff --git a/app/views/files/_subfield_files.html.erb b/app/views/files/_subfield_files.html.erb index 6da0caccb..7332f4892 100644 --- a/app/views/files/_subfield_files.html.erb +++ b/app/views/files/_subfield_files.html.erb @@ -53,7 +53,7 @@ <%#= render :partial => "files/subfield_tags", :locals => {:tag_list => @tag_list,:org_subfield => @org_subfield,:tag_name => @tag_name}%>
-共有 <%= @all_attachments.count %> 个资源
+共有 <%= @all_attachments.count %> 个资源
<% if @order == "asc" %> 按 <%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> / diff --git a/app/views/files/search_files_in_subfield.js.erb b/app/views/files/search_files_in_subfield.js.erb index dfaa56a6c..77c364817 100644 --- a/app/views/files/search_files_in_subfield.js.erb +++ b/app/views/files/search_files_in_subfield.js.erb @@ -4,4 +4,5 @@ <% else %> $("#org_subfield_list").html("<%= escape_javascript(render :partial => 'org_subfield_list', :locals => {org_subfield: @org_subfield,all_attachments: @result,sort:@sort,order:@order,org_subfield_attachments:@searched_attach})%>"); + $("#attachment_count").html("<%= @result.count %>"); <% end %> \ No newline at end of file diff --git a/app/views/org_subfields/_show_details.html.erb b/app/views/org_subfields/_show_details.html.erb new file mode 100644 index 000000000..7d83efaa1 --- /dev/null +++ b/app/views/org_subfields/_show_details.html.erb @@ -0,0 +1,80 @@ + +<% unless org_activities.nil? %> + <% org_activities.each do |act| %> + + <% if act.container_type == 'Organization' %> + <% if act.org_act_type == 'OrgDocumentComment' && act.org_act_id != @organization.home_id %> + <%= render :partial => 'organizations/show_org_document', :locals => {:document => act.org_act, :act => act, :flag => 2, :org_subfield_id => params[:org_subfield_id]} %> + <% end %> + <% end %> + <% if act.container_type == 'Project' %> + <% case act.org_act_type.to_s %> + <% when 'Message' %> + <%= render :partial => 'organizations/project_message', :locals => {:activity => Message.find(act.org_act_id),:user_activity_id =>act.id} %> + <% end %> + <% end %> + <% if act.container_type == 'Course' %> + <% case act.org_act_type.to_s %> + <% when 'Message'%> + <%= render :partial => 'organizations/org_course_message', :locals => {:activity => Message.find(act.org_act_id),:user_activity_id =>act.id} %> + <% end %> + <% end %> + <% if act.container_type == 'OrgSubfield' %> + <% if act.org_act_type == 'Message' and act.org_act_id and Message.where("id=#{act.org_act_id}").count > 0 %> + <% message = Message.find(act.org_act_id) %> + <% if !message.board.course_id.nil? %> + <%= render :partial => 'organizations/org_course_message', :locals => {:activity => message,:user_activity_id =>act.id} %> + <% elsif message.board.project_id != -1 %> + <%= render :partial => 'organizations/project_message', :locals => {:activity => message,:user_activity_id =>act.id} %> + <% elsif message.board.org_subfield_id %> + <%= render :partial => 'organizations/org_subfield_message', :locals => {:activity => message, :user_activity_id => act.id} %> + <% end %> + <% end %> + <% end %> + <% end %> + +<% end %> + +<% if org_act_count == 10 %> + <%= link_to "点击展开更多",show_org_subfield_organization_path(:id => @organization.id,:page => @page.to_i + 1,:sub_dir_name => params[:sub_dir_name]),:id => "show_more_activities",:remote => "true",:class => "loadMore mt10 f_grey"%> +<% end%> + diff --git a/app/views/org_subfields/_show_post_type.html.erb b/app/views/org_subfields/_show_post_type.html.erb new file mode 100644 index 000000000..defbbce1e --- /dev/null +++ b/app/views/org_subfields/_show_post_type.html.erb @@ -0,0 +1,35 @@ +<%= javascript_include_tag "jquery.infinitescroll.js" %> + +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: false, init_activity: true) %> +<% end %> + + + +