]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3755 various improvements on plan and assign actions
authorSimon Brandhof <simon.brandhof@gmail.com>
Wed, 22 May 2013 12:29:32 +0000 (14:29 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Wed, 22 May 2013 12:29:32 +0000 (14:29 +0200)
* display deadline besides the action plans
* unplan button
* unassign button
* Ruby API to easily format java or ruby dates

plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
sonar-core/src/main/resources/org/sonar/core/issue/db/ActionPlanMapper.xml
sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_action_plans_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
sonar-server/src/main/webapp/WEB-INF/app/views/issue/_plan_form.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/issues_action_plans/index.html.erb

index 5658dd3d0bb8bc9e18813d375a456b653f387716..138a4e1676a091e8550e7df77525a4365ea612f9 100644 (file)
@@ -546,6 +546,7 @@ issue.set_severity=Set Severity
 issue.set_severity.submit=Set Severity
 issue.do_plan=Plan
 issue.plan.submit=Plan
+issue.unplanned=Unplanned
 issue.unplan.submit=Unplan
 issue.plan_must_be_created_first=An action plan should be first created to plan the remediation effort of this issue.
 issue.status.REOPENED=Reopened
index 663284e21ac89f8bcbfd7c0bcfe14e751b2139d0..2e091afd2ba3f4052495b4e42fa05a4c15efb92e 100644 (file)
@@ -78,6 +78,7 @@
       and ap.status='OPEN'
       and ap.project_id=p.id
     </where>
+    order by deadline
   </select>
 
   <select id="findByNameAndProjectId" parameterType="long" resultType="ActionPlanIssue">
index 9dc9d445d424b2f78ce68da9f2e417995a850d36..6fda7363ac34ad975ee12131da5d08678d97dfe6 100644 (file)
@@ -48,11 +48,7 @@ class IssuesActionPlansController < ApplicationController
       @action_plan = action_plan_result.get()
       redirect_to :action => 'index', :id => @resource.id
     else
-      flash[:error] = ""
-      action_plan_result.errors().each_with_index do |msg, index|
-        flash[:error] << message(msg.text(), {:params => msg.params()}).capitalize
-        flash[:error] += "<br/>" if index < action_plan_result.errors().size() - 1
-      end
+      flash[:error] = action_plan_result.errors().map{|error| error.text ? error.text : Api::Utils.message(error.l10nKey, :params => error.l10nParams)}.join('<br/>')
       load_action_plans()
       render 'index'
     end
index 1ff52dcb29d6c3c749f1d45be3bd4eec2c31fc2c..032f8759df683d6d9a335c523b3b769d503319dc 100644 (file)
@@ -31,6 +31,7 @@ module ApplicationHelper
   #
   # == Options
   # * :format - See Ruby on Rails localization options
+  # * :time_if_today - true to only display the time when the date is today.
   #
   def format_datetime(object, options={})
     return nil unless object
@@ -39,25 +40,37 @@ module ApplicationHelper
     else
       dt = object
     end
-    l(dt, options)
+    if options[:time_if_today] && (Date.today - date.to_date == 0)
+      dt.strftime('%H:%M')
+    else
+      l(dt, options)
+    end
   end
 
   # Since 3.6
   # java.util.Date is supported
   #
   # == Options
-  # * :format - See Ruby on Rails localization options
+  # * :format - values are :short, :default, :long. See Ruby on Rails localization for more details.
+  # * :time_if_today - true to only display the time when the date is today.
   #
   def format_date(object, options={})
     return nil unless object
+
+    dt = object
+    date = object
     if object.is_a?(Java::JavaUtil::Date)
-      date = Api::Utils.java_to_ruby_datetime(object).to_date
-    elsif object.respond_to?(:to_date)
+      dt = Api::Utils.java_to_ruby_datetime(object)
+      date = dt.to_date
+    elsif object.is_a?(DateTime)
+      dt = object
       date = object.to_date
+    end
+    if options[:time_if_today] && (Date.today - date.to_date == 0)
+      dt.strftime('%H:%M')
     else
-      date = object
+      l(date, options)
     end
-    l(date, options)
   end
 
   def sonar_version
index 8848f3fe52bdcae04990a8b8c64debefe7ea3922..74982bc1c3d73c296f2770c7fe5490ef584f69bc 100644 (file)
@@ -1,6 +1,6 @@
 <%
    plans_select_box_id = "plans-#{params[:issue]}"
-   plans = Internal.issues.findOpenActionPlans(params[:issue]).sort_by { |plan| plan.deadLine }
+   plans = Internal.issues.findOpenActionPlans(params[:issue])
 
 
    if plans.empty?
@@ -10,7 +10,7 @@
 <%
    else
      first_plan = plans[0]
-     plan_options = options_for_select([[]] + plans.map { |plan|
+     plan_options = options_for_select([[message('issue.unplanned'), '']] + plans.map { |plan|
        if plan.deadLine
          label = "#{h plan.name} (#{format_date(plan.deadLine)})"
        else
index b42b18f933ff5be1bf4601b176789b99d8e28fe7..5ee5c788a01034a167828f8e6816787a79b01eb4 100644 (file)
@@ -27,7 +27,7 @@
           <tr>
             <td class="thin nowrap center"><img src="<%= ApplicationController.root_context -%>/images/status/<%= plan.status() -%>.png" title="<%= message('issues_action_plans.status' + plan.status()) -%>"/></td>
             <td class="thin nowrap"><%= h(plan.name()) -%></td>
-            <td class="thin nowrap <%= 'over-due' if plan.overDue() -%>" align="right" x="<%= deadline ? deadline.tv_sec : '' -%>"><%= format_date(plan.deadLine())  -%></td>
+            <td class="thin nowrap <%= 'over-due' if plan.overDue() -%>" align="right" x="<%= deadline ? deadline.tv_sec : '' -%>"><%= format_date(plan.deadLine(), :time_if_today => true)  -%></td>
             <% if plan.totalIssues()==0 %>
               <td class="noprogress thin nowrap">
                 <%= message('issues_action_plans.no_issues_linked_to_action_plan') -%>