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

feat: fix club announcements for 15+ announcements #1737

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 1 addition & 5 deletions intranet/apps/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,8 @@ def paginate_announcements_list_raw(
prev_page = items.previous_page_number() if items.has_previous() else 0
next_page = items.next_page_number() if more_items else 0

# limit to 15 to prevent extreme slowdowns for large amounts
# of club announcements
club_items = visible_club_items[:15]

return RawPaginationData(
club_items=club_items,
club_items=visible_club_items,
items=items,
page_num=page_num,
prev_page=prev_page,
Expand Down
4 changes: 4 additions & 0 deletions intranet/static/css/dashboard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -419,3 +419,7 @@ div[data-placeholder]:not(:focus):not([data-div-placeholder-content]):before {
padding-right: 432px;
}
}

.hidden-club-announcements {
display: none;
}
6 changes: 4 additions & 2 deletions intranet/static/js/dashboard/announcements.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,12 @@ function announcementToggle() {
announcement.remove();
const numAnnouncementsSpan = $(".num-club-announcements");
const numAnnouncements = numAnnouncementsSpan.text().match(/\d+/);
// 15 is the cap, and prevent clicking on the button too fast
if(numAnnouncements != 15 && !announcement.hasClass("announcement-read")) {
if(!announcement.hasClass("announcement-read")) {
numAnnouncementsSpan.text(numAnnouncements - 1);
announcement.addClass("announcement-read");
let newAnnouncement = $(".hidden-club-announcements").first();
newAnnouncement.toggleClass("hidden-club-announcements");
newAnnouncement.fadeIn(350);
}
$(".club-announcements:has(.club-announcements-content:not(:has(.announcement)))").slideUp(350);
}, 450);
Expand Down
13 changes: 5 additions & 8 deletions intranet/templates/dashboard/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,20 +217,17 @@ <h3>
<div class="club-announcements">
<h3 class="club-announcements-header">
<i class="fas fa-users"></i>&nbsp;
<!-- This only goes up to 15 items. Removing this restriction causes slowdowns. -->
{% if club_items|length < 15 %}
You have <span class="num-club-announcements">{{ club_items|length }}</span> new club announcement{{ club_items|length|pluralize }}
{% else %}
You have <span class="num-club-announcements">15+</span> new club announcements
{% endif %}
You have <span class="num-club-announcements">{{ club_items|length }}</span> new club announcement{{ club_items|length|pluralize }}
<i class="fas fa-chevron-down club-announcements-toggle-icon"></i>
</h3>
<div class="club-announcements-content">
{% for item in club_items %}
{% if not hide_announcements or not item.id in user_hidden_announcements %}
{% with announcement=item show_icon=True %}
<div class="{% if forloop.counter >= 15 %}hidden-club-announcements{% endif %}">
{% with announcement=item show_icon=True %}
{% include "announcements/announcement.html" %}
{% endwith %}
{% endwith %}
</div>
{% endif %}
{% endfor %}
</div>
Expand Down
Loading