diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-05-22 14:29:32 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-05-22 14:29:32 +0200 |
commit | 6eacc3d1eab02885c35667cd8abab13ad344b4ef (patch) | |
tree | 57a27c72b7a869139d12b8db62c82cd8f17951df | |
parent | b767a9f5ca9b271a1060a9c501c5fbebd17cfa07 (diff) | |
download | sonarqube-6eacc3d1eab02885c35667cd8abab13ad344b4ef.tar.gz sonarqube-6eacc3d1eab02885c35667cd8abab13ad344b4ef.zip |
SONAR-3755 various improvements on plan and assign actions
* display deadline besides the action plans
* unplan button
* unassign button
* Ruby API to easily format java or ruby dates
6 files changed, 25 insertions, 14 deletions
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties index 5658dd3d0bb..138a4e1676a 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -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 diff --git a/sonar-core/src/main/resources/org/sonar/core/issue/db/ActionPlanMapper.xml b/sonar-core/src/main/resources/org/sonar/core/issue/db/ActionPlanMapper.xml index 663284e21ac..2e091afd2ba 100644 --- a/sonar-core/src/main/resources/org/sonar/core/issue/db/ActionPlanMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/issue/db/ActionPlanMapper.xml @@ -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"> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_action_plans_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_action_plans_controller.rb index 9dc9d445d42..6fda7363ac3 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_action_plans_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_action_plans_controller.rb @@ -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 diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb index 1ff52dcb29d..032f8759df6 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb @@ -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 diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_plan_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_plan_form.html.erb index 8848f3fe52b..74982bc1c3d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_plan_form.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_plan_form.html.erb @@ -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 diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/issues_action_plans/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/issues_action_plans/index.html.erb index b42b18f933f..5ee5c788a01 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/issues_action_plans/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/issues_action_plans/index.html.erb @@ -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') -%> |