Warn if attempting to under-vote
This commit is contained in:
parent
b62933629b
commit
f01b236554
@ -46,7 +46,9 @@
|
||||
}
|
||||
|
||||
function nextQuestion() {
|
||||
saveSelections();
|
||||
if (!saveSelections()) {
|
||||
return;
|
||||
}
|
||||
if (booth.questionNum == election.questions.__len__() - 1) {
|
||||
nextTemplate();
|
||||
} else {
|
||||
|
@ -18,7 +18,15 @@
|
||||
|
||||
<h2>{{ questionNum + 1 }}. {{ election.questions.__getitem__(questionNum).prompt }}</h2>
|
||||
|
||||
<p><small>Vote for between {{ election.questions.__getitem__(questionNum).min_choices }} and {{ election.questions.__getitem__(questionNum).max_choices }} choices. Click the check-boxes to the left of the choices to make your selection, then click the ‘Continue’ button. If you make a mistake, click the check-boxes again to clear your selection.</small></p>
|
||||
<p><small>
|
||||
Vote for
|
||||
{% if election.questions.__getitem__(questionNum).min_choices == election.questions.__getitem__(questionNum).max_choices %}
|
||||
exactly {{ election.questions.__getitem__(questionNum).min_choices }}
|
||||
{% else %}
|
||||
between {{ election.questions.__getitem__(questionNum).min_choices }} and {{ election.questions.__getitem__(questionNum).max_choices }}
|
||||
{% endif %}
|
||||
choices. Click the check-boxes to the left of the choices to make your selection, then click the ‘Continue’ button. If you make a mistake, click the check-boxes again to clear your selection.
|
||||
</small></p>
|
||||
|
||||
<div id="question-choices" class="ui form" style="margin-bottom: 1em;">
|
||||
<div class="grouped fields">
|
||||
@ -63,7 +71,16 @@
|
||||
$("#question-choices input:checked").each(function(i, el) {
|
||||
selections.push(parseInt(el.id.substring("question-choice-".length)));
|
||||
});
|
||||
|
||||
if (selections.length < election.questions.__getitem__(booth.questionNum).min_choices) {
|
||||
if (!window.confirm('You have selected fewer than the minimum required number of choices. If you proceed to cast this ballot, it will **NOT** be counted. If this was not your intention, please click the "Cancel" button below now, and correct your selections.')) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
answer = eosjs.eos.base.election.__all__.ApprovalAnswer(eosjs.__kwargtrans__({choices: selections}));
|
||||
booth.answers[booth.questionNum] = eosjs.eos.core.objects.__all__.EosObject.serialise_and_wrap(answer);
|
||||
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
|
@ -30,7 +30,11 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% if booth.answers[loop.index0].value.choices.length < question.max_choices %}
|
||||
{% if booth.answers[loop.index0].value.choices.length < question.min_choices %}
|
||||
<div class="ui error message">
|
||||
<p>You have selected fewer than the minimum required number of choices. If you proceed to cast this ballot, it will <span class="superem">not</span> be counted. If this was not your intention, please click the ‘Back’ button below now, and correct your selections.</p>
|
||||
</div>
|
||||
{% elif booth.answers[loop.index0].value.choices.length < question.max_choices %}
|
||||
<div class="ui warning message">
|
||||
<p>You have selected fewer than the maximum allowed number of choices. If this was not your intention, please click the ‘Back’ button below now, and correct your selections.</p>
|
||||
</div>
|
||||
|
@ -18,7 +18,15 @@
|
||||
|
||||
<h2>{{ questionNum + 1 }}. {{ election.questions.__getitem__(questionNum).prompt }}</h2>
|
||||
|
||||
<p><small>Vote for between {{ election.questions.__getitem__(questionNum).min_choices }} and {{ election.questions.__getitem__(questionNum).max_choices }} choices. Click and drag the choices from the grey box to the blue box in order from most-preferred to least-preferred. It is in your best interests to vote for as many choices as you can.</small></p>
|
||||
<p><small>
|
||||
Vote for
|
||||
{% if election.questions.__getitem__(questionNum).min_choices == election.questions.__getitem__(questionNum).max_choices %}
|
||||
exactly {{ election.questions.__getitem__(questionNum).min_choices }}
|
||||
{% else %}
|
||||
between {{ election.questions.__getitem__(questionNum).min_choices }} and {{ election.questions.__getitem__(questionNum).max_choices }}
|
||||
{% endif %}
|
||||
choices. Click and drag the choices from the grey box to the blue box in order from most-preferred to least-preferred. It is in your best interests to vote for as many choices as you can.
|
||||
</small></p>
|
||||
|
||||
<div id="question-choices-selected" class="preferential-choices">
|
||||
<div style="color: #3465a4;">Options voted for:</div>
|
||||
@ -160,9 +168,18 @@
|
||||
$("#question-choices-selected .preferential-choice:not(.ticket)").each(function(i, el) {
|
||||
selections.push(parseInt(el.dataset.choiceno));
|
||||
});
|
||||
|
||||
if (selections.length < election.questions.__getitem__(booth.questionNum).min_choices) {
|
||||
if (!window.confirm('You have selected fewer than the minimum required number of choices. If you proceed to cast this ballot, it will **NOT** be counted. If this was not your intention, please click the "Cancel" button below now, and correct your selections.')) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
answer = eosjs.eos.base.election.__all__.PreferentialAnswer(eosjs.__kwargtrans__({choices: selections}));
|
||||
booth.answers[booth.questionNum] = eosjs.eos.core.objects.__all__.EosObject.serialise_and_wrap(answer);
|
||||
|
||||
booth.q_state[booth.questionNum] = [$("#question-choices-selected .dragarea").html(), $("#question-choices-remaining .dragarea").html()]; // wew lad
|
||||
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
|
@ -35,7 +35,11 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if booth.answers[loop.index0].value.choices.length < question.max_choices %}
|
||||
{% if booth.answers[loop.index0].value.choices.length < question.min_choices %}
|
||||
<div class="ui error message">
|
||||
<p>You have selected fewer than the minimum required number of choices. If you proceed to cast this ballot, it will <span class="superem">not</span> be counted. If this was not your intention, please click the ‘Back’ button below now, and correct your selections.</p>
|
||||
</div>
|
||||
{% elif booth.answers[loop.index0].value.choices.length < question.max_choices %}
|
||||
<div class="ui warning message">
|
||||
<p>You have selected fewer than the maximum allowed number of choices. If this was not your intention, please click the ‘Back’ button below now, and correct your selections.</p>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user