diff --git a/eosweb/core/static/nunjucks/booth/selections.html b/eosweb/core/static/nunjucks/booth/selections.html index 925b62d..550f72d 100644 --- a/eosweb/core/static/nunjucks/booth/selections.html +++ b/eosweb/core/static/nunjucks/booth/selections.html @@ -46,7 +46,9 @@ } function nextQuestion() { - saveSelections(); + if (!saveSelections()) { + return; + } if (booth.questionNum == election.questions.__len__() - 1) { nextTemplate(); } else { diff --git a/eosweb/core/static/nunjucks/question/approval/selections_make.html b/eosweb/core/static/nunjucks/question/approval/selections_make.html index c938abc..53ff4b7 100644 --- a/eosweb/core/static/nunjucks/question/approval/selections_make.html +++ b/eosweb/core/static/nunjucks/question/approval/selections_make.html @@ -18,7 +18,15 @@

{{ questionNum + 1 }}. {{ election.questions.__getitem__(questionNum).prompt }}

-

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.

+

+ 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. +

@@ -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; } diff --git a/eosweb/core/static/nunjucks/question/approval/selections_review.html b/eosweb/core/static/nunjucks/question/approval/selections_review.html index 8f686a8..439b387 100644 --- a/eosweb/core/static/nunjucks/question/approval/selections_review.html +++ b/eosweb/core/static/nunjucks/question/approval/selections_review.html @@ -30,7 +30,11 @@ {% endfor %}
-{% if booth.answers[loop.index0].value.choices.length < question.max_choices %} +{% if booth.answers[loop.index0].value.choices.length < question.min_choices %} +
+

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 ‘Back’ button below now, and correct your selections.

+
+{% elif booth.answers[loop.index0].value.choices.length < question.max_choices %}

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.

diff --git a/eosweb/core/static/nunjucks/question/preferential/selections_make.html b/eosweb/core/static/nunjucks/question/preferential/selections_make.html index 7a78041..8512a24 100644 --- a/eosweb/core/static/nunjucks/question/preferential/selections_make.html +++ b/eosweb/core/static/nunjucks/question/preferential/selections_make.html @@ -18,7 +18,15 @@

{{ questionNum + 1 }}. {{ election.questions.__getitem__(questionNum).prompt }}

-

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.

+

+ 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. +

Options voted for:
@@ -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; } diff --git a/eosweb/core/static/nunjucks/question/preferential/selections_review.html b/eosweb/core/static/nunjucks/question/preferential/selections_review.html index 9e048ef..cd27f4d 100644 --- a/eosweb/core/static/nunjucks/question/preferential/selections_review.html +++ b/eosweb/core/static/nunjucks/question/preferential/selections_review.html @@ -35,7 +35,11 @@
{% endif %} -{% if booth.answers[loop.index0].value.choices.length < question.max_choices %} +{% if booth.answers[loop.index0].value.choices.length < question.min_choices %} +
+

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 ‘Back’ button below now, and correct your selections.

+
+{% elif booth.answers[loop.index0].value.choices.length < question.max_choices %}

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.