From efc64c6cd7ebbb61ffb6dea438f194d026d3256a Mon Sep 17 00:00:00 2001 From: armored-dragon Date: Thu, 5 Sep 2024 17:06:12 -0500 Subject: [PATCH] Creating and sending ballot --- applications/voting/vote.js | 9 ++++----- applications/voting/vote.qml | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/applications/voting/vote.js b/applications/voting/vote.js index ade668e..a362b68 100644 --- a/applications/voting/vote.js +++ b/applications/voting/vote.js @@ -164,13 +164,13 @@ // Cast a vote on a poll function castVote(event) { - console.log(`Casting vote to ${poll.id}: ${event}`); + console.log(`Casting vote to ${poll.id}`); // Check if poll is valid if (poll == undefined || poll.id == '') return; - // Send vote to server - Messages.sendMessage(poll.id, JSON.stringify({type: "vote", option: event.option})); + // Send vote to users in poll + Messages.sendMessage(poll.id, JSON.stringify({type: "vote", ballot: event.ballot, uuid: myUuid})); } // Emit the prompt question and options to the server @@ -192,8 +192,7 @@ // Communication function fromQML(event) { console.log(`New QML event:\n${JSON.stringify(event)}`); - // event = JSON.parse(event); - console.log(event.type); + switch (event.type) { case "create_poll": createPoll(event.poll); diff --git a/applications/voting/vote.qml b/applications/voting/vote.qml index fcd71a9..30fd1de 100644 --- a/applications/voting/vote.qml +++ b/applications/voting/vote.qml @@ -365,6 +365,7 @@ Rectangle { } } + // TODO: Keep track of used numbers and blacklist them // Options Item { width: parent.width