Skip to content

Commit

Permalink
Add and remove RSVP from list (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
yefim authored Jun 26, 2023
1 parent fd59ebf commit 34bfccd
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions app/templates/attendee_rsvp.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@
submitRSVP("not_attending");
});

function removeSelfFromList() {
const li = [...$attendeesList.children].find((el) => {
return el.innerText === "{{attendee.attendee.split()[0]}}";
});

if (li) {
$attendeesList.removeChild(li);
}
}

function submitRSVP(status) {
const junction_pub = document.getElementById("junction_pub").value;
const attendeeStatus = document.getElementById("attendee_status");
Expand All @@ -150,12 +160,18 @@

switch (status) {
case "attending":
removeSelfFromList();
const li = document.createElement("li");
li.innerText = "{{attendee.attendee.split()[0]}}";
$attendeesList.appendChild(li);
consoleText([attendeeStatus.innerText, "attending"]);
break;
case "maybe":
removeSelfFromList();
consoleText([attendeeStatus.innerText, "a maybe for"]);
break;
case "not_attending":
removeSelfFromList();
consoleText([
attendeeStatus.innerText,
"unable to make it for",
Expand Down Expand Up @@ -208,11 +224,11 @@

/* Populate list of attendees. */
const ATTENDEE_DATA = "ATTENDEES_UNKNOWN".split(",");
const listEl = document.getElementById("attendees-list");
const $attendeesList = document.getElementById("attendees-list");
ATTENDEE_DATA.forEach((attendee) => {
const li = document.createElement("li");
li.innerText = attendee;
listEl.appendChild(li);
$attendeesList.appendChild(li);
});

function consoleText(words, id, colors) {
Expand Down

0 comments on commit 34bfccd

Please sign in to comment.