From 103773c0dc471f92352c970fc4471b64f410894e Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Mon, 19 Dec 2011 09:54:53 +0100 Subject: [PATCH] SONAR-2662 Allow to close & reopen an action plan --- .../src/main/resources/org/sonar/l10n/core.properties | 2 ++ .../app/controllers/action_plans_controller.rb | 11 ++++++++++- .../WEB-INF/app/views/action_plans/index.html.erb | 6 +++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties index 02ca77ea581..97bade0325a 100644 --- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -426,6 +426,8 @@ action_plans.date_cant_be_in_past=The dead-line can't be in the past action_plans.x_out_of_x_reviews_solved={0} of {1} reviews solved action_plans.resolved_reviews_x_percent=Resolved reviews - {0}% ({1} reviews) action_plans.open_reviews_x_percent=Open reviews - {0}% ({1} reviews) +action_plans.reopen=Reopen +action_plans.close=Close #------------------------------------------------------------------------------ diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb index f12a9a9a68a..5a1466a3d93 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb @@ -22,7 +22,7 @@ class ActionPlansController < ApplicationController SECTION=Navigation::SECTION_RESOURCE before_filter :load_resource - verify :method => :post, :only => [:save, :delete], :redirect_to => {:action => :index} + verify :method => :post, :only => [:save, :delete, :change_status], :redirect_to => {:action => :index} def index @action_plans = ActionPlan.find(:all, :conditions => ['project_id=?', @resource.id], :include => 'reviews', :order => 'dead_line ASC') @@ -66,6 +66,15 @@ class ActionPlansController < ApplicationController redirect_to :action => 'index', :id => @resource.id end + def change_status + action_plan = ActionPlan.find params[:plan_id] + if action_plan + action_plan.status = action_plan.open? ? ActionPlan::STATUS_CLOSED : ActionPlan::STATUS_OPEN + action_plan.save + end + redirect_to :action => 'index', :id => @resource.id + end + private def load_resource diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb index 16425cfdf1b..3e4b74dcf54 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb @@ -47,7 +47,11 @@ <%= h(plan.description) -%> <%= h(plan.user.name) -%> - <%= message('edit') -%> + <% if plan.open? %> + <%= link_to message('edit'), {:action => 'new', :id => @resource.id, :plan_id => plan.id}, {:class => 'action'} -%> + <% end %> + <%= link_to plan.open? ? message('action_plans.close') : message('action_plans.reopen'), + {:action => 'change_status', :id => @resource.id, :plan_id => plan.id}, {:method => 'POST', :class => 'action'} -%> <%= link_to message('delete'), {:action => 'delete', :id => @resource.id, :plan_id => plan.id}, {:method => 'POST', :confirm => message('action_plans.confirm_delete'), :class => 'action'} -%> -- 2.39.5