From a1e7b4931b204ae56f5aa4a9977c39ee6f837eda Mon Sep 17 00:00:00 2001 From: Julien Schmidt <js@stusta.net> Date: Wed, 13 May 2020 11:59:12 +0200 Subject: [PATCH] add button to select YES for all applicants --- vote/static/vote/js/vote.js | 10 ++++++++++ vote/templates/vote/vote.html | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/vote/static/vote/js/vote.js b/vote/static/vote/js/vote.js index df664ba..866f51e 100644 --- a/vote/static/vote/js/vote.js +++ b/vote/static/vote/js/vote.js @@ -18,3 +18,13 @@ document.querySelectorAll(".vote-list input[type='radio']").forEach(function(inp voteList.querySelector("tfoot .yes").innerText = (max-count) + " remaining"; } }); + +document.querySelectorAll("#all-yes").forEach(function(btn) { + btn.onclick = function() { + var voteList = document.querySelector('.vote-list'); + voteList.querySelectorAll("input[type='radio'][value='accept']").forEach(function(input) { + input.checked = true; + input.onchange(); + }); + } +}); diff --git a/vote/templates/vote/vote.html b/vote/templates/vote/vote.html index e00b7ae..82a2602 100644 --- a/vote/templates/vote/vote.html +++ b/vote/templates/vote/vote.html @@ -41,6 +41,11 @@ Your vote is anonymous. </div> </div> + {% if max_votes_yes > 1 and max_votes_yes >= form.num_applications %} + <div class="mt-4 text-right"> + <button type="button" class="btn btn-success" id="all-yes">Select YES for all {{ form.num_applications }} applicants</button> + </div> + {% endif %} <table class="table table-sm vote-list" data-max-votes-yes="{{ max_votes_yes }}"> <thead class="thead-light"> <tr> -- GitLab