]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2662 Improve action plans
authorFabrice Bellingard <bellingard@gmail.com>
Tue, 20 Dec 2011 16:11:10 +0000 (17:11 +0100)
committerFabrice Bellingard <bellingard@gmail.com>
Tue, 20 Dec 2011 16:13:03 +0000 (17:13 +0100)
- The create/update form is now on the same page as the listing of
  the action plans (and on an orange background)
- Must be possible to create action plans with the same name in
  different projects
- Do not put links on '0' in the progress bar
- Improve rendering of progress bar on Chrome
- Display an alert message if one wants to plan a review whereas no
  action plan has been defined on the project
- If only one action is available, select it automatically when
  planning a review
- Add a "Unlink" button and remove the "none" entry in the select box
- Add "Back" button on the review listing page
- Fix bug on Derby with dead_line date

14 files changed:
plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/models/action_plan.rb
sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/_new.html.erb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/_progress.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/new.html.erb [deleted file]
sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/index.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_action_plan_form.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_review.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_action_plan_form.html.erb

index ac7dbbf677509b08de0db5c5a871c3d6f16ae932..7447f77ef66dd3a3d84a6cf7a59faf666a8a601b 100644 (file)
@@ -400,12 +400,14 @@ reviews.status.OPEN=Open
 reviews.status.CLOSED=Closed
 reviews.resolution.FALSE-POSITIVE=False-positive
 reviews.resolution.FIXED=Fixed
-reviews.link_to_action_plan=Action plan
+reviews.link_to_action_plan=Plan
 reviews.action_plan_label=Action plan
-reviews.action_plan_submit=Link to action plan
+reviews.action_plan_submit=Plan
+reviews.unlink_action_plan_submit=Unlink
 reviews.no_action_plan=None
 reviews.planned_for_x=Planned for {0}
 reviews.planned_for_label=Planned for
+reviews.an_action_plan_must_be_created_first=An action plan should be first created to plan the remediation effort of this violation.
 
 
 #------------------------------------------------------------------------------
@@ -428,6 +430,9 @@ action_plans.no_reviews_linked_to_action_plan=No reviews linked to this action p
 action_plans.confirm_delete=Delete this action plan? Associated reviews will not be deleted.
 action_plans.confirm_close=Close this action plan? There are still open reviews linked to it.
 action_plans.create_new_action_plan=Create a new action plan
+action_plans.create_action_plan=Create action plan
+action_plans.edit_action_plan=Edit action plan
+action_plans.same_name_in_same_project=An action plan with this name already exists in this project.
 action_plans.date_format_help=The date should be entered using the following pattern: 'day/month/year'. For instance, '31/12/2011'.
 action_plans.date_not_valid=Date not valid
 action_plans.date_cant_be_in_past=The dead-line can't be in the past
index b27456c767bb97a8f40159dd9a49de40b838766f..1a9cfc1ec4817478b791e0c830157184000ed381 100644 (file)
@@ -25,15 +25,13 @@ class ActionPlansController < ApplicationController
   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')
+    load_action_plans()
   end
 
-  def new
-    if params[:name] || params[:description] || params[:dead_line]
-      @action_plan = ActionPlan.new
-    elsif params[:plan_id]
-      @action_plan = ActionPlan.find params[:plan_id]
-    end
+  def edit
+    @action_plan = ActionPlan.find params[:plan_id]
+    load_action_plans()
+    render 'index'
   end
 
   def save
@@ -48,7 +46,7 @@ class ActionPlansController < ApplicationController
     @action_plan.description = params[:description]
     unless params[:dead_line].blank?
       begin
-        dead_line = Date.strptime(params[:dead_line], '%d/%m/%Y')
+        dead_line = DateTime.strptime(params[:dead_line], '%d/%m/%Y')
         if dead_line.past?
           date_not_valid = message('action_plans.date_cant_be_in_past')
         else
@@ -60,8 +58,10 @@ class ActionPlansController < ApplicationController
     end
 
     if date_not_valid || !@action_plan.valid?
-      @action_plan.errors.add :dead_line, date_not_valid if date_not_valid
-      render :action => :new, :id => @resource.id
+      @action_plan.errors.add :base, date_not_valid if date_not_valid
+      flash[:error] = @action_plan.errors.full_messages.join('<br/>')
+      load_action_plans()
+      render 'index'
     else
       @action_plan.save
       redirect_to :action => 'index', :id => @resource.id
@@ -90,5 +90,9 @@ class ActionPlansController < ApplicationController
     return redirect_to home_path unless @resource
     access_denied unless has_role?(:admin, @resource)
   end
+  
+  def load_action_plans
+    @action_plans = ActionPlan.find(:all, :conditions => ['project_id=?', @resource.id], :include => 'reviews', :order => 'dead_line ASC')
+  end
 
 end
index fcdf4c7f5321c59841b59f121902b750e5643db1..b2fd5af628c6990f02b6aac2034ebd5104f8b3d0 100644 (file)
@@ -321,6 +321,7 @@ class ResourceController < ApplicationController
     @global_violations=[]
     @expandable=(@lines!=nil)
     @filtered=!@expanded
+    @action_plans_size=ActionPlan.open_by_project_id(@snapshot.root_project_id).size
 
     conditions='snapshot_id=?'
     values=[@snapshot.id]
index 21295789a0c4659f1091be3485ab3e1910a8640f..259e02061db5fe34648f46cf456a013327c2c0dc 100644 (file)
@@ -24,10 +24,10 @@ class ReviewsController < ApplicationController
 
   verify :method => :post,
          :only => [:assign, :flag_as_false_positive, :save_comment, :delete_comment, :change_status,
-                   :link_to_action_plan,
+                   :link_to_action_plan, :unlink_from_action_plan,
                    :violation_assign, :violation_flag_as_false_positive, :violation_change_severity,
                    :violation_save_comment, :violation_delete_comment, :violation_change_status,
-                   :violation_link_to_action_plan],
+                   :violation_link_to_action_plan, :violation_unlink_from_action_plan],
          :redirect_to => {:action => :error_not_post}
   helper SourceHelper, UsersHelper
 
@@ -208,6 +208,19 @@ class ReviewsController < ApplicationController
 
     render :partial => "reviews/review"
   end
+  
+  # POST
+  def unlink_from_action_plan
+    @review = Review.find(params[:id])
+    unless has_rights_to_modify?(@review.project)
+      render :text => "<b>Cannot link to action plan</b> : access denied."
+      return
+    end
+    
+    @review.link_to_action_plan(nil, current_user, params)
+
+    render :partial => "reviews/review"
+  end
 
 
   #
@@ -404,6 +417,18 @@ class ReviewsController < ApplicationController
 
     render :partial => "resource/violation", :locals => {:violation => violation}
   end
+  
+  # POST
+  def violation_unlink_from_action_plan
+    violation = RuleFailure.find(params[:id], :include => 'snapshot')
+    unless has_rights_to_modify?(violation.snapshot)
+      render :text => "<b>Cannot link to action plan</b> : access denied."
+      return
+    end
+    violation.review.link_to_action_plan(nil, current_user, params)
+
+    render :partial => "resource/violation", :locals => {:violation => violation}
+  end
 
 
   #
index 7356256716344dc83c9193c3f9b6af4c9c0ba98b..9e72e9b3b3b96817ff67630472ac5cad2574d993 100644 (file)
@@ -22,12 +22,12 @@ class ActionPlan < ActiveRecord::Base
   belongs_to :project
   has_and_belongs_to_many :reviews
 
-  validates_uniqueness_of :name
   validates_length_of :name, :within => 1..200
   validates_length_of :description, :maximum => 1000, :allow_blank => true, :allow_nil => true
   validates_presence_of :user_login, :message => "can't be empty"
   validates_presence_of :status, :message => "can't be empty"
   validates_presence_of :project, :message => "can't be empty"
+  validate :unique_name_on_same_project
 
   STATUS_OPEN = 'OPEN'
   STATUS_CLOSED = 'CLOSED'
@@ -64,5 +64,14 @@ class ActionPlan < ActiveRecord::Base
   def over_due?
     dead_line ? status==STATUS_OPEN && dead_line.past? : false
   end
+  
+  private
+  
+  def unique_name_on_same_project
+    action_plan = ActionPlan.find(:first, :conditions => ['project_id=? AND name=?', project_id, name])
+    if action_plan && ( (id && action_plan.id!=id) || !id)
+      errors.add(:base, Api::Utils.message('action_plans.same_name_in_same_project'))
+    end
+  end
 
 end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/_new.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/_new.html.erb
new file mode 100644 (file)
index 0000000..a176974
--- /dev/null
@@ -0,0 +1,39 @@
+<table class="admintable" width="100%">
+  <form action="<%= url_for :action => 'save' -%>" method="POST" id="create-action-plan-form">
+    <input type="hidden" name="id" value="<%= @resource.id -%>"/>
+    <input type="hidden" name="plan_id" value="<%= @action_plan.id if @action_plan -%>"/>
+    <tbody>
+      <tr>
+        <td colspan="2"><h1 class="marginbottom10"><%= @action_plan ? message('action_plans.edit_action_plan') : message('action_plans.create_new_action_plan') -%></h1></h1></td>
+      </tr>
+      <tr>
+        <td class="left" valign="top">
+        <%= message('action_plans.col.name') -%>:
+        <br/>
+        <input type="text" name="name" id="name" value="<%= @action_plan ? @action_plan.name : params[:name] -%>"/>
+        </td>
+      </tr>
+      <tr>
+        <td class="left" valign="top">
+        <%= message('action_plans.col.due_for') -%>:
+        <br/>
+        <input type="text" name="dead_line" id="dead_line" value="<%= @action_plan && @action_plan.dead_line ? @action_plan.dead_line.strftime('%d/%m/%Y') : params[:dead_line] -%>"/>
+        <br/>
+        <span class="note"><%= message('action_plans.date_format_help') -%></span>
+        </td>
+      </tr>
+      <tr>
+        <td class="left" valign="top">
+        <%= message('action_plans.col.description') -%>:
+        <br/>
+        <textarea rows="5" cols="80" name="description" id="description" class="width100"><%= @action_plan ? @action_plan.description : params['description'] -%></textarea>
+        </td>
+      </tr>
+      <tr>
+        <td class="left" valign="top">
+        <input type="submit" value="<%= @action_plan ? message('action_plans.edit_action_plan') : message('action_plans.create_action_plan') -%>"/>
+        </td>
+      </tr>
+    </tbody>
+  </form>
+</table>
\ No newline at end of file
index 23bdfa2e52ba7fa185eda5d50a43705bb7dc38b6..acb27dfee64b00c5cb368665112c2abf3432fe6d 100644 (file)
@@ -2,29 +2,37 @@
   unless action_plan.progress[:total]==0
     options = {:controller => 'project_reviews', :action => 'index', :action_plan_id => action_plan.id, :projects => action_plan.project_id}
   
-    resolved_reviews_link = link_to action_plan.progress[:resolved].to_s, options.merge({:statuses => "#{Review::STATUS_RESOLVED},#{Review::STATUS_CLOSED}"})
+    resolved_reviews_link = action_plan.progress[:resolved].to_s 
+    resolved_reviews_link = link_to action_plan.progress[:resolved].to_s, options.merge({:statuses => "#{Review::STATUS_RESOLVED},#{Review::STATUS_CLOSED}"}) unless action_plan.progress[:resolved]==0
     total_reviews_link = link_to action_plan.progress[:total].to_s, options
 
-    resolved_reviews_url = url_for options.merge({:statuses => "#{Review::STATUS_RESOLVED},#{Review::STATUS_CLOSED}"})
-    open_reviews_url = url_for options.merge({:statuses => "#{Review::STATUS_OPEN},#{Review::STATUS_REOPENED}"})
+    if action_plan.progress[:resolved] > 0
+      resolved_reviews_url = url_for options.merge({:statuses => "#{Review::STATUS_RESOLVED},#{Review::STATUS_CLOSED}"})
+      percent_resolved = (action_plan.progress[:resolved]*100/action_plan.progress[:total]).to_i
+      tooltip_resolved = message('action_plans.resolved_reviews_x_percent', :params => [percent_resolved.to_s, action_plan.progress[:resolved].to_s])
+    end
   
-    percent_resolved = (action_plan.progress[:resolved]*100/action_plan.progress[:total]).to_i
-    percent_open = (action_plan.progress[:open]*100/action_plan.progress[:total]).to_i
-    
-    tooltip_resolved = message('action_plans.resolved_reviews_x_percent', :params => [percent_resolved.to_s, action_plan.progress[:resolved].to_s])
-    tooltip_open = message('action_plans.open_reviews_x_percent', :params => [percent_open.to_s, action_plan.progress[:open].to_s])
+    if action_plan.progress[:open] > 0
+      open_reviews_url = url_for options.merge({:statuses => "#{Review::STATUS_OPEN},#{Review::STATUS_REOPENED}"})
+      percent_open = (action_plan.progress[:open]*100/action_plan.progress[:total]).to_i
+      tooltip_open = message('action_plans.open_reviews_x_percent', :params => [percent_open.to_s, action_plan.progress[:open].to_s])
+    end
 %>
 
 <div class="progress">
   <table>
     <tbody>
       <tr>
+        <% if action_plan.progress[:resolved] > 0 %>
         <td class="resolved" style="width:<%= percent_resolved -%>%;">
           <a href="<%= resolved_reviews_url -%>" title="<%= tooltip_resolved -%>" alt="<%= tooltip_resolved -%>"></a>
         </td>
+        <% end %>
+        <% if action_plan.progress[:open] > 0 %>
         <td class="open" style="width:<%= percent_open -%>%;">
           <a href="<%= open_reviews_url -%>" title="<%= tooltip_open -%>" alt="<%= tooltip_open -%>"></a>
         </td>
+        <% end %>
       </tr>
     </tbody>
   </table>
index 38ecf0abd7ee05b3773379f97ac48fcbca977c95..14d1bc9d357880c6477e3f4e9df765a67d573927 100644 (file)
@@ -1,63 +1,69 @@
-<div class="line-block marginbottom10">
-  <ul class="operations">
-    <li class="last">
-      <%= image_tag 'add.png' -%>
-      <%= link_to message('action_plans.add_action_plan'), {:action => 'new', :id => @resource.id}, {:id => 'addActionPlan'} -%>
-    </li>
-  </ul>
-  <h1><%= message('action_plans.page_title') -%></h1>
-</div>
-
-<table class="width100 data sortable actionPlans" id="actionPlans">
-  <thead>
+<table width="100%">
   <tr>
-    <th class="thin nowrap"><%= message('action_plans.col.status') -%></th>
-    <th class="thin nowrap"><%= message('action_plans.col.name') -%></th>
-    <th class="thin nowrap righticon" style="text-align: right"><%= message('action_plans.col.due_for') -%></th>
-    <th class="nowrap nosort center"><%= message('action_plans.col.progress') -%></th>
-    <th class="nowrap"><%= message('action_plans.col.description') -%></th>
-    <th class="nowrap"><%= message('action_plans.col.author') -%></th>
-    <th class="thin nowrap nosort"><%= message('action_plans.col.operations') -%></th>
-  </tr>
-  </thead>
-  <tbody>
-  <% if @action_plans.empty? %>
-    <td colspan="7" class="even"><%= message('action_plans.no_action_plan') -%></td>
-  <% end %>
-  <%
-     @action_plans.each do |plan|
-  %>
-    <tr>
-      <td class="thin nowrap center"><img src="<%= ApplicationController.root_context -%>/images/status/<%= plan.status -%>.png" title="<%= message(plan.status.downcase).capitalize -%>"/></td>
-      <td class="thin nowrap"><%= h(plan.name) -%></td>
-      <td class="thin nowrap <%= 'over-due' if plan.over_due? -%>" align="right" x="<%= plan.dead_line ? plan.dead_line.tv_sec : '' -%>"><%= plan.dead_line ? plan.dead_line.strftime("%d %b %Y") : ' '  -%></td>
-      <% if plan.progress[:total]==0 %>
-      <td class="noprogress thin nowrap">
-        <%= message('action_plans.no_reviews_linked_to_action_plan') -%>
-      </td>
-      <% else %>
-      <td class="progress thin">
-        <%= render :partial => 'progress', :locals => {:action_plan => plan} -%>
-      </td>
-      <% end %>
-      <td id="desc"><%= h(plan.description) -%></td>
-      <td id="desc"><%= h(plan.user.name) -%></td>
-      <td class="thin nowrap">
-        <% if plan.open? %>
-          <%= link_to message('edit'), {:action => 'new', :id => @resource.id, :plan_id => plan.id}, {:class => 'action'} -%>  
+    <td valign="top">
+      
+      <h1><%= message('action_plans.page_title') -%></h1>
+
+      <table class="width100 data sortable actionPlans" id="actionPlans">
+        <thead>
+        <tr>
+          <th class="thin nowrap"><%= message('action_plans.col.status') -%></th>
+          <th class="thin nowrap"><%= message('action_plans.col.name') -%></th>
+          <th class="thin nowrap righticon" style="text-align: right"><%= message('action_plans.col.due_for') -%></th>
+          <th class="nowrap nosort center"><%= message('action_plans.col.progress') -%></th>
+          <th class="nowrap"><%= message('action_plans.col.description') -%></th>
+          <th class="nowrap"><%= message('action_plans.col.author') -%></th>
+          <th class="thin nowrap nosort"><%= message('action_plans.col.operations') -%></th>
+        </tr>
+        </thead>
+        <tbody>
+        <% if @action_plans.empty? %>
+          <td colspan="7" class="even"><%= message('action_plans.no_action_plan') -%></td>
         <% end %>
-        <% 
-          close_confirmation_message = {}
-          if plan.open? && plan.has_open_reviews?
-            close_confirmation_message = {:confirm => message('action_plans.confirm_close')}
-          end 
+        <%
+           @action_plans.each do |plan|
         %>
-        <%= 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'}.merge(close_confirmation_message) -%>
-        <%= link_to message('delete'), {:action => 'delete', :id => @resource.id, :plan_id => plan.id}, {:method => 'POST', :confirm => message('action_plans.confirm_delete'), :class => 'action'} -%>
-      </td>
-    </tr>
-  <% end %>
-  </tbody>
+          <tr>
+            <td class="thin nowrap center"><img src="<%= ApplicationController.root_context -%>/images/status/<%= plan.status -%>.png" title="<%= message(plan.status.downcase).capitalize -%>"/></td>
+            <td class="thin nowrap"><%= h(plan.name) -%></td>
+            <td class="thin nowrap <%= 'over-due' if plan.over_due? -%>" align="right" x="<%= plan.dead_line ? plan.dead_line.tv_sec : '' -%>"><%= plan.dead_line ? plan.dead_line.strftime("%d %b %Y") : ' '  -%></td>
+            <% if plan.progress[:total]==0 %>
+            <td class="noprogress thin nowrap">
+              <%= message('action_plans.no_reviews_linked_to_action_plan') -%>
+            </td>
+            <% else %>
+            <td class="progress thin">
+              <%= render :partial => 'progress', :locals => {:action_plan => plan} -%>
+            </td>
+            <% end %>
+            <td id="desc"><%= h(plan.description) -%></td>
+            <td id="desc"><%= h(plan.user.name) -%></td>
+            <td class="thin nowrap right">
+              <% if plan.open? %>
+                <%= link_to message('edit'), :action => 'edit', :id => @resource.id, :plan_id => plan.id, :class => 'action' -%>
+              <% end %>
+              <% 
+                close_confirmation_message = {}
+                if plan.open? && plan.has_open_reviews?
+                  close_confirmation_message = {:confirm => message('action_plans.confirm_close')}
+                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'}.merge(close_confirmation_message) -%>
+              <%= link_to message('delete'), {:action => 'delete', :id => @resource.id, :plan_id => plan.id}, {:method => 'POST', :confirm => message('action_plans.confirm_delete'), :class => 'action'} -%>
+            </td>
+          </tr>
+        <% end %>
+        </tbody>
+      </table>
+      <script>TableKit.Sortable.init('actionPlans');</script>
+
+    </td>
+    <td class="sep"></td>
+    <td width="210" valign="top" align="right">
+      <div id="admin_form">
+        <%= render :partial => 'new' %>
+      </div>
+    </td>
+  </tr>
 </table>
-<script>TableKit.Sortable.init('actionPlans');</script>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/new.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/new.html.erb
deleted file mode 100644 (file)
index b2c62dd..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-<h1 class="marginbottom10"><%= message('action_plans.create_new_action_plan') -%></h1>
-
-<% if @action_plan && @action_plan.errors.on_base
-     @action_plan.errors.on_base.each do |error| %>
-  <div class="error"><%= error -%></div>
-<%   end
-   end
-%>
-
-<form action="<%= url_for :action => 'save' -%>" method="POST" id="createForm">
-  <input type="hidden" name="id" value="<%= @resource.id -%>"/>
-  <input type="hidden" name="plan_id" value="<%= @action_plan.id if @action_plan -%>"/>
-  <table class="width100 form">
-    <tbody>
-      <tr>
-        <td class="keyCell">
-          <%= message('action_plans.col.name') -%>:
-        </td>
-        <td>
-          <input type="text" name="name" id="name" value="<%= @action_plan ? @action_plan.name : '' -%>"/>
-          <% if @action_plan && @action_plan.errors.on('name')
-               @action_plan.errors.on('name').each do |error| %>
-            <span class="error"><%= error -%></span>
-          <%   end
-             end %>
-        </td>
-      </tr>
-      <tr>
-        <td class="keyCell">
-          <%= message('action_plans.col.due_for') -%>:
-        </td>
-        <td>
-          <input type="text" name="dead_line" id="dead_line" value="<%= @action_plan && @action_plan.dead_line ? @action_plan.dead_line.strftime('%d/%m/%Y') : params[:dead_line] -%>"/>
-          <span class="note"><%= message('action_plans.date_format_help') -%></span>
-          <% if @action_plan && @action_plan.errors.on('dead_line')
-               @action_plan.errors.on('dead_line').each do |error| %>
-            <span class="error"><%= error -%></span>
-          <%   end
-             end %>
-        </td>
-      </tr>
-      <tr>
-        <td class="keyCell">
-          <%= message('action_plans.col.description') -%>:
-        </td>
-        <td>
-          <textarea rows="5" cols="80" name="description" id="description" class="width100"><%= @action_plan ? @action_plan.description : '' -%></textarea>
-          <% if @action_plan && @action_plan.errors.on('description')
-               @action_plan.errors.on('description').each do |error| %>
-            <span class="error"><%= error -%></span>
-          <%   end
-             end %>
-        </td>
-      </tr>
-      <tr>
-        <td class="keyCell">
-        </td>
-        <td>
-          <input type="submit" value="<%= message('save') -%>"/>
-          <%= link_to message('cancel'), :action => 'index', :id => @resource.id -%>
-        </td>
-      </tr>
-    </tbody>
-  </table>
-</form>
\ No newline at end of file
index de1a58170c3208d4ae6c04165cbc3120cf39bddb..ffc5d58a6e4a86b2462129f75e7733d718f858b4 100644 (file)
@@ -1,3 +1,7 @@
+<div style="font-size: 85%; margin-bottom: 10px">
+ยป <a href="#" onclick="history.back()"><%= message('back') -%></a>
+</div>
+
 <div id="reviews-search">
   <h1><%= message('reviews') -%></h1>
 
index f92df0462102f38039817e7958e996a455793e5a..5eb274529cd94f218745931f3225b49c5adfd506 100644 (file)
           <% unless violation.review && violation.review.resolved? %>
             <%= button_to_function message('reviews.change_severity'), "sCSF(#{violation.id})", :name => 'bChangeSeverity' -%>
             
-            <%= button_to_function message('reviews.link_to_action_plan'), "sAPF(#{violation.id})", :name => 'bLinkActionPlan' -%>
+            <% 
+               @action_plans_size = ActionPlan.open_by_project_id(violation.review.project_id).size unless @action_plans_size
+               if @action_plans_size > 0 
+            %>
+              <%= button_to_function message('reviews.link_to_action_plan'), "sAPF(#{violation.id})", :name => 'bLinkActionPlan' -%>
+            <% else %>
+              <input type="button" value="<%= message('reviews.link_to_action_plan') -%>" onclick="alert('<%= message('reviews.an_action_plan_must_be_created_first') -%>');" name="bLinkActionPlan">
+            <% end %>
           <% end %>
         </div>
       <% end %>
index 5e6c95d39343ba6affa88e48337e3aa5b3176852..c95966602cf257c19f7412e5bec55573e9896c7f 100644 (file)
@@ -3,7 +3,6 @@
 
   <%= message('reviews.action_plan_label') -%>:
   <select name="action_plan_id" id="selectActionPlan">
-    <option value="-1" <%= 'selected' if !@review.planned? -%>><%= message('reviews.no_action_plan') -%></option>
     <% @action_plans.each do |plan| %>
       <option value="<%= plan.id -%>" <%= 'selected' if @review.linked_to?(plan) -%>><%= h(plan.name) -%></option>
     <% end %>
   <textarea id="actionText" rows="4" name="text" style="width: 100%"></textarea>
   <%= submit_to_remote "submit_btn", message('reviews.action_plan_submit'), :url => {:action => 'link_to_action_plan'}, :html => {:id => "submit_btn"}, :update => 'review' -%>
   &nbsp;
+  
+  <% if @review.planned? %>
+    &nbsp;
+    <%= submit_to_remote "submit_btn", message('reviews.unlink_action_plan_submit'), :url => {:action => 'unlink_from_action_plan'}, :html => {:id => "submit_btn"}, :update => 'review' -%>
+  <% end %>
+  
   <%= link_to_remote message('cancel'), :url => {:action => 'show', :id => params[:id]}, :update => 'review' -%>
 </form>
index 6b2ef05584fcff2aafe43caf20251beedff0f217..c14286d71f9d0d56bcbb36bc0c576f4c525069ca 100644 (file)
                              :update => "actionForm",
                              :complete => "$('actionButtons').remove();$('actionForm').show();$('selectSeverity').focus();" -%>
 
-        <%= button_to_remote message('reviews.link_to_action_plan'),
+        <% if ActionPlan.open_by_project_id(@review.project_id).size>0 %>
+          <%= button_to_remote message('reviews.link_to_action_plan'),
                              :url => {:controller => "reviews", :action => "action_plan_form", :id => review.id},
                              :update => "actionForm",
                              :complete => "$('actionButtons').remove();$('actionForm').show();$('selectSeverity').focus();" -%>
+        <% else %>
+          <input type="button" value="<%= message('reviews.link_to_action_plan') -%>" onclick="alert('<%= message('reviews.an_action_plan_must_be_created_first') -%>');">
+        <% end %>
       <% end %>
     </div>
   <% end %>
index 596ca7b96114fb139bde27e10cb7342dfefd5469..6ce542a8d7d0aafaebb5ed5462a6918827cc92c1 100644 (file)
@@ -3,7 +3,6 @@
 
   <%= message('reviews.action_plan_label') -%>:
   <select name="action_plan_id" id="selectActionPlan<%= params[:id] -%>">
-    <option value="-1" <%= 'selected' if !@violation.review || (@violation.review && !@violation.review.planned?) -%>><%= message('reviews.no_action_plan') -%></option>
     <% @action_plans.each do |plan| %>
       <option value="<%= plan.id -%>" <%= 'selected' if @violation.review && @violation.review.linked_to?(plan) -%>><%= h(plan.name) -%></option>
     <% end %>
   </table>
 
   <%= submit_to_remote "submit_btn"+params[:id], message('reviews.action_plan_submit'), :url => {:action => 'violation_link_to_action_plan'}, :html => {:id => "submit_btn"+params[:id]}, :update => 'vId'+params[:id] -%>
+  
+  <% if @violation.review && @violation.review.planned? %>
+    &nbsp;
+    <%= submit_to_remote "submit_btn"+params[:id], message('reviews.unlink_action_plan_submit'), :url => {:action => 'violation_unlink_from_action_plan'}, :html => {:id => "submit_btn"+params[:id]}, :update => 'vId'+params[:id] -%>
+  <% end %>
+  
   &nbsp;
   <%= link_to_function message('cancel'), "cancelViolationAction(#{params[:id]})" -%>
 </form>