@(state: String, milestones: List[(gitbucket.core.model.Milestone, Int, Int)], repository: gitbucket.core.service.RepositoryService.RepositoryInfo, hasWritePermission: Boolean)(implicit context: gitbucket.core.controller.Context) @import context._ @import gitbucket.core.view.helpers._ @html.main(s"Milestones - ${repository.owner}/${repository.name}"){ @html.menu("issues", repository){ @issues.html.navigation("milestones", hasWritePermission, repository)

@milestones.count(_._1.closedDate.isEmpty) Open @milestones.count(_._1.closedDate.isDefined) Closed
@defining(milestones.filter { case (milestone, _, _) => milestone.closedDate.map(_ => state == "closed").getOrElse(state == "open") }){ milestones => @milestones.map { case (milestone, openCount, closedCount) =>

@milestone.title
@if(milestone.closedDate.isDefined){ Closed @helper.html.datetimeago(milestone.closedDate.get) } else { @milestone.dueDate.map { dueDate => @if(isPast(dueDate)){ Due by @date(dueDate) } else { Due by @date(dueDate) } }.getOrElse { No due date } }
@progress(openCount + closedCount, closedCount)
@if(closedCount == 0){ 0% } else { @((closedCount.toDouble / (openCount + closedCount).toDouble * 100).toInt)% } complete @openCount open @closedCount closed
@if(milestone.description.isDefined){
@markdown(milestone.description.get, repository, false, false)
}

} @if(milestones.isEmpty){
No milestones to show. @if(hasWritePermission){ Create a new milestone. }
} }

} }