From 333c0e41a006b47ee76d6511f7af3212a8de300f Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 9 Dec 2015 10:48:15 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=A0=8F=E7=9B=AE=E5=A2=9E=E5=8A=A0=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E5=B8=96=E5=AD=90=E5=8A=9F=E8=83=BD=EF=BC=9B=202.?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E6=9F=90=E6=A0=8F=E7=9B=AE=EF=BC=8C=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E7=9B=B8=E5=BA=94=E7=9A=84=E5=8A=A8=E6=80=81=EF=BC=9B?= =?UTF-8?q?=203.=E7=BC=96=E8=BE=91=E6=A0=8F=E7=9B=AE=E9=87=8C=E7=9A=84?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E5=90=8E=EF=BC=8C=E8=BF=94=E5=9B=9E=E7=9B=B8?= =?UTF-8?q?=E5=BA=94=E7=9A=84=E6=A0=8F=E7=9B=AE=E5=8A=A8=E6=80=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org_document_comments_controller.rb | 4 +- app/controllers/organizations_controller.rb | 52 ++++++++------ app/views/org_document_comments/edit.html.erb | 2 +- app/views/org_document_comments/new.html.erb | 10 +-- .../organizations/_org_activities.html.erb | 2 +- .../_org_left_subfield_list.html.erb | 2 +- .../organizations/_show_org_document.html.erb | 2 +- app/views/organizations/show.html.erb | 70 ++++++++++--------- 8 files changed, 74 insertions(+), 70 deletions(-) diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index e9f3d47fb..b8584fea3 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -18,7 +18,7 @@ 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) + redirect_to organization_path(@organization, :org_subfield_id => params[:field_id]) else redirect_to organization_org_document_comments_path(@organization) end @@ -53,7 +53,7 @@ class OrgDocumentCommentsController < ApplicationController 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) + redirect_to organization_path(@org_document.organization.id, :org_subfield_id => params[:org_subfield_id]) end end } diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index d182640ed..38402f68e 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -68,29 +68,35 @@ class OrganizationsController < ApplicationController def show if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) @organization = Organization.find(params[:id]) - project_ids = @organization.projects.map(&:id) << 0 - course_ids = @organization.courses.map(&:id) << 0 - course_types = "('Message','News','HomeworkCommon','Poll','Course')" - case params[:type] - when nil - @org_activities = OrgActivity.where("(container_id =? and container_type =?) " + - "or (container_type ='Project' and org_act_type in ('Issue','Message','ProjectCreateInfo') and container_id in (#{project_ids.join(',')})) "+ - "or (container_type ='Course' and org_act_type in #{course_types} and container_id in (#{course_ids.join(',')}))", - @organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) - when 'project_issue' - @org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Issue' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) - when 'project_message' - @org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Message' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) - when 'org' - @org_activities = OrgActivity.where("container_id =? and container_type =?",@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) - when 'course_homework' - @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'HomeworkCommon' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) - when 'course_news' - @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'News' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) - when 'course_message' - @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Message' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) - when 'course_poll' - @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Poll' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + if params[:org_subfield_id] + @org_subfield = OrgSubfield.find(params[:org_subfield_id]) + @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(",")})").order('updated_at desc').page(params[:page] || 1).per(10) + else + project_ids = @organization.projects.map(&:id) << 0 + course_ids = @organization.courses.map(&:id) << 0 + course_types = "('Message','News','HomeworkCommon','Poll','Course')" + case params[:type] + when nil + @org_activities = OrgActivity.where("(container_id =? and container_type =?) " + + "or (container_type ='Project' and org_act_type in ('Issue','Message','ProjectCreateInfo') and container_id in (#{project_ids.join(',')})) "+ + "or (container_type ='Course' and org_act_type in #{course_types} and container_id in (#{course_ids.join(',')}))", + @organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) + when 'project_issue' + @org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Issue' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'project_message' + @org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Message' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'org' + @org_activities = OrgActivity.where("container_id =? and container_type =?",@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_homework' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'HomeworkCommon' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_news' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'News' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_message' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Message' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_poll' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Poll' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + end end @page = params[:page] respond_to do |format| diff --git a/app/views/org_document_comments/edit.html.erb b/app/views/org_document_comments/edit.html.erb index c4a74c791..e4ac22bf7 100644 --- a/app/views/org_document_comments/edit.html.erb +++ b/app/views/org_document_comments/edit.html.erb @@ -17,7 +17,7 @@
-<%= form_tag url_for(:controller => 'org_document_comments',:action => 'update', :id => @org_document.id, :flag => @flag),:method => 'put', :id => 'new_org_document_form' do |f| %> +<%= 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| %>
diff --git a/app/views/org_document_comments/new.html.erb b/app/views/org_document_comments/new.html.erb index 9150be608..af938b498 100644 --- a/app/views/org_document_comments/new.html.erb +++ b/app/views/org_document_comments/new.html.erb @@ -22,17 +22,13 @@ } } function cancel_create_org_document(){ - $("#document_title").val(""); - org_document_description_editor.html(""); - org_document_description_editor.sync(); - $('#org_document_editor').hide(); - $('#doc_title_hint').hide(); + location.href = document.referrer; } <%= form_tag organization_org_document_comments_path(:organization_id => @organization.id, :field_id => params[:field_id]), :id => 'new_org_document_form' do |f| %>
- +
@@ -48,7 +44,7 @@
确定 - 取消 + 取消
diff --git a/app/views/organizations/_org_activities.html.erb b/app/views/organizations/_org_activities.html.erb index 9cb84e6d6..969c504da 100644 --- a/app/views/organizations/_org_activities.html.erb +++ b/app/views/organizations/_org_activities.html.erb @@ -22,7 +22,7 @@
<% end %> <% if act.org_act_type == 'OrgDocumentComment' && act.org_act_id != @organization.home_id %> - <%= render :partial => 'show_org_document', :locals => {:document => act.org_act, :act => act, :flag => 2} %> + <%= render :partial => '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' %> diff --git a/app/views/organizations/_org_left_subfield_list.html.erb b/app/views/organizations/_org_left_subfield_list.html.erb index f2329e2be..9c9e0a1be 100644 --- a/app/views/organizations/_org_left_subfield_list.html.erb +++ b/app/views/organizations/_org_left_subfield_list.html.erb @@ -25,7 +25,7 @@
<% organization.org_subfields.each do |field| %>
- <%= field.name %> + <%= link_to "#{field.name}", organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText" %> <%=link_to "", new_organization_org_document_comment_path(organization, :field_id => field.id), :method => "get", :class => "homepageMenuSetting fr", :title => "发布帖子"%>