Skip to content

Commit

Permalink
navbar: Change new issue button action of nav bar
Browse files Browse the repository at this point in the history
  • Loading branch information
doortts committed Sep 24, 2017
1 parent 8255749 commit b01db32
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
21 changes: 13 additions & 8 deletions app/controllers/IssueApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import jxl.write.WriteException;
import models.*;
import models.enumeration.Operation;
import models.enumeration.ProjectScope;
import models.enumeration.ResourceType;
import models.enumeration.State;
import org.apache.commons.collections.CollectionUtils;
Expand Down Expand Up @@ -293,12 +294,8 @@ public static Result newDirectIssueForm() {
User current = UserApp.currentUser();

Project project = null;
// Fallback #1: Favorite projects 1st if exists
if(!CollectionUtils.isEmpty(current.favoriteProjects)) {
project = current.favoriteProjects.get(current.favoriteProjects.size() - 1).project;
}

// Fallback #2: Last visited project
// Fallback #1: Last visited project
List<Project> visitedProjects = current.getVisitedProjects();
if (project == null && !CollectionUtils.isEmpty(visitedProjects)) {
project = visitedProjects.get(0);
Expand All @@ -321,10 +318,18 @@ public static Result newDirectMyIssueForm() {
project = Project.findByOwnerAndProjectName(current.loginId, "_private");
}

// Fallback to any other project
// Fallback to my project which is private and recently created
if (project == null) {
List<Project> projects = Project.findProjectsCreatedByUserAndScope(current.loginId, ProjectScope.PRIVATE, "createdDate desc");
if (!CollectionUtils.isEmpty(projects)) {
project = projects.get(0);
}
}

// Fallback to my public project
if( project == null ) {
List<Project> projects = Project.findProjectsByMember(current.id);
if(!CollectionUtils.isEmpty(projects)) {
List<Project> projects = Project.findProjectsCreatedByUserAndScope(current.loginId, ProjectScope.PUBLIC, "createdDate desc");
if (!CollectionUtils.isEmpty(projects)) {
project = projects.get(0);
}
}
Expand Down
6 changes: 6 additions & 0 deletions app/models/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,12 @@ public static List<Project> findProjectsCreatedByUser(String loginId, String ord

}

public static List<Project> findProjectsCreatedByUserAndScope(String loginId, ProjectScope projectScope, String orderString) {
return find.where().eq("owner", loginId)
.eq("projectScope", projectScope)
.orderBy(orderString).findList();
}

public Date lastUpdateDate() {
try {
PlayRepository repository = RepositoryService.getRepository(this);
Expand Down
2 changes: 1 addition & 1 deletion conf/messages
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ issue.list.authoredByMe = Created
issue.list.commentedByMe = Commented
issue.list.mentionedOfMe = Mentioned
issue.menu.new = New issue
issue.menu.new.mine = New issue - personal
issue.menu.new.mine = New issue - personal inbox
issue.myIssue = My issues
issue.new.result = Results
issue.noAssignee = No assignee
Expand Down
2 changes: 1 addition & 1 deletion conf/messages.ko-KR
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ issue.list.authoredByMe = 작성한 이슈
issue.list.commentedByMe = 댓글 남긴 이슈
issue.list.mentionedOfMe = 나를 언급한 이슈
issue.menu.new = 새 이슈
issue.menu.new.mine = 새 이슈 - 개인
issue.menu.new.mine = 새 이슈 - 개인 inbox
issue.myIssue = 내 이슈
issue.new.result = 확인결과
issue.noAssignee = 담당자 없음
Expand Down

0 comments on commit b01db32

Please sign in to comment.