From bcaacfa757f461ac20aaadff07be02ca9ea90e79 Mon Sep 17 00:00:00 2001 From: Yaron Shmaria Date: Sun, 26 Feb 2017 21:09:06 +0200 Subject: [PATCH 1/3] add submittedSuggestion logic --- api/game.js | 18 ++++++++++++++++++ src/assets/pencil-writing.png | Bin 0 -> 659 bytes src/components/GamePage.vue | 8 +++++++- src/components/PlayerList.vue | 5 +++-- 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 src/assets/pencil-writing.png diff --git a/api/game.js b/api/game.js index f5899ca..d3790bb 100644 --- a/api/game.js +++ b/api/game.js @@ -25,6 +25,24 @@ module.exports = function (router) { res.send(true) }) + // POST /submit + router.post('/submit', function (req, res, next) { + var playerId = req.body.playerId + var suggestionDisabled = req.body.suggestionDisabled + if (!playerId) { + res.status(422).send("Missing playerId") + return + } + var player = State.getPlayerById(playerId) + if (player == null) { + res.status(422).send(`Missing player for playerId ${playerId}`) + return + } + player.suggestionSubmitted = true + server.io.emit('server:state') + res.send(true) + }) + // POST /removeVote router.post('/removevote', function (req, res, next) { var voterId = req.body.voterId diff --git a/src/assets/pencil-writing.png b/src/assets/pencil-writing.png new file mode 100644 index 0000000000000000000000000000000000000000..df2cd32f34182672872a49b0cc89ef63476b8dfb GIT binary patch literal 659 zcmV;E0&M+>P)FDU1nTq)M_{hX;^78W7guvzG#?ao{-@Tx>$bz-OinFPwp09qMbtPgpGBbySQly|>piFs=D|I&= zIhB%Dse*B@p=zL>hqSVuy1B8pw1Lvm!e(Ma5RW$M0004ANklV56lW}-^Fp8m#(9V5CZMbW zkfyjOVg+jIDZ0!h!8+YLc{=}WkpqoTNrO-+$!WxfDk*Vrv)M%OR!xF>&ie0 z+qB|ZupWiz1c+JP*sR4t%rJrGd0xAHbc}I&q6A(O*#Q--Q}wE+=$;cYY#latzAlq` zQL=ooc3XR#nq1g=8bTL>Ge+5uWx9W$yILBql-W}VDRiBGPnBxvr%`~ZE!8pxQ5IiCOk002ovPDHLkV1gg3R4D)e literal 0 HcmV?d00001 diff --git a/src/components/GamePage.vue b/src/components/GamePage.vue index b0500f7..226ef0d 100644 --- a/src/components/GamePage.vue +++ b/src/components/GamePage.vue @@ -71,7 +71,13 @@ }, submit: function () { console.log(`submitting text for ${this.sharedState.playerId}`) - this.suggestionDisabled = 1 + this.suggestionDisabled = true + request.post('/api/submit', { + playerId: this.sharedState.playerId, + suggestionDisabled: this.suggestionDisabled + }, function (err, state) { + if (err) { console.log(err) } + }) console.log(this.suggestionDisabled) } }, diff --git a/src/components/PlayerList.vue b/src/components/PlayerList.vue index 9d960f6..82411f8 100644 --- a/src/components/PlayerList.vue +++ b/src/components/PlayerList.vue @@ -9,7 +9,8 @@
{{player.nickname}}
-
+
+
@@ -98,7 +99,7 @@ .vote-button { display: inline-block; - background-image: url('../assets/heart-icon.png'); + background-image: url('../assets/pencil-writing.png'); width: 32px; height: 32px; cursor: pointer; From 2cb731196664cc3ae23e63382c8d85e5e1152dad Mon Sep 17 00:00:00 2001 From: Yaron Shmaria Date: Sun, 26 Feb 2017 21:27:22 +0200 Subject: [PATCH 2/3] vote-button icons --- src/components/PlayerList.vue | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/PlayerList.vue b/src/components/PlayerList.vue index 82411f8..7f17299 100644 --- a/src/components/PlayerList.vue +++ b/src/components/PlayerList.vue @@ -99,12 +99,19 @@ .vote-button { display: inline-block; - background-image: url('../assets/pencil-writing.png'); width: 32px; height: 32px; cursor: pointer; } - + + .vote-button:disabled { + background-image: url('../assets/pencil-writing.png') + } + + .vote-button:enabled { + background-image: url('../assets/heart-icon.png') + } + .voteButtonActive { /* Use different style for active and hover https://github.com/groupwrite-io/groupwrite.io/issues/60 @@ -116,7 +123,7 @@ margin-top: 20px; } - .vote-button:hover { + .vote-button:hover:enabled { background-image: url('../assets/heart-icon-hover.png'); } \ No newline at end of file From 823c165fe416d31b9d96886963bda7be19dcafb5 Mon Sep 17 00:00:00 2001 From: Yaron Shmaria Date: Sun, 26 Feb 2017 21:44:32 +0200 Subject: [PATCH 3/3] playerbox div .voteButtonActive --- src/components/PlayerList.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/PlayerList.vue b/src/components/PlayerList.vue index 7f17299..827f42e 100644 --- a/src/components/PlayerList.vue +++ b/src/components/PlayerList.vue @@ -112,7 +112,7 @@ background-image: url('../assets/heart-icon.png') } - .voteButtonActive { + .playerbox div .voteButtonActive { /* Use different style for active and hover https://github.com/groupwrite-io/groupwrite.io/issues/60 */