views/books/shortlist-results.pug
//- vim:ft=jade
extends ../skeleton
block title
title #{__('shortlist-results')}
block breadcrumb
li
a(href=__('/book-club')) #{__('book-club')}
li
a(href=__('/book-club/short-list')) #{__('shortlist-results')}
block content
- electorCount = Object.keys(electorate).length
- max = books.length * electorCount
- unanimousBooks = 0
.grid-row
.column-full
h1.heading-xlarge #{__('shortlist-results')}
.grid-row
.column-two-thirds
table
thead
tr
th(colspan="3") #{__('shortlist-flags')}
th #{__('shortlist-candidate')}
th.numeric #{__('shortlist-approvals')}
th.numeric
abbr(title=__('shortlist-sav')) #{__('shortlist-sav-abbr')}
if results.length == 0
tr
td(colspan="7",style="text-align:center")
if state.allowVoting
span #{__('shortlist-waiting')}
else
span #{__('shortlist-waiting-notyetopen')}
for result in results
tr
if result.readingList
td(colspan="3").center.green #{__('shortlist-selected', {'note': result.readingList})}
else
td
if result.longlistedBy === req.user
abbr.green(title=__('shortlist-flag-longlisted')) ✎
td
if result.difficult
abbr.red(title=__('shortlist-flag-difficult')) D
td
if result.status
abbr.read(title=__('shortlist-flag-hasreadingstatus')) 📕
else if result.alreadyRead && result.alreadyRead.length > 0
abbr.read(title=__('shortlist-flag-alreadyread')) 📖
td
strong
if result.isbn
a(href='/book-club/book/' + result.isbn) #{result.title}
else
span #{result.title}
br
span #{result.author}
if result.approve.length === electorCount
- unanimousBooks++
td.numeric(title=__('shortlist-approvals-allapproved')).unanimous #{result.approve.length}
else
if result.approve.length > 0 && result.disapprove.length === 0
td.numeric(title=__('shortlist-approvals-nodownvotes')).almost-unanimous #{result.approve.length}
else
if (result.approve.length + result.disapprove.length) < electorCount
if result.approve.length == 0
td.numeric(title=__('shortlist-approvals-incomplete')).incomplete #{__('shortlist-approvals-nil')}
else
td.numeric(title=__('shortlist-approvals-incomplete')).incomplete #{result.approve.length}
else
if result.approve.length === 0
td.numeric #{__('shortlist-approvals-nil')}
else
td.numeric(title=__('shortlist-approvals-approvedby', {voters: result.approve.join(__('shortlist-approvals-approvedby-join'))})) #{result.approve.length}
- sav = (result.scaledSav/100*Object.keys(electorate).length).toFixed(2)
if sav === '0.00'
td.numeric #{__('shortlist-approvals-nil')}
else
td.numeric(title=__('shortlist-sav-title', {sav: result.scaledSav})) #{sav}
.column-one-third
table
thead
tr
th #{__('shortlist-person-elector')}
th.numeric #{__('shortlist-person-votes')}
th.numeric
abbr(title=__('shortlist-person-approval-percent')) #{__('shortlist-person-approval-percent-abbr')}
- sum = 0
for elector in Object.keys(electorate)
- sum += electorate[elector].total
tr
td #{elector}
if electorate[elector].total == 0
td.numeric #{__('shortlist-person-nil')}
else
if electorate[elector].total == books.length
td.numeric #{__('shortlist-person-complete')}
else if electorate[elector].total > books.length
td.numeric.red #{__('shortlist-person-progress-overrun', {'count': electorate[elector].total, 'total': books.length})}
else
td.numeric #{__('shortlist-person-progress', {'count': electorate[elector].total, 'total': books.length})}
td.numeric(title=__('shortlist-person-approval-count', {'count':electorate[elector].approve})).
#{__('shortlist-person-approval-percent-cell', {'percent': Math.round((electorate[elector].approve/electorate[elector].total)*100)})}
p #{__('shortlist-progress', {sum, max})}
if sum < max
hr
p.notice
i.icon.icon-important
strong #{__('shortlist-results-warning')}
hr
else
p
.data
span.data-item.bold-xlarge #{unanimousBooks}
span.data-item.bold-xsmall #{__('shortlist-stat-unanimous')}
p #{__('shortlist-results-spiel-approval')}
hr
p #{__('shortlist-results-spiel-sav')}
p #{__('shortlist-results-spiel-sav-weighting', {min: 0, max: Object.keys(electorate).length})}
hr
if state.allowVoting
if sum !== max
p #{__('shortlist-polls-incomplete')}
else
p #{__('shortlist-polls-completebutopen')}
else
p #{__('shortlist-polls-closed')}
.grid-row
.column-full