Skip to content

Commit

Permalink
subtask: Support basic subtask feature
Browse files Browse the repository at this point in the history
  • Loading branch information
doortts committed Mar 13, 2017
1 parent e189670 commit caf0ee1
Show file tree
Hide file tree
Showing 18 changed files with 394 additions and 123 deletions.
2 changes: 2 additions & 0 deletions app/assets/stylesheets/less/_common.less
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ input[type=number]::-webkit-outer-spin-button {
filter:none;
&.orange { background:@orange; .box-shadow(none); } // #f28149
&.blue { background:@blue; .box-shadow(none); }
&.grey { background:@gray-9e; .box-shadow(none); }
&.done { background:@light-green; .box-shadow(none); }
&.open { background:@state-open; .box-shadow(none); }
&.closed { background:@state-closed; .box-shadow(none); }
}
Expand Down
140 changes: 102 additions & 38 deletions app/assets/stylesheets/less/_page.less
Original file line number Diff line number Diff line change
Expand Up @@ -2134,43 +2134,7 @@ label.inline-list {
background: #fd6956 !important;
}

.state-label {
font-size: 13px;
padding: 5px 0 3px;
display: inline-block;
min-width: 13px;
color: white;
border-radius: 5px;
text-align: center;
line-height: 14px;
margin-right: 3px;

&.open {
color: white;
}
&.closed {
color: #2196F3;
}
}

.issue-item {
font-size: 16px;
padding: 3px;
.item-name {
background-color: white;
vertical-align: middle;
}
.number {
font-family: menlo, Consolas, monospace, sans-serif;
font-size: 12px;
color: gray;
min-width: 35px;
padding-right: 5px;
display: inline-block;
text-align: right;
margin-right: 3px;
}
}
#simple-issue-list;

.infos {
width: 100%; /*700px*; /*660px;*/
Expand Down Expand Up @@ -3450,7 +3414,9 @@ div.markdown-preview {
.title {
margin-bottom: 15px;
font-size:18px;

border: none;
border-bottom: 1px solid #ddd;
border-radius: 0 !important;
}
.error {
margin-bottom: 5px;
Expand Down Expand Up @@ -6658,3 +6624,101 @@ div.diff-body[data-outdated="true"] tr:hover .icon-comment {
color: darkviolet;
font-weight: bold;
}

.width16px {
width: 16px;
display: inline-block;
}

#simple-issue-list {
.state-label {
font-size: 13px;
padding: 5px 0 3px;
display: inline-block;
min-width: 13px;
color: white;
border-radius: 5px;
text-align: center;
line-height: 14px;
margin-right: 3px;

&.open {
color: white;
}
&.closed {
color: #fd6956;
}
}

.issue-item {
font-size: 16px;
padding: 3px;
.item-name {
background-color: white;
vertical-align: middle;
}
.number {
font-family: menlo, Consolas, monospace, sans-serif;
font-size: 12px;
color: gray;
min-width: 35px;
padding-right: 5px;
display: inline-block;
text-align: right;
margin-right: 3px;
}
}
}

.subtasks {
#simple-issue-list;
margin-bottom: 15px;
}

.subtask {
a {
border: 1px solid;
padding: 0 2px;
&:hover {
color: #51aacc;
text-decoration: none;
}
}
color: #9e9e9e;
}

.infos, .parent-issue {
.upload-progress {
display: inline-block;
width: 30px;
vertical-align: middle;
overflow: hidden;
margin-top: 3px;
box-shadow: none;
}
.completion-ratio {
margin-right: 3px;
}
.open {
background-color: #8BC34A;
}
.closed {
background-color: #f68c52;
}
.parent-issue-state {
border-radius: 0;
color: white;
padding: 2px;
font-size: 12px;
line-height: 17px;
vertical-align: text-bottom;
}
}

.txt-orange {
color: #f68c52;
}

.txt-green {
color: @light-green;
}
4 changes: 4 additions & 0 deletions app/assets/stylesheets/less/_variables.less
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@
@low-white: #efefef;
@black : #000;
@orange : #F36C22;
@orangeLighter : #f68c52;
@purple : #8d008d;
@blue : #5DBBE0;
@blue2 : #51AACC;
@darkgray: #878787;
@green: #007fca;
@light-green: #8bc34a;
@light-cyan: #00BCD4;
@darkmagenta: #8B008B;

@gray-d4: #D4D4D4;
Expand All @@ -42,6 +45,7 @@
@gray-52: #5D5D5D;
@gray-f2: #F2F2F2;
@gray-d9: #D9D9D9;
@gray-9e: #9E9E9E;

// new color scheme

Expand Down
15 changes: 15 additions & 0 deletions app/controllers/IssueApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,9 @@ public static Result newIssue(String ownerName, String projectName) {
ErrorViews.RequestTextEntityTooLarge.render());
}

if(StringUtils.isNotEmpty(newIssue.parentIssueId)){
newIssue.parent = Issue.finder.byId(Long.valueOf(newIssue.parentIssueId));
}
newIssue.createdDate = JodaDateUtil.now();
newIssue.updatedDate = JodaDateUtil.now();
newIssue.setAuthor(UserApp.currentUser());
Expand Down Expand Up @@ -511,6 +514,7 @@ public static Result editIssue(String ownerName, String projectName, Long number
Project project = Project.findByOwnerAndProjectName(ownerName, projectName);

if (issueForm.hasErrors()) {
flash(Constants.WARNING, issueForm.error("name").message());
return badRequest(edit.render("error.validation", issueForm, Issue.findByNumber(project, number), project));
}

Expand All @@ -521,6 +525,7 @@ public static Result editIssue(String ownerName, String projectName, Long number
issue.dueDate = JodaDateUtil.lastSecondOfDay(issue.dueDate);

final Issue originalIssue = Issue.findByNumber(project, number);
updateSubtaskRelation(issue, originalIssue);

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

Expand All @@ -547,6 +552,16 @@ public void run() {
return editPosting(originalIssue, issue, issueForm, redirectTo, preUpdateHook);
}

private static void updateSubtaskRelation(Issue issue, Issue originalIssue) {
if(StringUtils.isEmpty(issue.parentIssueId)){
issue.parent = null;
} else {
issue.parent = Issue.finder.byId(Long.valueOf(issue.parentIssueId));
}
originalIssue.parent = issue.parent;
originalIssue.update();
}

private static void setAssignee(Form<Issue> issueForm, Issue issue, Project project) {
String value = issueForm.field("assignee.user.id").value();
if (value != null) {
Expand Down
50 changes: 50 additions & 0 deletions app/models/Issue.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package models;

import com.avaje.ebean.Ebean;
import com.avaje.ebean.ExpressionList;
import com.avaje.ebean.Page;
import com.avaje.ebean.annotation.Formula;
import controllers.routes;
Expand Down Expand Up @@ -94,6 +95,12 @@ public Issue(Project project, User author, String title, String body) {
this.state = State.OPEN;
}

@Transient
public String parentIssueId;

@OneToOne
public Issue parent;

public Issue() {
super();
}
Expand Down Expand Up @@ -421,6 +428,24 @@ public static List<Issue> findRecentlyOpendIssuesByDaysAgo(Project project, int
.ge("createdDate", JodaDateUtil.before(days)).order().desc("createdDate").findList();
}

public static List<Issue> findByProject(Project project, String filter) {
ExpressionList<Issue> el = finder.where()
.eq("project.id", project.id);
if(StringUtils.isNotEmpty(filter)){
el.icontains("title", filter);
}
return el.order().desc("createdDate").findList();
}

public static List<Issue> findByProject(Project project, String filter, int limit) {
ExpressionList<Issue> el = finder.where()
.eq("project.id", project.id);
if(StringUtils.isNotEmpty(filter)){
el.icontains("title", filter);
}
return el.setMaxRows(10).order().desc("createdDate").findList();
}

public static Page<Issue> findIssuesByState(int size, int pageNum, State state) {
return finder.where().eq("state", state)
.order().desc("createdDate")
Expand Down Expand Up @@ -581,6 +606,31 @@ public static int countOpenIssuesByMilestone(Project project, Milestone mileston
.findRowCount();
}

public static List<Issue> findByParentIssueId(Long parentIssueId){
return finder.where()
.eq("parent.id", parentIssueId)
.findList();
}

public boolean hasChildIssue(){
List<Issue> issues = finder.where()
.eq("parent.id", this.id)
.setFirstRow(1)
.setMaxRows(1).findList();
return issues.size() > 0;
}

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

public static int countByParentIssueIdAndState(Long parentIssueId, State state){
return finder.where()
.eq("parent.id", parentIssueId)
.eq("state", state)
.findRowCount();
}
}
3 changes: 3 additions & 0 deletions app/models/Posting.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ public int computeNumOfComments() {
return comments.size();
}

@OneToOne
public Posting parent;

public Posting() {
super();
}
Expand Down
24 changes: 5 additions & 19 deletions app/models/User.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
/**
* Yobi, Project Hosting SW
*
* Copyright 2012 NAVER Corp.
* http://yobi.io
*
* @author Ahn Hyeok Jun
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Yona, 21st Century Project Hosting SW
* <p>
* Copyright Yona & Yobi Authors & NAVER Corp.
* https://yona.io
**/
package models;

import com.avaje.ebean.*;
Expand Down
9 changes: 7 additions & 2 deletions app/views/common/select2.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,14 @@
</div>
</script>
<script id="tplSelect2ProjectsWithoutAvatar" type="text/x-jquery-tmpl">
<div class="usf-group" title="${name}>
<span class="avatar-wrap smaller"> </span>
<div class="usf-group" title="${name}">
<span class="width16px"></span>
<span class="name">${name}</span>
</div>
</script>

<script id="tplSelect2FormatIssues" type="text/x-jquery-tmpl">
<div title="${name}">
${name}
</div>
</script>
Loading

0 comments on commit caf0ee1

Please sign in to comment.