Skip to content

Commit

Permalink
issue: Minimum issue moving from and to projects
Browse files Browse the repository at this point in the history
  • Loading branch information
doortts committed Mar 13, 2017
1 parent 340e054 commit 2bfc22d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
23 changes: 21 additions & 2 deletions app/controllers/IssueApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -528,15 +528,34 @@ public static Result editIssue(String ownerName, String projectName, Long number
}

final Issue issue = issueForm.get();

setAssignee(issueForm, issue, project);
removeAnonymousAssignee(issue);
setMilestone(issueForm, issue);
issue.dueDate = JodaDateUtil.lastSecondOfDay(issue.dueDate);

final Issue originalIssue = Issue.findByNumber(project, number);
Issue originalIssue = Issue.findByNumber(project, number);
if(StringUtils.isNotEmpty(issue.targetProjectId)){
Project toAnotherProject = Project.find.byId(Long.valueOf(issue.targetProjectId));
if(toAnotherProject == null){
flash(Constants.WARNING, Messages.get("error.notfound.project"));
return badRequest(edit.render("error.validation", issueForm, Issue.findByNumber(project, number), project));
} else if (!project.id.equals(toAnotherProject.id)){
originalIssue.project = toAnotherProject;
originalIssue.setNumber(Project.increaseLastIssueNumber(toAnotherProject.id));
originalIssue.createdDate = JodaDateUtil.now();
originalIssue.updatedDate = JodaDateUtil.now();
originalIssue.milestone = null;
for(IssueComment comment: originalIssue.comments){
comment.projectId = originalIssue.project.id;
comment.update();
}
originalIssue.update();
}
}
updateSubtaskRelation(issue, originalIssue);

Call redirectTo = routes.IssueApp.issue(project.owner, project.name, number);
Call redirectTo = routes.IssueApp.issue(originalIssue.project.owner, originalIssue.project.name, originalIssue.getNumber());

// preUpdateHook.run would be called just before this issue is updated.
// It updates some properties only for issues, such as assignee or labels, but not for non-issues.
Expand Down
2 changes: 1 addition & 1 deletion app/views/issue/partial_list_subtask.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@if(issue.parent != null){
<span class="infos-item subtask">
@defining(Issue.finder.byId(issue.parent.id)) { parentIssue =>
<a href="@routes.IssueApp.issue(project.owner, project.name, parentIssue.getNumber)">#@parentIssue.getNumber @parentIssue.title.take(5).trim()@if(parentIssue.title.size > 5){...}</a>
<a href="@routes.IssueApp.issue(parentIssue.project.owner, parentIssue.project.name, parentIssue.getNumber)">#@parentIssue.getNumber @parentIssue.title.take(5).trim()@if(parentIssue.title.size > 5){...}</a>
}
</span>
}
7 changes: 5 additions & 2 deletions app/views/issue/partial_select_subtask.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@(project:Project, parentIssueId:Long, currentIssueId:Long)

@showOption = @{Option(parentIssueId).isDefined && Option(currentIssueId).isDefined}
@hasChildIssue = @{Option(currentIssueId).isDefined && Issue.finder.byId(currentIssueId).hasChildIssue}
@import utils.TemplateHelper._

<div class="subtask-wrap @if(showOption){show}">
Expand All @@ -22,14 +23,16 @@
</div>
<div class="span6">
<select id="parentId" name="parentIssueId" data-format="issues" data-placeholder="@Messages("organization.choose.projects")" data-toggle="select2" data-container-css-class="fullsize" @if(!showOption){disabled}>
<option value="" selected>@Messages("issue.subtask.select")</option>
<option value="" selected>@if(hasChildIssue){이미 부모 이슈입니다.}else{@Messages("issue.subtask.select")}</option>
@if(Option(parentIssueId).isDefined){
@defining(Issue.finder.byId(parentIssueId)) { issue =>
<option value="@issue.id" selected>#@issue.getNumber. @issue.title</option>
}
}
@for(issue <- Issue.findByProject(project, "", 1).filter(issue => issue.id != currentIssueId)) {
<option value="@issue.id" @if(issue.id == parentIssueId){selected}>#@issue.getNumber. @issue.title</option>
@if(issue.parent == null && !hasChildIssue) {
<option value="@issue.id" @if(issue.id == parentIssueId) {selected}>#@issue.getNumber. @issue.title </option>
}
}
</select>
</div>
Expand Down
6 changes: 3 additions & 3 deletions app/views/issue/view.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
@if(!openChildIssues.isEmpty || !closedChildIssues.isEmpty) {
<div class="child-issues">
@defining(Issue.finder.byId(parentIssueId)) { parentIssue =>
<div class="issue-item parent-issue"><a href="@routes.IssueApp.issue(project.owner, project.name, parentIssue.getNumber)" class="@if(parentIssue.id == issue.id){bold}">#@parentIssue.getNumber @parentIssue.title @if(parentIssue.assignee != null) {- @parentIssue.assignee.user.name}</a>
<div class="issue-item parent-issue"><a href="@routes.IssueApp.issue(parentIssue.project.owner, parentIssue.project.name, parentIssue.getNumber)" class="@if(parentIssue.id == issue.id){bold}">#@parentIssue.getNumber @parentIssue.title @if(parentIssue.assignee != null) {- @parentIssue.assignee.user.name}</a>
@defining(getPercent(closedChildIssues.size.toDouble, (openChildIssues.size + closedChildIssues.size).toDouble)) { percentage =>
<div class="upload-progress">
<div class="bar @if(percentage == 100){done} else {grey}" style="width: @percentage%;" title="Subtask"></div>
Expand All @@ -73,15 +73,15 @@
@for(childIssue <- openChildIssues) {
<div class="issue-item @if(childIssue.id == issue.id){bold}">
<span class="state-label open"></span>
<a href="@routes.IssueApp.issue(project.owner, project.name, childIssue.getNumber)">
<a href="@routes.IssueApp.issue(childIssue.project.owner, childIssue.project.name, childIssue.getNumber)">
<span class="item-name">@childIssue.title @if(childIssue.assignee != null) {- @childIssue.assignee.user.name}</span>
</a>
</div>
}
@for(childIssue <- closedChildIssues) {
<div class="issue-item @if(childIssue.id == issue.id){bold}">
<span class="state-label closed"><i class=" yobicon-checkmark"></i></span>
<a href="@routes.IssueApp.issue(project.owner, project.name, childIssue.getNumber)">
<a href="@routes.IssueApp.issue(childIssue.project.owner, childIssue.project.name, childIssue.getNumber)">
<span class="item-name">@childIssue.title @if(childIssue.assignee != null) {- @childIssue.assignee.user.name}</span>
</a>
</div>
Expand Down

0 comments on commit 2bfc22d

Please sign in to comment.