@import helper._
@(projects: Seq[ReportInfo], watchedProjects: Set[String], failedReports: Set[String], filter: Option[String])(implicit req: DefaultRequest, mainTemplateData: MainTemplateData)
@button(action: Call)(label: String) = {
@form(action, 'style -> "display: inline-block"){
@CSRF.formField
}
}
@toggleButton(id: String, buttonClass: String, labelClass: String) = {
}
@projectListItem(project: ReportInfo, subprojects: Seq[ReportInfo])(children: Html) = {
@for(
isWatchedDirectly <- Some(watchedProjects contains project.fullId); // hack allowing one to define a variable
isWatchedByParent = project.isNotBare && (watchedProjects contains project.bare.fullId);
isFailed = failedReports contains project.fullId; // actually fullId should be equal bare id in such cases
watchedChildCount = subprojects.count(p => watchedProjects contains p.fullId);
hasWatchedChild = watchedChildCount > 0;
hasButtons = !subprojects.isEmpty;
classes = Seq(
if(isWatchedDirectly) Some("watched") else None,
if(hasWatchedChild && !isWatchedDirectly) None else Some("collapsed"),
if(hasButtons) Some("with-buttons") else None
).flatten;
id = s"project-${urlEncode(project.fullId)}"
){
@if(hasButtons) {
@toggleButton(id, buttonClass = "watching-btn-expand", labelClass = "glyphicon-plus-sign")
@toggleButton(id, buttonClass = "watching-btn-collapse", labelClass = "glyphicon-minus-sign")
}
@friendlyProjectName(project)
@if(isFailed){
(!)
}
@if(project.isBare){
@if(isWatchedDirectly){
You watch this project with all subprojects.
}else{
@if(hasWatchedChild){
You watch @watchedChildCount @if(watchedChildCount==1){subproject}else{subprojects}.
}
}
}else{@* non-bare *@
@if(isWatchedDirectly && !isWatchedByParent){
You explicitly watch this project.
}
}
@if(isWatchedByParent) {
You watch the parent project.
}else{
@if(isWatchedDirectly){
@button(routes.Notifications.unwatch(project.fullId, filter))("unwatch")
}else{
@button(routes.Notifications.watch(project.fullId, filter))("watch")
}
}
@children
}
}
@headExtension = {
}
@main("Watch projects", headExtension = headExtension){
@for(
(projectGroup, projectsInGroup) <- projects.groupBy(_.bare).toIndexedSeq.sortBy(x => friendlyProjectNameString(x._1).toLowerCase)
){
@projectListItem(projectGroup, projectsInGroup) {
@for(
project <- projectsInGroup;
if project.isNotBare
) {
@projectListItem(project, Seq()){ }
}
}
}
}