Skip to content

Commit

Permalink
152 feature copy rsvp attendees email to clipboard (#157)
Browse files Browse the repository at this point in the history
* copy rsvp attendee's email when on rsvp tab

* Fix copy to clipboard alert, fix logic

---------

Co-authored-by: Ryan Chen <103216376+ryanyychen@users.noreply.github.com>
  • Loading branch information
KengLL and ryanyychen authored Apr 25, 2024
1 parent 4d479cd commit c2d4132
Showing 1 changed file with 58 additions and 15 deletions.
73 changes: 58 additions & 15 deletions frontend/src/Components/Events/CustomizableEventConsole.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
export let event;
let eventid = event.pk;
let emailsCheckedOff = [];
let emailsRsvp = [];
async function checkAdmin() {
let response = await fetch(`/api/permissions/`).then(value => value.json());
Expand All @@ -34,6 +35,31 @@
}
}
async function copyToClipboard(text, sign_tab) {
if(text.length == 0){
alert("No checked off attendees!");
}else{
if(sign_tab){
try {
await navigator.clipboard.writeText(text);
alert("Checked-Off attendee's email copied to clipboard!");
} catch (err) {
console.error("Failed to copy:", err);
alert("Failed to copy text to clipboard.");
}
}else{
try {
await navigator.clipboard.writeText(text);
alert("RSVP'd attendee's email copied to clipboard!");
} catch (err) {
console.error("Failed to copy:", err);
alert("Failed to copy text to clipboard.");
}
}
}
}
// This variable is used by the EditPointsModal to select a particular user
// and edit that user's points. It is set to one of the rows of the table
// during the Edit Points button on:click event.
Expand Down Expand Up @@ -87,6 +113,7 @@
});
rows.forEach((row) => {
emailsRsvp.push(row["Email"]);
if (row["Check Off Id"] !== undefined) {
emailsCheckedOff.push(row["Email"]);
}
Expand Down Expand Up @@ -128,20 +155,6 @@
return rows;
}
async function copyToClipboard(text) {
if(text.length == 0){
alert("No checked off attendees!");
}else{
try {
await navigator.clipboard.writeText(text);
alert("Text copied to clipboard!");
} catch (err) {
console.error("Failed to copy:", err);
alert("Failed to copy text to clipboard.");
}
}
}
// Filter Table
let generateTablePromise = generateTable();
let indexedRows = new Map();
Expand Down Expand Up @@ -245,7 +258,37 @@
}}>
RSVP List
</button>
<button on:click={() => copyToClipboard(emailsCheckedOff)}>Copy Emails</button>
<script>
// if Check Off button is selected, gray out the Check Off button
// and highlight the RSVP'd button
let signed_in = document.getElementById("signed-in");
let rsvpd = document.getElementById("rsvpd");
rsvpd.style.backgroundColor = "gray";
signed_in.addEventListener("click", () => {
signed_in.selected = true;
rsvpd.selected = false;
signed_in.style.backgroundColor = "var(--fc-button-bg-color)";
rsvpd.style.backgroundColor = "gray";
});
rsvpd.addEventListener("click", () => {
signed_in.selected = false;
rsvpd.selected = true;
signed_in.style.backgroundColor = "gray";
rsvpd.style.backgroundColor = "var(--fc-button-bg-color)";
});
</script>
<button
on:click={() => {
if (rsvpd.selected) {
copyToClipboard(emailsRsvp, rsvpd.selected);
} else {
copyToClipboard(emailsCheckedOff, rsvpd.selected);
}
}}>
Copy Emails
</button>
</div>

<table style="margin-top: 0px;">
Expand Down

0 comments on commit c2d4132

Please sign in to comment.