Skip to content
This repository has been archived by the owner on Sep 12, 2018. It is now read-only.

Commit

Permalink
Shows admin on Assignee dropdown list when admin is login user or a…
Browse files Browse the repository at this point in the history
…ssignee.

Cause:
When `admin` assigns an issue to himself, dropdown list default value is set to `No assignee` because `Assignee dropdown list` does not include `admin` user.

Solution:
If login user is admin, he will be shown on `Assignee dropdown list`. Also an issue that assignee is admin will show admin on the list.

Private-issue: 1091
  • Loading branch information
ChangsungKim committed Aug 18, 2014
1 parent d9449d0 commit 5184244
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 17 deletions.
10 changes: 8 additions & 2 deletions app/models/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.avaje.ebean.Ebean;
import com.avaje.ebean.ExpressionList;
import com.avaje.ebean.Page;
import controllers.UserApp;
import models.enumeration.ProjectScope;
import models.enumeration.RequestState;
import models.enumeration.ResourceType;
Expand Down Expand Up @@ -460,13 +461,13 @@ public List<ProjectUser> members() {
}

/**
* Return users related to this project and group of the project.
* Return assignable users to this project and group of the project.
*
* If the project has no groups, it returns all project members.
* If the project has a group and is private, it returns all project members and group admins.
* If the project has a group and is protected or public, it returns all project and group members.
*/
public List<User> relatedUsers() {
public List<User> getAssignableUsers() {
Set<User> users = new HashSet<>();

// member of this project.
Expand All @@ -486,6 +487,11 @@ public List<User> relatedUsers() {
// sorting
List<User> result = new ArrayList<>(users);
Collections.sort(result, User.USER_NAME_COMPARATOR);

if (UserApp.currentUser().isSiteManager()) {
result.add(UserApp.currentUser());
}

return result;
}

Expand Down
29 changes: 19 additions & 10 deletions app/views/issue/partial_assignee.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@

@import utils.AccessControl._

@makeOptionTagWithFlag(user:User, flag:String) = {
<option value="@user.id"
data-avatar-url="@User.findByLoginId(user.loginId).avatarUrl"
data-login-id="@user.loginId"
@flag>
@user.name
</option>
}

<select id="assignee" name="assignee.user.id" data-field-name="assignee.id"
data-toggle="select2" data-format="user" data-container-css-class="fullsize">
<option value="@User.anonymous.id" @if(issue == null || issue.assignee == null){selected}>@Messages("issue.noAssignee")</option>
Expand All @@ -36,15 +45,15 @@
}
}
}
@for(user <- project.relatedUsers){
<option value="@user.id"
data-avatar-url="@User.findByLoginId(user.loginId).avatarUrl"
data-login-id="@user.loginId"
@if(issue != null && issue.assignee != null && issue.assignee.user.loginId == user.loginId){
selected
}
>
@user.name
</option>
@for(user <- project.getAssignableUsers){
@if(issue != null && issue.assignee != null && issue.assignee.user.loginId == user.loginId) {
@makeOptionTagWithFlag(user, "selected")
} else {
@makeOptionTagWithFlag(user,"")
}
}

@if(issue.assignee != null && issue.assignee.user.isSiteManager() && !UserApp.currentUser().isSiteManager()) {
@makeOptionTagWithFlag(issue.assignee.user, "selected")
}
</select>
10 changes: 5 additions & 5 deletions app/views/issue/partial_massupdate.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@
<li data-value="@UserApp.currentUser().id"><a>@Messages("issue.assignToMe")</a></li>
}
<li class="divider"></li>
@for(member <- project.members()) {
<li data-value="@member.user.id">
@for(user <- project.getAssignableUsers()) {
<li data-value="@user.id">
<a class="usf-group">
<span class="avatar-wrap smaller">
<img src="@member.user.avatarUrl" width="20" height="20">
<img src="@user.avatarUrl" width="20" height="20">
</span>
<strong class="name">@member.user.name</strong>
<span class="loginid"> <strong>@{"@"}</strong>@member.user.loginId</span>
<strong class="name">@user.name</strong>
<span class="loginid"> <strong>@{"@"}</strong>@user.loginId</span>
</a>
</li>
}
Expand Down

0 comments on commit 5184244

Please sign in to comment.