Skip to content

Commit

Permalink
subtask: Reopen parent issue when child reopen
Browse files Browse the repository at this point in the history
  • Loading branch information
doortts committed Sep 25, 2017
1 parent 43a380a commit 5157a14
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/controllers/IssueApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,11 @@ public static Result nextState(String ownerName, String projectName, Long number
final Issue issue = Issue.findByNumber(project, number);

Call redirectTo = routes.IssueApp.issue(project.owner, project.name, number);
issue.toNextState();
State state = issue.toNextState();

if(state == State.OPEN && issue.hasParentIssue() && issue.parent.state == State.CLOSED) {
issue.parent.toNextState();
}
NotificationEvent notiEvent = NotificationEvent.afterStateChanged(issue.previousState(), issue);
IssueEvent.addFromNotificationEvent(notiEvent, issue, UserApp.currentUser().loginId);
return redirect(redirectTo);
Expand Down
6 changes: 6 additions & 0 deletions app/models/Issue.java
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,12 @@ public boolean hasChildIssue(){
.findRowCount() > 0;
}

public boolean hasParentIssue(){
return finder.where()
.isNotNull("parent.id")
.findRowCount() > 0;
}

public static List<Issue> findByParentIssueIdAndState(Long parentIssueId, State state){
return finder.where()
.eq("parent.id", parentIssueId)
Expand Down

0 comments on commit 5157a14

Please sign in to comment.