Skip to content

Commit

Permalink
feat: improve pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGrace2282 committed Oct 5, 2024
1 parent 19d9c25 commit df32926
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
3 changes: 3 additions & 0 deletions intranet/static/js/dashboard/announcements.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ $(document).ready(function() {
filterClubAnnouncements();
});

if (flipToUnsubscribed) {
$(".unsubscribed-filter").click();
}
});

function updatePartiallyHidden() {
Expand Down
15 changes: 9 additions & 6 deletions intranet/templates/dashboard/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
{% block js %}
{{ block.super }}

<script>
const flipToUnsubscribed = "{{ request.GET.flip_to }}" == "unsubscribed";
</script>
<script src="{% static 'js/dashboard/eighth-widget.js' %}"></script>
<script src="{% static 'js/schedule.js' %}"></script>
<script src="{% static 'js/events.js' %}"></script>
Expand Down Expand Up @@ -285,7 +288,7 @@ <h3 class="club-announcements-header">
<div style="display:grid;grid-template-columns:1fr max-content 1fr">
<div style="text-align:center;grid-column-start:2">
<a {% if prev_page > 0 %}
href="{% url view_announcements_url %}?{% query_transform request page=prev_page %}"
href="{% url view_announcements_url %}?{% query_transform request page=prev_page flip_to="subscribed" %}"
{% else %}
disabled
{% endif %}
Expand All @@ -295,11 +298,11 @@ <h3 class="club-announcements-header">
{% for page in page_obj|page_list:items %}
<a class="{% if page %}button {% else %}ellipses{% endif %}"
style="{% if page == items.number %}background-image: linear-gradient(to bottom, #858585 0%, #5f5f5f 100%); color: white;{% endif %}"
href="{% url view_announcements_url %}{% if page %}?{% query_transform request page=page %}{% else %}#{% endif %}">{{ page|default:"..." }}</a>
href="{% url view_announcements_url %}{% if page %}?{% query_transform request page=page flip_to="subscribed" %}{% else %}#{% endif %}">{{ page|default:"..." }}</a>
{% endfor %}

<a {% if more_items %}
href="{% url view_announcements_url %}?{% query_transform request page=next_page %}"
href="{% url view_announcements_url %}?{% query_transform request page=next_page flip_to="subscribed" %}"
{% else %}
disabled
{% endif %}
Expand All @@ -322,7 +325,7 @@ <h3 class="club-announcements-header">
<div style="display:grid;grid-template-columns:1fr max-content 1fr">
<div style="text-align:center;grid-column-start:2">
<a {% if unsubscribed.prev_page > 0 %}
href="{% url view_announcements_url %}?{% query_transform request unsubscribed_page=unsubscribed.prev_page %}"
href="{% url view_announcements_url %}?{% query_transform request unsubscribed_page=unsubscribed.prev_page flip_to="unsubscribed" %}"
{% else %}
disabled
{% endif %}
Expand All @@ -332,11 +335,11 @@ <h3 class="club-announcements-header">
{% for page in unsubscribed.page_obj|page_list:unsubscribed.items %}
<a class="{% if page %}button {% else %}ellipses{% endif %}"
style="{% if page == unsubscribed.items.number %}background-image: linear-gradient(to bottom, #858585 0%, #5f5f5f 100%); color: white;{% endif %}"
href="{% url view_announcements_url %}{% if page %}?{% query_transform request unsubscribed_page=page %}{% else %}#{% endif %}">{{ page|default:"..." }}</a>
href="{% url view_announcements_url %}{% if page %}?{% query_transform request unsubscribed_page=page flip_to="unsubscribed" %}{% else %}#{% endif %}">{{ page|default:"..." }}</a>
{% endfor %}

<a {% if unsubscribed.more_items %}
href="{% url view_announcements_url %}?{% query_transform request unsubscribed_page=unsubscribed.next_page %}"
href="{% url view_announcements_url %}?{% query_transform request unsubscribed_page=unsubscribed.next_page flip_to="unsubscribed" %}"
{% else %}
disabled
{% endif %}
Expand Down

0 comments on commit df32926

Please sign in to comment.