From bd6a1a9d4931c6e14fa5b2fee516ac00c62a968c Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 16 Nov 2015 17:21:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=84=E7=BB=87=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E4=B8=AD=E7=9A=84=E9=A1=B9=E7=9B=AE=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E7=9A=84=E5=9B=9E=E5=A4=8D=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/issues_controller.rb | 21 +++++++++++++++++-- .../org_document_comments_controller.rb | 1 + app/views/issues/add_journal_in_org.js.erb | 3 +++ .../org_document_comments/add_reply.js.erb | 4 ++-- .../organizations/_org_activities.html.erb | 12 +++++------ .../organizations/_org_project_issue.html.erb | 18 +++++++++++++++- .../organizations/_show_org_document.html.erb | 14 ++++++------- app/views/organizations/show.html.erb | 3 ++- config/routes.rb | 1 + 9 files changed, 58 insertions(+), 19 deletions(-) create mode 100644 app/views/issues/add_journal_in_org.js.erb diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index e529dd3b9..edf055370 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -20,11 +20,11 @@ class IssuesController < ApplicationController default_search_scope :issues before_filter :authorize1, :only => [:show] - before_filter :find_issue, :only => [:show, :edit, :update,:add_journal] + before_filter :find_issue, :only => [:show, :edit, :update,:add_journal, :add_journal_in_org] before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy] before_filter :find_project, :only => [:new, :create, :update_form] #before_filter :authorize, :except => [:index, :show] - before_filter :authorize, :except => [:index,:add_journal] + before_filter :authorize, :except => [:index,:add_journal, :add_journal_in_org] before_filter :find_optional_project, :only => [:index] before_filter :check_for_default_issue_status, :only => [:new, :create] @@ -397,6 +397,23 @@ class IssuesController < ApplicationController end end + def add_journal_in_org + if User.current.logged? + jour = Journal.new + jour.user_id = User.current.id + jour.notes = params[:notes] + jour.journalized = @issue + jour.save + org_activity = OrgActivity.where("org_act_type='Issue' and org_act_id =#{@issue.id}").first + org_activity.updated_at = jour.created_on + org_activity.save + @user_activity_id = params[:user_activity_id] + respond_to do |format| + format.js + end + end + end + private def find_project diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index 60522dc3f..13a188e72 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -41,6 +41,7 @@ class OrgDocumentCommentsController < ApplicationController 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 diff --git a/app/views/issues/add_journal_in_org.js.erb b/app/views/issues/add_journal_in_org.js.erb new file mode 100644 index 000000000..ad7a85540 --- /dev/null +++ b/app/views/issues/add_journal_in_org.js.erb @@ -0,0 +1,3 @@ +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'organizations/org_project_issue', :locals => {:activity => @issue,:user_activity_id =>@user_activity_id}) %>"); + +init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); \ No newline at end of file diff --git a/app/views/org_document_comments/add_reply.js.erb b/app/views/org_document_comments/add_reply.js.erb index 5d54af2bf..40ed2eeb2 100644 --- a/app/views/org_document_comments/add_reply.js.erb +++ b/app/views/org_document_comments/add_reply.js.erb @@ -1,3 +1,3 @@ -$("#organization_document_<%= @document.id %>").replaceWith("<%= escape_javascript(render :partial => 'organizations/show_org_document', :locals => {:document => @document}) %>"); -init_activity_KindEditor_data(<%= @document.id %>,"","87%"); \ No newline at end of file +$("#organization_document_<%= @act.id %>").replaceWith("<%= escape_javascript(render :partial => 'organizations/show_org_document', :locals => {:document => @document, :act => @act}) %>"); +init_activity_KindEditor_data(<%= @act.id %>,"","87%"); \ No newline at end of file diff --git a/app/views/organizations/_org_activities.html.erb b/app/views/organizations/_org_activities.html.erb index cb69738b6..148bb9efe 100644 --- a/app/views/organizations/_org_activities.html.erb +++ b/app/views/organizations/_org_activities.html.erb @@ -1,5 +1,10 @@ <% unless org_activities.nil? %> <% org_activities.each do |act| %> + <% if act.container_type == 'Organization' %> <% if act.org_act_type == 'CreateOrganization' %>
@@ -17,12 +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} %> + <%= render :partial => 'show_org_document', :locals => {:document => act.org_act, :act => act} %> <% end %> <% end %> <% if act.container_type == 'Project' %> diff --git a/app/views/organizations/_org_project_issue.html.erb b/app/views/organizations/_org_project_issue.html.erb index 573429752..e29994967 100644 --- a/app/views/organizations/_org_project_issue.html.erb +++ b/app/views/organizations/_org_project_issue.html.erb @@ -130,7 +130,23 @@ <% end %> - +
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => add_journal_in_org_issue_path(activity.id),:method => "post", :remote => true) do |f|%> + + +
+ +
+

+ <% end%> +
+
+
+
+
diff --git a/app/views/organizations/_show_org_document.html.erb b/app/views/organizations/_show_org_document.html.erb index 4177c3688..e352288ab 100644 --- a/app/views/organizations/_show_org_document.html.erb +++ b/app/views/organizations/_show_org_document.html.erb @@ -91,16 +91,16 @@ <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33", :alt => "用户头像"), user_path(User.current) %>
-
- <%= form_for('new_form', :url => add_reply_org_document_comment_path(:id => document.id), :method => "post", :remote => true) do |f| %> - - +
+ <%= form_for('new_form', :url => add_reply_org_document_comment_path(:id => document.id, :act_id => act.id), :method => "post", :remote => true) do |f| %> + + -
- +
+
-

+

<% end %>
diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb index a85ffa687..1ccb2f0e5 100644 --- a/app/views/organizations/show.html.erb +++ b/app/views/organizations/show.html.erb @@ -30,7 +30,8 @@ init_activity_KindEditor_data(<%= @organization.home_id%>, null, "87%"); }); - <%= render :partial => 'show_org_document', :locals => {:document => OrgDocumentComment.find(@organization.home_id), :home_id => @organization.home_id} %> + <% act = OrgActivity.where("org_act_type = 'OrgDocumentComment' and org_act_id =?", @organization.home_id).first %> + <%= render :partial => 'show_org_document', :locals => {:document => OrgDocumentComment.find(@organization.home_id), :home_id => @organization.home_id, :act => act} %> <% end %> <%= render :partial => 'organizations/org_activities', diff --git a/config/routes.rb b/config/routes.rb index 69134e666..24d159f04 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -634,6 +634,7 @@ RedmineApp::Application.routes.draw do end member do post 'add_journal' + post 'add_journal_in_org' end resources :time_entries, :controller => 'timelog' do collection do