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

1177 course import deduplicate emails #1236

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Changes from 2 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
49 changes: 34 additions & 15 deletions web/template/admin/admin_tabs/course-import.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,40 @@
</label>
<table>
<tbody>
<template x-for="contact in course.contacts">
<tr class="pl-3" :class="contact.main_contact?'text-green-400':'text-3'">
<td class="px-2">
<label>
<i class="fa fa-envelope" x-show="contact.main_contact"></i>
<input class="w-auto" type="checkbox" x-model="contact.main_contact">
</label>
</td>
<td class="px-2" x-text="contact.role + ':'"></td>
<td x-text="contact.first_name + ' ' + contact.last_name" class="px-2"></td>
<td class="px-2">
<a :href="'mailto:'+contact.email" x-text="contact.email"></a>
</td>
</tr>
</template>
<script>
/*
The data coming from TUMonline sometimes duplicates contacts of some courses.
course.contacts has 5 attributes:
first_name, last_name, email, main_contact, role.
All cases considered, the most distinctive among them is e-mail.
and that's why duplicates are eliminated accordingly.
*/
function filterUniqueContacts(contacts) {
const uniqueEmails = new Set();
return contacts.filter(contact => {
if (!uniqueEmails.has(contact.email)) {
uniqueEmails.add(contact.email);
return true;
}
return false;
});
}
</script>
<template x-for="contact in filterUniqueContacts(course.contacts)">
<tr class="pl-3" :class="contact.main_contact ? 'text-green-400' : 'text-3'">
<td class="px-2">
<label>
<i class="fa fa-envelope" x-show="contact.main_contact"></i>
<input class="w-auto" type="checkbox" x-model="contact.main_contact">
</label>
</td>
<td class="px-2" x-text="contact.role + ':'"></td>
<td x-text="contact.first_name + ' ' + contact.last_name" class="px-2"></td>
<td class="px-2">
<a :href="'mailto:' + contact.email" x-text="contact.email"></a>
</td>
</tr>
</template>
</tbody>
</table>
<template x-for="event in course.events">
Expand Down
Loading