Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

152 feature copy rsvp attendees email to clipboard #157

Merged
merged 3 commits into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading