
Fix Label bugs.
@b687eb5c13828a939428b5803d11f50cdfbadea1
--- app/controllers/IssueLabelApp.java
+++ app/controllers/IssueLabelApp.java
... | ... | @@ -261,7 +261,14 @@ |
261 | 261 |
} |
262 | 262 |
|
263 | 263 |
IssueLabel label = IssueLabel.finder.byId(id); |
264 |
+ IssueLabelCategory category = label.category; |
|
264 | 265 |
label.delete(); |
266 |
+ |
|
267 |
+ long labelCategoryRemainCount = IssueLabel.findByProject(label.project).stream().filter(lb -> lb.category.equals(category)).count(); |
|
268 |
+ if (labelCategoryRemainCount == 0) { |
|
269 |
+ category.delete(); |
|
270 |
+ } |
|
271 |
+ |
|
265 | 272 |
return ok(); |
266 | 273 |
} |
267 | 274 |
|
... | ... | @@ -390,6 +397,12 @@ |
390 | 397 |
} |
391 | 398 |
|
392 | 399 |
IssueLabelCategory category = form.get(); |
400 |
+ |
|
401 |
+ if (IssueLabelCategory.findByProject(category.project).stream() |
|
402 |
+ .filter(lc -> lc.name.equals(category.name) && !lc.id.equals(category.id)).count() > 0) { |
|
403 |
+ return badRequest(form.errorsAsJson()); |
|
404 |
+ } |
|
405 |
+ |
|
393 | 406 |
category.id = id; |
394 | 407 |
category.project = |
395 | 408 |
Project.findByOwnerAndProjectName(ownerName, projectName); |
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?