@import com.gu.contentatom.renderer.utils.GuardianDateFormatter
@import com.gu.contentatom.thrift.atom.commonsdivision.Mp
@import scala.collection.immutable.Map
@import com.gu.contentatom.renderer.ArticleConfiguration
@(atom: com.gu.contentatom.thrift.Atom
, data: com.gu.contentatom.thrift.atom.commonsdivision.CommonsDivision
)(implicit conf: ArticleConfiguration)
@partyClassName(name: String) = @{
val shortName = name match {
case "Conservative" => "tory"
case "Labour" => "labour"
case "Democratic Unionist Party" => "dup"
case "Liberal Democrat" => "libdem"
case "Green Party" => "green"
case "Plaid Cymru" => "plaid"
case "Scottish National Party" => "snp"
case _ => "default"
}
s"atom--commonsdivision__party-$shortName"
}
@partyDisplayName(name: String) = @{
name match {
case "Democratic Unionist Party" => "DUP"
case "Scottish National Party" => "SNP"
case "Liberal Democrat" => "Lib Dem"
case "Green Party" => "Green"
case other => other
}
}
@uniqueNames(a: Set[String], b: Set[String]) = @{ (a | b).toList.sorted }
@partiesTable(ayes: Map[String, Seq[Mp]], noes: Map[String, Seq[Mp]]) = {
@uniqueNames(ayes.keySet, noes.keySet).map { partyName =>
@if(conf.commonsdivisionConfiguration.showMps) {
|
@ayes.getOrElse(partyName, Nil).map { mp => - @mp.name
} |
@noes.getOrElse(partyName, Nil).map { mp => - @mp.name
} |
|
}
}
}
@for(title <- atom.title; description <- data.description) {
@{partiesTable(data.votes.ayes.toSeq.groupBy(_.party), data.votes.noes.toSeq.groupBy(_.party))}
}