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
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
<tbody>
<%
open_action_plans.each do |plan|
- deadline = Api::Utils.java_to_ruby_datetime(plan.deadLine()) if plan.deadLine()
%>
<tr class="<%= show_resolved_issues ? '' : cycle("even", "odd", :name => "action_plan_" + widget.id.to_s) -%>">
<td class="nowrap <%= line_class -%>"><%= h(plan.name) -%></td>
- <td class="nowrap small <%= line_class -%> <%= 'over-due' if plan.overDue() -%>" style="text-align: right; padding-left:10px"><%= deadline ? deadline.strftime("%d %b %Y") : ' ' -%></td>
+ <td class="nowrap small <%= line_class -%> <%= 'over-due' if plan.overDue() -%>" style="text-align: right; padding-left:10px"><%= format_date(plan.deadLine()) -%></td>
<% if show_resolved_issues %>
<% if plan.totalIssues()==0 %>
* 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;
}
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
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
#
# Creates a dropdown selection box.
+ #
# ==== Options
# * <tt>:width</tt> - The width suffixed with unit, for example '300px' or '100%'. Default is '250px'
# * <tt>:placeholder</tt> - the label to display when nothing is selected. Default is ''.
# * <tt>:open</tt> - true to open the select-box. Default is false. Since 3.6.
# * <tt>:select2_options</tt> - 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
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
# 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
+<% user_select_box_id = "assignee-#{params[:issue]}" %>
<form action="">
<input type="hidden" name="issue" value="<%= params[:issue] -%>"/>
<input type="hidden" name="id" value="assign"/>
<table class="width100">
<tr>
<td style="vertical-align:top">
- <%= user_select_tag('assignee', :html_id => "assignee-#{params[:issue]}", :open => true) -%>
+ <%= user_select_tag('assignee', :html_id => user_select_box_id, :open => true) -%>
<input type="button" value="<%= message('issue.assign.submit') -%>" onclick="submitIssueForm(this)">
- <%= link_to_function message('cancel'), 'closeIssueForm(this)' -%>
+
+ <% if @issue.assignee %>
+ <%= image_tag 'sep12.png' -%>
+
+ <input type="button" value="<%= message('issue.unassign.submit') -%>" onclick="$j('#<%= user_select_box_id -%>').val('');submitIssueForm(this)">
+
+ <% end %>
+ <%= link_to_function message('cancel'), 'closeIssueForm(this)' -%>
<span class="loading hidden"></span>
</td>
</tr>
<%
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)}"
%>
<span title="<%= h dates_title -%>"><%= distance_of_time_in_words_to_now(created_at) -%></span>
<%
- 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?
%>
<span class="error"><%= message('issue.plan_must_be_created_first') -%></span>
<%= 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 %>
-<form method="POST">
- <input type="hidden" name="issue" value="<%= params[:issue] -%>"/>
- <input type="hidden" name="id" value="plan"/>
+%>
+ <form method="POST">
+ <input type="hidden" name="issue" value="<%= params[:issue] -%>"/>
+ <input type="hidden" name="id" value="plan"/>
- <select name="plan">
- <option value=""></option>
- <% plans.each do |plan| %>
- <option value="<%= plan.key() -%>"><%= h(plan.name()) -%></option>
- <% end %>
- </select>
+ <%= dropdown_tag('plan', plan_options, {:show_search_box => false}, {:id => plans_select_box_id}) -%>
- <input type="button" value="<%= message('issue.plan.submit') -%>" onclick="submitIssueForm(this)">
- <%= link_to_function message('cancel'), 'closeIssueForm(this)' -%>
- <span class="loading hidden"></span>
+ <input type="button" value="<%= message('issue.plan.submit') -%>" onclick="submitIssueForm(this)">
+
+ <% if @issue.actionPlanKey %>
+ <%= image_tag 'sep12.png' -%>
+
+ <input type="button" value="<%= message('issue.unplan.submit') -%>" onclick="$j('#<%= plans_select_box_id -%>').val('');$j('#<%= plans_select_box_id -%>').prop('disabled', false);submitIssueForm(this)">
+ <% end %>
+ <%= link_to_function message('cancel'), 'closeIssueForm(this)' -%>
+ <span class="loading hidden"></span>
-</form>
+ </form>
<% end %>
<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 : '' -%>"><%= deadline ? deadline.strftime("%d %b %Y") : ' ' -%></td>
+ <td class="thin nowrap <%= 'over-due' if plan.overDue() -%>" align="right" x="<%= deadline ? deadline.tv_sec : '' -%>"><%= format_date(plan.deadLine()) -%></td>
<% if plan.totalIssues()==0 %>
<td class="noprogress thin nowrap">
<%= message('issues_action_plans.no_issues_linked_to_action_plan') -%>
<tr>
<td class="thin nowrap center"><img src="<%= ApplicationController.root_context -%>/images/status/<%= plan.status() -%>.png" title="<%= message(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 : '' -%>"><%= deadline ? deadline.strftime("%d %b %Y") : ' ' -%></td>
- <td class="thin nowrap" align="right" x="<%= updated_at.tv_sec -%>"><%= updated_at.strftime("%d %b %Y") -%></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" align="right" x="<%= updated_at.tv_sec -%>"><%= format_date(plan.updatedAt()) -%></td>
<% if plan.totalIssues()==0 %>
<td class="noprogress thin nowrap">
<%= message('issues_action_plans.no_issues_linked_to_action_plan') -%>