From 38ca9b353869b00a524a99af164bb8b3a83e091b Mon Sep 17 00:00:00 2001 From: Cristian Douce Date: Thu, 10 Oct 2013 23:57:36 -0300 Subject: [PATCH] [proposal-options] - Show/hide results and vote-box in different situations. #34 --- lib/proposal-options/options.jade | 63 +++++++++++++++++-------------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/lib/proposal-options/options.jade b/lib/proposal-options/options.jade index 7606369dd8..338f7d84cb 100644 --- a/lib/proposal-options/options.jade +++ b/lib/proposal-options/options.jade @@ -14,11 +14,13 @@ - && proposal.abstentions.map(function(v) { return v.author }) ) - || [] +- var participants = proposal.participants + +- var closed = proposal.closingAt && +proposal.closingAt < Date.now() - var voted = locals.citizen && ~census.indexOf(citizen.id) -- var showOptions = !!citizen.id -.proposal-options(class= showOptions ? '' : 'hide') - .vote-box +.proposal-options + .vote-box(class= !!citizen.id ? '' : 'hide') .meta-data - if(~positives.indexOf(citizen.id)) p.alert.alert-success(style="margin:0;") #{t('You voted Yea')}. @@ -26,10 +28,10 @@ p.alert.alert-danger(style="margin:0;") #{t('You voted Nay')}. - else if (~neutrals.indexOf(citizen.id)) p.alert.alert-info(style="margin:0;") #{t('You abstained from voting')}. - a.meta-item.change-vote(href="#", class= voted ? '' : 'hide') + a.meta-item.change-vote(href="#", class= voted && !closed ? '' : 'hide') small #{t('I want to change my vote')}. - .vote-options(class= voted ? 'hide' : '') + .vote-options(class= voted || closed ? 'hide' : '') h5= t('Vote') .direct-vote a.vote-option.vote-yes(href="#", data-proposal=proposal.id) @@ -49,29 +51,34 @@ //- label= t('Delegate to') //- input.delegation-input(type="text", name="q") - a.toggle-results.btn.btn-default.btn-block.btn-success(class= voted ? '' : 'hide') + .votes-cast + em.text-muted= t('{num} votes cast', { num: census.length }) + + + a.toggle-results.btn.btn-default.btn-block.btn-success(class= closed ? '' : 'hide') span.glyphicon.glyphicon-stats | #{t('Partial results')} - .results-box(class='hide') - h5= t('Yea') - - var width = census.length ? (positives.length/census.length)*100 : 0; - .progress - .progress-bar.progress-bar-success(role="progress-bar", aria-valuenow=positives.length, aria-valuemin="0", aria-valuemax=census.length, style="width: #{width}%;") - span.sr-only - | #{positives.length} - | #{t('votes')} - h5= t('Nay') - - var width = census.length ? (negatives.length/census.length)*100 : 0; - .progress - .progress-bar.progress-bar-danger(role="progress-bar", aria-valuenow=negatives.length, aria-valuemin="0", aria-valuemax=census.length, style="width: #{width}%;") - span.sr-only - | #{negatives.length} - | #{t('votes')} - h5= t('Abstain') - - var width = census.length ? (neutrals.length/census.length)*100 : 0; - .progress - .progress-bar.progress-bar-info(role="progress-bar", aria-valuenow=neutrals.length, aria-valuemin="0", aria-valuemax=census.length, style="width: #{width}%;") - span.sr-only - | #{neutrals.length} - | #{t('votes')} + - if (closed) + .results-box(class='hide') + h5= t('Yea') + - var width = census.length ? (positives.length/census.length)*100 : 0; + .progress + .progress-bar.progress-bar-success(role="progress-bar", aria-valuenow=positives.length, aria-valuemin="0", aria-valuemax=census.length, style="width: #{width}%;") + span.sr-only + | #{positives.length} + | #{t('votes')} + h5= t('Nay') + - var width = census.length ? (negatives.length/census.length)*100 : 0; + .progress + .progress-bar.progress-bar-danger(role="progress-bar", aria-valuenow=negatives.length, aria-valuemin="0", aria-valuemax=census.length, style="width: #{width}%;") + span.sr-only + | #{negatives.length} + | #{t('votes')} + h5= t('Abstain') + - var width = census.length ? (neutrals.length/census.length)*100 : 0; + .progress + .progress-bar.progress-bar-info(role="progress-bar", aria-valuenow=neutrals.length, aria-valuemin="0", aria-valuemax=census.length, style="width: #{width}%;") + span.sr-only + | #{neutrals.length} + | #{t('votes')} \ No newline at end of file