Skip to content

Commit 3fea2c4

Browse files
committed
Fixed count of votes cast (#108)
* Fixed count of votes cast * Misc fixes
1 parent 62d186d commit 3fea2c4

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

api.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,21 @@ func GetPollResults(c *gin.Context) {
254254
return
255255
}
256256

257-
fmt.Println(len(results))
257+
numVotes := 0
258+
259+
for _, v := range results {
260+
for key := range v {
261+
numVotes += v[key]
262+
}
263+
}
264+
258265
c.HTML(http.StatusOK, "result.tmpl", gin.H{
259266
"Id": poll.Id,
260267
"Title": poll.Title,
261268
"Description": poll.Description,
262269
"VoteType": poll.VoteType,
263270
"Results": results,
264-
"NumVotes": len(results),
271+
"NumVotes": numVotes,
265272
"IsOpen": poll.Open,
266273
"IsHidden": poll.Hidden,
267274
"CanModify": canModify,

templates/create.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434
</select>
3535
</div>
3636
<div id="customOptions" class="input-group d-none my-3">
37-
<label for="customOptions" class="input-group-text">Custom Options</label>
37+
<label for="customOptions" class="input-group-text">Custom Vote Options</label>
3838
<input
3939
type="text"
4040
name="customOptions"
4141
class="form-control"
42-
placeholder="Enter a comma separated list of custom options"
42+
placeholder="Enter a comma separated list of custom vote options"
4343
>
4444
</div>
4545

@@ -112,7 +112,7 @@
112112
</div>
113113
{{ end }}
114114

115-
<input type="submit" class="btn btn-primary" value="Create">
115+
<input type="submit" class="btn btn-primary my-2" value="Create">
116116
</form>
117117
</div>
118118

templates/poll.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
<form action="/poll/{{ .Id }}" method="POST">
1717
{{ if eq .PollType "simple" }}
1818
{{ range $i, $option := .Options }}
19-
<div class="form-check fs-4">
19+
<div class="form-check fs-4 lh-sm">
2020
<input class="form-check-input" type="radio" name="option" id="{{ $option }}" value="{{ $option }}" />
2121
<label class="form-check-label" for="{{ $option }}">{{ $option }}</label>
2222
</div>
2323
<br />
2424
{{ end }}
2525
{{ if .AllowWriteIns }}
26-
<div class="form-check fs-4">
26+
<div class="form-check fs-4 lh-sm">
2727
<input class="form-check-input" type="radio" name="option" value="writein" />
2828
<input
2929
type="text"

templates/result.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
{{ end }}
2525
{{ end }}
2626

27-
<h2>{{ .Title }}</h2>
27+
<h2 class="text-break">{{ .Title }}</h2>
2828
{{ if .Description }}
2929
<h4>{{ .Description | MakeLinks }}</h4>
3030
{{ end }}

0 commit comments

Comments
 (0)