Improve multi month polls
This commit is contained in:
+12
-1
@@ -49,6 +49,14 @@ function renderAll() {
|
||||
cal = new Calendar($("calendar"), {
|
||||
canClick: (ds) => canVote && byDate.has(ds),
|
||||
isOffered: (ds) => byDate.has(ds),
|
||||
months: () => {
|
||||
const counts = new Map();
|
||||
for (const ds of byDate.keys()) {
|
||||
const key = ds.slice(0, 7);
|
||||
counts.set(key, (counts.get(key) || 0) + 1);
|
||||
}
|
||||
return counts;
|
||||
},
|
||||
isPicked: (ds) => byDate.has(ds) && myPicks.has(byDate.get(ds).id),
|
||||
onToggle: (ds) => {
|
||||
const id = byDate.get(ds).id;
|
||||
@@ -85,8 +93,11 @@ function renderAll() {
|
||||
|
||||
function updateSummary() {
|
||||
const n = myPicks.size;
|
||||
const total = poll.options.length;
|
||||
$("vote-summary").textContent =
|
||||
n === 0 ? "No days circled yet." : n === 1 ? "1 day circled." : `${n} days circled.`;
|
||||
n === 0
|
||||
? `No days circled yet — ${total} ${total === 1 ? "day" : "days"} offered.`
|
||||
: `${n} of ${total} offered days circled.`;
|
||||
}
|
||||
|
||||
function renderResults() {
|
||||
|
||||
Reference in New Issue
Block a user