-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathcreate.tmpl
More file actions
166 lines (157 loc) · 5.55 KB
/
create.tmpl
File metadata and controls
166 lines (157 loc) · 5.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
{{ template "header.tmpl" . }}
<div class="container main p-5">
<h2 class="mb-4">Create Poll</h2>
<form action="/create" method="POST">
<div class="input-group needs-validation">
<label for="title" class="input-group-text required-label">Poll Title</label>
<input
type="text"
class="form-control"
name="title"
placeholder="My Poll"
required
>
</div>
<div class="input-group my-3">
<label for="description" class="input-group-text">Description</label>
<input
type="text"
name="description"
class="form-control"
placeholder="Description"
>
</div>
<div class="input-group my-3">
<label for="options" class="input-group-text required-label">Options</label>
<select name="options" id="options" onChange="onOptionsChange()" class="form-select">
<option value="pass_fail" selected>Pass/Fail</option>
<option value="pass-fail-conditional">
Pass/Fail or Conditional
</option>
<option value="fail-conditional">Fail/Conditional</option>
<option value="custom">Custom</option>
</select>
</div>
<div id="customOptions" class="input-group d-none my-3">
<label for="customOptions" class="input-group-text">Custom Vote Options</label>
<input
type="text"
name="customOptions"
class="form-control"
placeholder="Enter a comma separated list of custom vote options"
>
</div>
<h5 class="mt-4"><strong>Additional Settings</strong></h5>
<div class="form-check form-switch fs-5">
<input
class="form-check-input"
type="checkbox"
role="switch"
name="allowWriteIn"
value="true"
>
<label for="allowWriteIn" class="form-check-label">Allow Write-Ins</label>
</div>
<div class="form-check form-switch fs-5">
<input
class="form-check-input"
type="checkbox"
name="rankedChoice"
value="true"
>
<label for="rankedChoice" class="form-check-label">Ranked Choice Vote</label>
</div>
<div class="form-check form-switch fs-5">
<input
class="form-check-input"
type="checkbox"
name="hidden"
value="true"
>
<label for="hidden" class="form-check-label">Hide Results Until Vote is Complete</label>
</div>
{{ if .EBoard }}
<div id="eboard-options" class="my-4">
<h5><strong>E-Board Options</strong></h5>
<div class="form-check form-switch fs-5">
<input
class="form-check-input"
type="checkbox"
name="gatekeep"
id="gatekeep"
value="true"
onchange="onGatekeepChange()"
>
<label for="gatekeep"> Gatekeep Required (Require Quorum, Limit Voters, Force Automatic Close)</label>
</div>
<div id="quorumPercentInput" class="input-group d-none w-auto my-3">
<label for="quorumType" class="input-group-text">Quorum %</label>
<input
type="number"
name="quorumType"
id="quorumType"
class="form-control"
min="0"
max="100"
step="1"
value="50"
>
</div>
<div id="waivedUsers" class="input-group d-none">
<label for="waivedUsers" class="input-group-text">Waived Users</label>
<input
type="text"
name="waivedUsers"
class="form-control"
placeholder="Comma separated list of usernames"
>
</div>
</div>
{{ end }}
<input type="submit" class="btn btn-primary my-2" value="Create">
</form>
</div>
<style>
.required-label::after {
content: " *";
color: red;
}
</style>
<script>
function onOptionsChange() {
if (document.getElementById("options").value == "custom") {
document.getElementById("customOptions").classList.remove('d-none');
} else {
document.getElementById("customOptions").classList.add('d-none');
}
}
function onGatekeepChange(){
const gatekeepBox = document.getElementById("gatekeep");
const waivedUsers = document.getElementById("waivedUsers");
const quorumType = document.getElementById("quorumPercentInput");
if (gatekeepBox.checked){
waivedUsers.classList.remove('d-none');
quorumType.classList.remove('d-none');
} else {
waivedUsers.classList.add('d-none');
quorumType.classList.add('d-none');
}
}
(() => {
'use strict'
// Fetch all the forms we want to apply custom Bootstrap validation styles to
const forms = document.querySelectorAll('.needs-validation')
// Loop over them and prevent submission
Array.from(forms).forEach(form => {
form.addEventListener('submit', event => {
if (!form.checkValidity()) {
event.preventDefault()
event.stopPropagation()
}
form.classList.add('was-validated')
}, false)
})
})()
</script>
</body>
</html>