BLT editor: Tweak workflow

Start on candidate entry screen
Go to candidate entry screen when loading file
This commit is contained in:
RunasSudo 2021-01-26 04:11:44 +11:00
parent f15e2bd89b
commit 89507fb916
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 15 additions and 14 deletions

View File

@ -34,7 +34,7 @@
<a href="https://yingtongli.me/blog/2020/12/24/pyrcv2.html">Information and instructions</a>
</div>
<div id="bltMain">
<div id="bltMain" style="display: none;">
<select id="selBallots" size="20" onchange="changeBallot()">
<option value="new" selected>-- New Ballot --</option>
</select>
@ -44,15 +44,17 @@
Ballot value: <input id="txtBallotValue" type="number" value="1" min="1" style="width: 3em;">
</div>
<table id="tblBallot"></table>
<button onclick="clickSave()">Save and advance to next ballot</button>
<button onclick="clickSave()">Save and advance to next ballot (Enter)</button>
</div>
</div>
<div id="divEditCandidates" style="display: none;">
<div id="divEditCandidates">
<div>Enter the candidates' names, one per line:</div>
<div><textarea id="txtCandidates"></textarea></div>
<div><textarea id="txtCandidates">Candidate 1
Candidate 2
Candidate 3</textarea></div>
<div><button onclick="clickSaveCandidates()">Save candidates</button></div>
<div>Warning: Adding, removing or reordering candidates once ballots have been input may result in unexpected behaviour.</div>
<div><b>Warning:</b> Adding, removing or reordering candidates once ballots have been input may result in unexpected behaviour.</div>
</div>
<script src="../bundle.js?v=GITVERSION"></script>

View File

@ -16,7 +16,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
let candidates = ['Candidate 1', 'Candidate 2', 'Candidate 3'];
let candidates = [];
let ballots = [];
let inpFile = document.getElementById('inpFile');
@ -160,9 +160,13 @@ async function changeInpFile() {
}
}
// Go to ballot entry screen
document.getElementById('bltMain').style.display = '';
document.getElementById('divEditCandidates').style.display = 'none';
// Update ballot entry
initBallot();
// Update ballot list
selBallots.innerHTML = '<option value="new" selected>-- New Ballot --</option>';
selBallots.value = 'new';
@ -247,7 +251,7 @@ function clickExportBLT() {
function clickEditCandidates() {
document.getElementById('bltMain').style.display = 'none';
document.getElementById('divEditCandidates').style.display = 'block';
document.getElementById('divEditCandidates').style.display = '';
document.getElementById('txtCandidates').value = candidates.join('\n');
}
@ -263,11 +267,6 @@ function clickSaveCandidates() {
initBallot();
changeBallot();
document.getElementById('bltMain').style.display = 'flex';
document.getElementById('bltMain').style.display = '';
document.getElementById('divEditCandidates').style.display = 'none';
}
// Init tasks
initBallot();
changeBallot();