
label function refactoring
Duplicated code is converted to method. Wrong javadoc is fixed. Dead url in comment is fixed.
@4db84d85828a1e60bdd0806676647ded8544a7c5
--- app/controllers/LabelApp.java
+++ app/controllers/LabelApp.java
... | ... | @@ -56,6 +56,7 @@ |
56 | 56 |
* 엔터티 본문의 미디어 타입은 언제나 {@code application/json}이기 때문이다. |
57 | 57 |
* |
58 | 58 |
* @param query 태그에 대한 검색어 질의 |
59 |
+ * @param category a group of label to search |
|
59 | 60 |
* @param limit 가져올 태그의 최대 갯수 |
60 | 61 |
* @return 태그 목록 요청에 대한 응답 |
61 | 62 |
* @see <a href="https://github.com/nforge/yobi/blob/master/docs/technical/label-typeahead |
--- app/controllers/ProjectApp.java
+++ app/controllers/ProjectApp.java
... | ... | @@ -1091,7 +1091,6 @@ |
1091 | 1091 |
* 공개여부가 @{code state} 인 프로젝트 목록을 최근생성일로 정렬하여 페이징 형태로 가져온다. |
1092 | 1092 |
* |
1093 | 1093 |
* @param query 검색질의(프로젝트명 / 관리자 아이디 / Overview) |
1094 |
- * @param state 프로젝트 상태(공개/비공개/전체) |
|
1095 | 1094 |
* @param pageNum 페이지번호 |
1096 | 1095 |
* @return 프로젝트명 또는 관리자 로그인 아이디가 {@code query}를 포함하고 공개여부가 @{code state} 인 프로젝트 목록 |
1097 | 1096 |
*/ |
... | ... | @@ -1116,7 +1115,6 @@ |
1116 | 1115 |
* JSON으로 변환하여 반환한다. |
1117 | 1116 |
* |
1118 | 1117 |
* @param query 검색질의(프로젝트명 / 관리자 / Overview) |
1119 |
- * @param state state 프로젝트 상태(공개/비공개/전체) |
|
1120 | 1118 |
* @return JSON 형태의 프로젝트 목록 |
1121 | 1119 |
*/ |
1122 | 1120 |
private static Result getProjectsToJSON(String query) { |
... | ... | @@ -1180,13 +1178,22 @@ |
1180 | 1178 |
|
1181 | 1179 |
Map<Long, Map<String, String>> labels = new HashMap<>(); |
1182 | 1180 |
for (Label label: project.labels) { |
1183 |
- Map<String, String> tagMap = new HashMap<>(); |
|
1184 |
- tagMap.put("category", label.category); |
|
1185 |
- tagMap.put("name", label.name); |
|
1186 |
- labels.put(label.id, tagMap); |
|
1181 |
+ labels.put(label.id, convertToMap(label)); |
|
1187 | 1182 |
} |
1188 | 1183 |
|
1189 | 1184 |
return ok(toJson(labels)); |
1185 |
+ } |
|
1186 |
+ |
|
1187 |
+ /** |
|
1188 |
+ * convert from some part of {@link models.Label} to {@link java.util.Map} |
|
1189 |
+ * @param label {@link models.Label} object |
|
1190 |
+ * @return label's map data |
|
1191 |
+ */ |
|
1192 |
+ private static Map<String, String> convertToMap(Label label) { |
|
1193 |
+ Map<String, String> tagMap = new HashMap<>(); |
|
1194 |
+ tagMap.put("category", label.category); |
|
1195 |
+ tagMap.put("name", label.name); |
|
1196 |
+ return tagMap; |
|
1190 | 1197 |
} |
1191 | 1198 |
|
1192 | 1199 |
/** |
... | ... | @@ -1240,14 +1247,11 @@ |
1240 | 1247 |
} |
1241 | 1248 |
|
1242 | 1249 |
if (isAttached) { |
1243 |
- // Return the attached label. The return type is Map<Long, String> |
|
1250 |
+ // Return the attached label. The return type is Map<Long, Map<String, String>> |
|
1244 | 1251 |
// even if there is only one label, to unify the return type with |
1245 | 1252 |
// ProjectApp.labels(). |
1246 | 1253 |
Map<Long, Map<String, String>> labels = new HashMap<>(); |
1247 |
- Map<String, String> labelMap = new HashMap<>(); |
|
1248 |
- labelMap.put("category", label.category); |
|
1249 |
- labelMap.put("name", label.name); |
|
1250 |
- labels.put(label.id, labelMap); |
|
1254 |
+ labels.put(label.id, convertToMap(label)); |
|
1251 | 1255 |
|
1252 | 1256 |
if (isCreated) { |
1253 | 1257 |
return created(toJson(labels)); |
--- public/bootstrap/js/bootstrap-better-typeahead.js
+++ public/bootstrap/js/bootstrap-better-typeahead.js
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 |
|
12 | 12 |
// ************************************************** |
13 | 13 |
// Yobi modifications by Yi EungJun |
14 |
-// http://github.github.com/nforge/yobi/ |
|
14 |
+// http://github.com/nforge/yobi/ |
|
15 | 15 |
// |
16 | 16 |
// Modifications are tagged with "yobi" |
17 | 17 |
// ************************************************** |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?