Skip to content

Commit

Permalink
subtask: Disable parent issue selection case by case
Browse files Browse the repository at this point in the history
  • Loading branch information
doortts committed Mar 13, 2017
1 parent 890f3b5 commit 340e054
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/models/Issue.java
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ public static List<Issue> findByProject(Project project, String filter, int limi
if(StringUtils.isNotEmpty(filter)){
el.icontains("title", filter);
}
return el.setMaxRows(10).order().desc("createdDate").findList();
return el.setMaxRows(100).order().desc("createdDate").findList();
}

public static Page<Issue> findIssuesByState(int size, int pageNum, State state) {
Expand Down
10 changes: 10 additions & 0 deletions app/models/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -936,4 +936,14 @@ private void removeFavoriteOrganization(Long organizationId) {
list.get(0).delete();
}
}

public List<Project> getIssueMovableProject(){
Set<Project> projects = new LinkedHashSet<>();
projects.addAll(getFavoriteProjects());
projects.addAll(getVisitedProjects());
projects.addAll(Project.findProjectsByMember(id));
List<Project> list = new ArrayList<>();
list.addAll(projects);
return list;
}
}
10 changes: 6 additions & 4 deletions app/views/issue/partial_select_subtask.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,22 @@
<div class="span3">
<select id="targetProjectId" name="targetProjectId" data-format="projects" data-placeholder="@Messages("organization.choose.projects")" data-toggle="select2" data-container-css-class="fullsize" @if(!showOption){disabled}>
<option value="@project.id" data-avatar-url="@urlToProjectLogo(project)">@project.name</option>
@for(project <- UserApp.currentUser().myProjects("")) {
<option value="@project.id" data-avatar-url="@urlToProjectLogo(project)">@project.name</option>
@for(movableProject <- UserApp.currentUser().getIssueMovableProject) {
@if(movableProject.id != project.id) {
<option value="@movableProject.id" data-avatar-url="@urlToProjectLogo(movableProject)">@movableProject.name</option>
}
}
</select>
</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> -- select a parent issue -- </option>
<option value="" selected>@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)) {
@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>
}
</select>
Expand Down
1 change: 1 addition & 0 deletions conf/messages
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ issue.noAuthor = No author
issue.noMilestone = No milestone
issue.noDuedate = No due date
issue.search = SEARCH
issue.subtask.select = -- If you want to make a sub-issue, choose parent issue --
issue.state = Status
issue.state.all = All
issue.state.assigned = Assigned
Expand Down
1 change: 1 addition & 0 deletions conf/messages.ko-KR
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ issue.noAuthor = 작성자 없음
issue.noMilestone = 마일스톤 없음
issue.noDuedate = 목표 완료일 없음
issue.search = 검색
issue.subtask.select = -- 서브 이슈로 만들고 싶으면 부모 이슈를 선택하세요 --
issue.state = 상태
issue.state.all = 전체
issue.state.assigned = 할당됨
Expand Down
15 changes: 15 additions & 0 deletions public/javascripts/common/yona.Subtask.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,19 @@ $(function () {
this.disabled = !this.disabled;
});
});

var initialProject = $("#targetProjectId");
var initialProjectId = initialProject.val();
initialProject.on("change", function(){
var parentId = $("#parentId");
console.log("$(this).val()", $(this).val());
if($(this).val() === initialProjectId){
parentId.prop("disabled", false);
parentId.trigger('change.select2');
} else {
parentId.val(parentId.find("option:first").val());
parentId.prop("disabled", true);
parentId.trigger('change.select2');
}
});
});

0 comments on commit 340e054

Please sign in to comment.