143 } else { |
143 } else { |
144 san |
144 san |
145 } |
145 } |
146 } |
146 } |
147 |
147 |
|
148 private fun feedPath(project: Project) = "feed/${project.node}/issues.rss" |
|
149 |
148 data class PathInfos( |
150 data class PathInfos( |
149 val projectInfo: ProjectInfo, |
151 val projectInfo: ProjectInfo, |
150 val version: Version?, |
152 val version: Version?, |
151 val component: Component? |
153 val component: Component? |
152 ) { |
154 ) { |
153 val issuesHref by lazyOf("projects/${projectInfo.project.node}/issues/${version?.node ?: "-"}/${component?.node ?: "-"}/") |
155 val project = projectInfo.project |
|
156 val issuesHref by lazyOf("projects/${project.node}/issues/${version?.node ?: "-"}/${component?.node ?: "-"}/") |
154 } |
157 } |
155 |
158 |
156 private fun withPathInfo(http: HttpRequest, dao: DataAccessObject): PathInfos? { |
159 private fun withPathInfo(http: HttpRequest, dao: DataAccessObject): PathInfos? { |
157 val projectInfo = obtainProjectInfo(http, dao) |
160 val projectInfo = obtainProjectInfo(http, dao) |
158 if (projectInfo == null) { |
161 if (projectInfo == null) { |
184 |
187 |
185 private fun project(http: HttpRequest, dao: DataAccessObject) { |
188 private fun project(http: HttpRequest, dao: DataAccessObject) { |
186 withPathInfo(http, dao)?.run { |
189 withPathInfo(http, dao)?.run { |
187 |
190 |
188 val issues = dao.listIssues(IssueFilter( |
191 val issues = dao.listIssues(IssueFilter( |
189 project = SpecificFilter(projectInfo.project), |
192 project = SpecificFilter(project), |
190 version = version?.let { SpecificFilter(it) } ?: AllFilter(), |
193 version = version?.let { SpecificFilter(it) } ?: AllFilter(), |
191 component = component?.let { SpecificFilter(it) } ?: AllFilter() |
194 component = component?.let { SpecificFilter(it) } ?: AllFilter() |
192 )).sortedWith(DEFAULT_ISSUE_SORTER) |
195 )).sortedWith(DEFAULT_ISSUE_SORTER) |
193 |
196 |
194 with(http) { |
197 with(http) { |
195 view = ProjectDetails(projectInfo, issues, version, component) |
198 view = ProjectDetails(projectInfo, issues, version, component) |
|
199 feedPath = feedPath(project) |
196 navigationMenu = activeProjectNavMenu( |
200 navigationMenu = activeProjectNavMenu( |
197 dao.listProjects(), |
201 dao.listProjects(), |
198 projectInfo, |
202 projectInfo, |
199 version, |
203 version, |
200 component |
204 component |
424 } |
432 } |
425 |
433 |
426 val comments = dao.listComments(issue) |
434 val comments = dao.listComments(issue) |
427 |
435 |
428 with(http) { |
436 with(http) { |
429 view = IssueDetailView(issue, comments, projectInfo.project, version, component) |
437 view = IssueDetailView(issue, comments, project, version, component) |
|
438 // TODO: feed path for this particular issue |
|
439 feedPath = feedPath(projectInfo.project) |
430 navigationMenu = activeProjectNavMenu( |
440 navigationMenu = activeProjectNavMenu( |
431 dao.listProjects(), |
441 dao.listProjects(), |
432 projectInfo, |
442 projectInfo, |
433 version, |
443 version, |
434 component |
444 component |
441 |
451 |
442 private fun issueForm(http: HttpRequest, dao: DataAccessObject) { |
452 private fun issueForm(http: HttpRequest, dao: DataAccessObject) { |
443 withPathInfo(http, dao)?.run { |
453 withPathInfo(http, dao)?.run { |
444 val issue = dao.findIssue(http.pathParams["issue"]?.toIntOrNull() ?: -1) ?: Issue( |
454 val issue = dao.findIssue(http.pathParams["issue"]?.toIntOrNull() ?: -1) ?: Issue( |
445 -1, |
455 -1, |
446 projectInfo.project, |
456 project, |
447 ) |
457 ) |
448 |
458 |
449 // pre-select component, if available in the path info |
459 // pre-select component, if available in the path info |
450 issue.component = component |
460 issue.component = component |
451 |
461 |
462 view = IssueEditView( |
472 view = IssueEditView( |
463 issue, |
473 issue, |
464 projectInfo.versions, |
474 projectInfo.versions, |
465 projectInfo.components, |
475 projectInfo.components, |
466 dao.listUsers(), |
476 dao.listUsers(), |
467 projectInfo.project, |
477 project, |
468 version, |
478 version, |
469 component |
479 component |
470 ) |
480 ) |
|
481 feedPath = feedPath(projectInfo.project) |
471 navigationMenu = activeProjectNavMenu( |
482 navigationMenu = activeProjectNavMenu( |
472 dao.listProjects(), |
483 dao.listProjects(), |
473 projectInfo, |
484 projectInfo, |
474 version, |
485 version, |
475 component |
486 component |
503 private fun issueCommit(http: HttpRequest, dao: DataAccessObject) { |
514 private fun issueCommit(http: HttpRequest, dao: DataAccessObject) { |
504 withPathInfo(http, dao)?.run { |
515 withPathInfo(http, dao)?.run { |
505 // TODO: throw validator exception instead of using defaults |
516 // TODO: throw validator exception instead of using defaults |
506 val issue = Issue( |
517 val issue = Issue( |
507 http.param("id")?.toIntOrNull() ?: -1, |
518 http.param("id")?.toIntOrNull() ?: -1, |
508 projectInfo.project |
519 project |
509 ).apply { |
520 ).apply { |
510 component = dao.findComponent(http.param("component")?.toIntOrNull() ?: -1) |
521 component = dao.findComponent(http.param("component")?.toIntOrNull() ?: -1) |
511 category = IssueCategory.valueOf(http.param("category") ?: "") |
522 category = IssueCategory.valueOf(http.param("category") ?: "") |
512 status = IssueStatus.valueOf(http.param("status") ?: "") |
523 status = IssueStatus.valueOf(http.param("status") ?: "") |
513 subject = http.param("subject") ?: "" |
524 subject = http.param("subject") ?: "" |
520 } |
531 } |
521 } |
532 } |
522 eta = http.param("eta")?.let { if (it.isBlank()) null else Date.valueOf(it) } |
533 eta = http.param("eta")?.let { if (it.isBlank()) null else Date.valueOf(it) } |
523 |
534 |
524 affectedVersions = http.paramArray("affected") |
535 affectedVersions = http.paramArray("affected") |
525 .mapNotNull { param -> param.toIntOrNull()?.let { Version(it, projectInfo.project.id) } } |
536 .mapNotNull { param -> param.toIntOrNull()?.let { Version(it, project.id) } } |
526 resolvedVersions = http.paramArray("resolved") |
537 resolvedVersions = http.paramArray("resolved") |
527 .mapNotNull { param -> param.toIntOrNull()?.let { Version(it, projectInfo.project.id) } } |
538 .mapNotNull { param -> param.toIntOrNull()?.let { Version(it, project.id) } } |
528 } |
539 } |
529 |
540 |
530 val openId = if (issue.id < 0) { |
541 val openId = if (issue.id < 0) { |
531 dao.insertIssue(issue) |
542 dao.insertIssue(issue) |
532 } else { |
543 } else { |