From: Simon Brandhof Date: Wed, 22 May 2013 10:19:04 +0000 (+0200) Subject: SONAR-3755 various improvements on plan and assign actions X-Git-Tag: 3.6~315 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b767a9f5ca9b271a1060a9c501c5fbebd17cfa07;p=sonarqube.git 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 --- 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 460c7422720..5658dd3d0bb 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 @@ -531,6 +531,7 @@ reviews.filtered_by.to=To date issue.assign.formlink=Assign issue.assign.submit=Assign +issue.unassign.submit=Unassign issue.assign.to_me=to me issue.comment.formlink=Comment issue.comment.submit=Comment @@ -545,6 +546,7 @@ issue.set_severity=Set Severity issue.set_severity.submit=Set Severity issue.do_plan=Plan issue.plan.submit=Plan +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 issue.status.RESOLVED=Resolved diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/action_plans.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/action_plans.html.erb index 4d896a83f76..f6736a6cddc 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/action_plans.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/action_plans.html.erb @@ -45,11 +45,10 @@ <% open_action_plans.each do |plan| - deadline = Api::Utils.java_to_ruby_datetime(plan.deadLine()) if plan.deadLine() %> "action_plan_" + widget.id.to_s) -%>"> <%= h(plan.name) -%> - <%= deadline ? deadline.strftime("%d %b %Y") : ' ' -%> + <%= format_date(plan.deadLine()) -%> <% if show_resolved_issues %> <% if plan.totalIssues()==0 %> diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueQuery.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueQuery.java index 74edf09d6ec..b27dd441564 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueQuery.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueQuery.java @@ -281,7 +281,7 @@ public class IssueQuery { * If true, it will return all issues linked to an action plan * If false, it will return all issues not linked to an action plan */ - public Builder planned(Boolean planned) { + public Builder planned(@Nullable Boolean planned) { this.planned = planned; return this; } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/issue_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/issue_controller.rb index 83a806f7a88..fb28aded774 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/issue_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/issue_controller.rb @@ -39,6 +39,10 @@ class IssueController < ApplicationController def action_form verify_ajax_request require_parameters :id, :issue + + @issue_result = Api.issues.find(params[:issue]) + @issue = @issue_result.issues().get(0) + action_type = params[:id] render :partial => "issue/#{action_type}_form" 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 013da3c1bb8..1ff52dcb29d 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 @@ -26,6 +26,40 @@ module ApplicationHelper super(location, options) end + # Since 3.6 + # java.util.Date is supported + # + # == Options + # * :format - See Ruby on Rails localization options + # + def format_datetime(object, options={}) + return nil unless object + if object.is_a?(Java::JavaUtil::Date) + dt = Api::Utils.java_to_ruby_datetime(object) + else + dt = object + end + l(dt, options) + end + + # Since 3.6 + # java.util.Date is supported + # + # == Options + # * :format - See Ruby on Rails localization options + # + def format_date(object, options={}) + return nil unless object + if object.is_a?(Java::JavaUtil::Date) + date = Api::Utils.java_to_ruby_datetime(object).to_date + elsif object.respond_to?(:to_date) + date = object.to_date + else + date = object + end + l(date, options) + end + def sonar_version Java::OrgSonarServerPlatform::Platform.getServer().getVersion() end @@ -724,6 +758,7 @@ module ApplicationHelper # # Creates a dropdown selection box. + # # ==== Options # * :width - The width suffixed with unit, for example '300px' or '100%'. Default is '250px' # * :placeholder - the label to display when nothing is selected. Default is ''. @@ -732,6 +767,9 @@ module ApplicationHelper # * :open - true to open the select-box. Default is false. Since 3.6. # * :select2_options - hash of select2 options # + # ==== Example + # dropdown_tag('user', [['Morgan', 'morgan'], ['Simon', 'simon']], {:show_search_box => false}, {:id => 'users_123'}) + # def dropdown_tag(name, option_tags, options={}, html_options={}) width=options[:width]||'250px' html_id=html_options[:id]||name @@ -739,8 +777,8 @@ module ApplicationHelper minimumResultsForSearch=show_search_box ? 0 : option_tags.size + 1 js_options={ - 'minimumResultsForSearch' => minimumResultsForSearch, - 'allowClear' => options[:allow_clear]||false, + 'minimumResultsForSearch' => minimumResultsForSearch, + 'allowClear' => options[:allow_clear]||false, } js_options['placeholder']= options.has_key?(:placeholder) ? "'#{options[:placeholder]}'" : "''" js_options['width']= "'#{width}'" if width diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/api.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/api.rb index 13870a3a4f6..b3ca183f1ac 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/api.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/api.rb @@ -22,12 +22,14 @@ # as an API and can evolve through time. class Api - # since 3.6 + # See the javadoc of org.sonar.api.issue.RubyIssueService. + # Since 3.6 def self.issues Internal.issues_api end - # since 3.6 + # See the javadoc of org.sonar.api.user.RubyUserService + # Since 3.6 def self.users Internal.users_api end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_assign_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_assign_form.html.erb index 2d8be33f28f..1399397f159 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_assign_form.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_assign_form.html.erb @@ -1,12 +1,20 @@ +<% user_select_box_id = "assignee-#{params[:issue]}" %>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_issue.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_issue.html.erb index 7a12817dcee..c5520fed88b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_issue.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_issue.html.erb @@ -13,7 +13,7 @@ <% created_at = Api::Utils.java_to_ruby_datetime(issue.creationDate()) updated_at = Api::Utils.java_to_ruby_datetime(issue.updateDate()) - dates_title = "Created at #{l created_at} and updated at #{l updated_at}" + dates_title = "Created at #{format_datetime(created_at)} and updated at #{format_datetime(updated_at)}" %> <%= distance_of_time_in_words_to_now(created_at) -%>   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 0749fc032e5..8848f3fe52b 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,27 +1,41 @@ <% - plans = Internal.issues.findOpenActionPlans(params[:issue]) + plans_select_box_id = "plans-#{params[:issue]}" + plans = Internal.issues.findOpenActionPlans(params[:issue]).sort_by { |plan| plan.deadLine } - if plans.empty? + + if plans.empty? %> <%= message('issue.plan_must_be_created_first') -%>  <%= link_to_function message('cancel'), 'closeIssueForm(this)' -%> +<% + else + first_plan = plans[0] + plan_options = options_for_select([[]] + plans.map { |plan| + if plan.deadLine + label = "#{h plan.name} (#{format_date(plan.deadLine)})" + else + label = h plan.name + end + [label, plan.key] + }, first_plan.key) -<% else %> - - - +%> + + + - + <%= dropdown_tag('plan', plan_options, {:show_search_box => false}, {:id => plans_select_box_id}) -%> - -  <%= link_to_function message('cancel'), 'closeIssueForm(this)' -%>  - + +   + <% if @issue.actionPlanKey %> + <%= image_tag 'sep12.png' -%> +   + + <% end %> + <%= link_to_function message('cancel'), 'closeIssueForm(this)' -%>  + - + <% end %> 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 ffcb7cefc04..b42b18f933f 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 @@ - + <% if plan.totalIssues()==0 %> - - + + <% if plan.totalIssues()==0 %>
- <%= user_select_tag('assignee', :html_id => "assignee-#{params[:issue]}", :open => true) -%> + <%= user_select_tag('assignee', :html_id => user_select_box_id, :open => true) -%> -  <%= link_to_function message('cancel'), 'closeIssueForm(this)' -%>  +   + <% if @issue.assignee %> + <%= image_tag 'sep12.png' -%> +   + +   + <% end %> + <%= link_to_function message('cancel'), 'closeIssueForm(this)' -%> 
<%= h(plan.name()) -%><%= deadline ? deadline.strftime("%d %b %Y") : ' ' -%><%= format_date(plan.deadLine()) -%> <%= message('issues_action_plans.no_issues_linked_to_action_plan') -%> @@ -85,8 +85,8 @@
<%= h(plan.name) -%><%= deadline ? deadline.strftime("%d %b %Y") : ' ' -%><%= updated_at.strftime("%d %b %Y") -%><%= format_date(plan.deadLine()) -%><%= format_date(plan.updatedAt()) -%> <%= message('issues_action_plans.no_issues_linked_to_action_plan') -%>