import javax.annotation.Nullable;
import java.util.Collections;
-import java.util.Comparator;
import java.util.Date;
import java.util.List;
}
/**
- * List of available transitions, ordered by key.
+ * List of available transitions.
* <p/>
* Never return null, but return an empty list if the issue does not exist.
*/
public List<Transition> listTransitions(String issueKey) {
- DefaultIssue issue = loadIssue(issueKey);
- if (issue == null) {
- return Collections.emptyList();
- }
- List<Transition> transitions = workflow.outTransitions(issue);
- Collections.sort(transitions, new Comparator<Transition>() {
- @Override
- public int compare(Transition transition, Transition transition2) {
- return transition.key().compareTo(transition2.key());
- }
- });
- return transitions;
+ return listTransitions(loadIssue(issueKey));
}
/**
if (issue == null) {
return Collections.emptyList();
}
- List<Transition> transitions = workflow.outTransitions(issue);
- Collections.sort(transitions, new Comparator<Transition>() {
- @Override
- public int compare(Transition transition, Transition transition2) {
- return transition.key().compareTo(transition2.key());
- }
- });
- return transitions;
+ return workflow.outTransitions(issue);
}
public Issue doTransition(String issueKey, String transition, UserSession userSession) {
<a class="open-modal" modal-width="800" href="<%= url_for :controller => 'rules', :action => 'show', :id => issue.rule_key.to_s, :modal => 'true', :layout => 'false' -%>"><%= h rule_name -%></a>
</span>
- <%= image_tag 'sep12.png' -%>
-
-
- <%
- created_at = Api::Utils.java_to_ruby_datetime(issue.creationDate())
- updated_at = Api::Utils.java_to_ruby_datetime(issue.updateDate())
- 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>
-
- <%
- if issue.resolution
- %>
+ <% if issue.resolution %>
<%= image_tag 'sep12.png' -%>
<span><%= message("issue.resolution.#{issue.resolution}") -%></span>
<span><%= message("issue.status.#{issue.status}") -%></span>
<% end %>
+ <%= image_tag 'sep12.png' -%>
+
<%
- if issue.assignee
- %>
- <%= image_tag 'sep12.png' -%>
-
- <%= message('assigned_to') -%> <%= h(@issue_results.user(issue.assignee).name) -%>
-
- <% end %>
- <%
- if issue.actionPlanKey()
+ created_at = Api::Utils.java_to_ruby_datetime(issue.creationDate())
+ updated_at = Api::Utils.java_to_ruby_datetime(issue.updateDate())
+ 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>
+
+ <% if issue.reporter %>
<%= image_tag 'sep12.png' -%>
- <%= message('issue.planned_for_x', :params => h(@issue_results.actionPlan(issue).name())) if @issue_results.actionPlan(issue) -%>
+ <span><%= message('issue.reported_by') -%> <%= @issue_results.user(issue.reporter).name -%></span>
<% end %>
-
</div>
<% unless issue.message.blank? %>
<% end %>
<% if current_user %>
+ <% transitions = Internal.issues.listTransitions(issue) %>
+
<div class="code-issue-actions">
<a href='#' onclick="return issueForm('comment', this)" class="link-action spacer-right"><%= message('issue.comment.formlink') -%></a>
<% unless issue.resolution %>
+ <%= image_tag 'sep12.png' -%>
+
<span class="spacer-right">
- <a href='#' onclick="return issueForm('assign', this)" class="link-action"><%= message('issue.assign.formlink') -%></a>
+ <% if !issue.assignee %>
+ <a href='#' onclick="return issueForm('assign', this)" class="link-action"><%= message('issue.assign.formlink') -%></a>
<% if issue.assignee!=current_user.login %>
- [<a href="#" onclick="return assignIssueToMe(this)" class="link-action"><%= message('issue.assign.to_me') -%></a>]
+ [<a href="#" onclick="return assignIssueToMe(this)" class="link-action"><%= message('issue.assign.to_me') -%></a>]
+ <% end %>
+ <% else %>
+ <a href='#' onclick="return issueForm('assign', this)" class="link-action"><%= message('assigned_to') -%></a> <%= @issue_results.user(issue.assignee).name -%>
<% end %>
</span>
<% end %>
- <% Internal.issues.listTransitions(issue).each do |transition| %>
+ <% unless issue.resolution %>
+ <%= image_tag 'sep12.png' -%>
+
+ <span class="spacer-right">
+ <% if !@issue_results.actionPlan(issue) %>
+ <a href="#" onclick="return issueForm('plan', this)" class="link-action"><%= message('issue.do_plan') -%></a>
+ <% else %>
+ <a href="#" onclick="return issueForm('plan', this)" class="link-action"><%= message('issue.planned_for') -%></a> <%= h(@issue_results.actionPlan(issue).name()) -%>
+ <% end %>
+ </span>
+ <% end %>
+
+ <%
+ if transitions.size > 0 && transitions.first
+ transition = transitions.first
+ %>
+ <%= image_tag 'sep12.png' -%>
+
<a href="#" onclick="return doIssueTransition(this, '<%= transition.key -%>')" class="link-action spacer-right"><%= message("issue.transition.#{transition.key}") -%></a>
<% end %>
- <% unless issue.resolution %>
- <a href="#" onclick="return issueForm('severity', this)" class="link-action spacer-right"><%= message("issue.set_severity") -%></a>
- <a href="#" onclick="return issueForm('plan', this)" class="link-action spacer-right"><%= message("issue.do_plan") -%></a>
+ <%
+ if transitions.size > 1 || !issue.resolution
+ transitions.remove(0)
+ %>
+ <div class="dropdown">
+ <a href="#" class="link-action link-more" onclick="showDropdownMenuOnElement($j(this).next('.dropdown-menu')); return false;"><%= message('more_actions') -%></a>
+ <ul style="display: none" class="dropdown-menu">
+ <% unless issue.resolution %>
+ <li><a href="#" onclick="return issueForm('severity', this)" class="link-action spacer-right"><%= message("issue.set_severity") -%></a></li>
+ <% end %>
+ <% transitions.each do |transition| %>
+ <li><a href="#" onclick="return doIssueTransition(this, '<%= transition.key -%>')" class="link-action spacer-right"><%= message("issue.transition.#{transition.key}") -%></a></li>
+ <% end %>
+ </ul>
+ </div>
<% end %>
</div>
<div class="code-issue-form hidden"></div>
var currentlyDisplayedDropdownMenu;
var hideCurrentDropdownMenu = function () {
- menu = $j('#' + currentlyDisplayedDropdownMenu);
- if (menu) {
- menu.hide();
+ if (currentlyDisplayedDropdownMenu) {
+ currentlyDisplayedDropdownMenu.hide();
}
$j(document).unbind('mouseup', hideCurrentDropdownMenu);
}
}
function showDropdownMenu(menuId) {
- if (menuId == currentlyDisplayedDropdownMenu) {
+ showDropdownMenuOnElement($j('#' + menuId));
+}
+
+function showDropdownMenuOnElement(elt) {
+ var dropdownElt = $j(elt);
+ var dropdownChildren = dropdownElt.children('li');
+
+ if (dropdownElt == currentlyDisplayedDropdownMenu) {
currentlyDisplayedDropdownMenu = "";
} else {
- currentlyDisplayedDropdownMenu = menuId;
+ currentlyDisplayedDropdownMenu = dropdownElt;
$j(document).mouseup(hideCurrentDropdownMenu);
- $j('#' + currentlyDisplayedDropdownMenu + ' li').unbind('click');
- $j('#' + currentlyDisplayedDropdownMenu + ' li').click(clickOnDropdownMenuLink);
- $j('#' + currentlyDisplayedDropdownMenu).show();
+ dropdownChildren.unbind('click');
+ dropdownChildren.click(clickOnDropdownMenuLink);
+ dropdownElt.show();
}
}