Skip to content

Commit

Permalink
show a badge for needs-plans tab and update it when the filter changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Oppenheimer authored and Aaron Oppenheimer committed Jul 23, 2024
1 parent 4a112e2 commit 939083e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions agenda/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ def set_default_view(request, val):
return HttpResponse()


@login_required
def get_needplans_count(request, *args, **kw):
c = request.user.future_noplans.count()
return HttpResponse(c if c else "")


@login_required
def grid_heatmap(request, *args, **kw):
year = int(request.POST['year'])
Expand Down
1 change: 1 addition & 0 deletions agenda/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@
path('grid/gigs', helpers.grid_gigs, name='grid-gigs'),

path('defaultview/<int:val>', helpers.set_default_view, name='set-default-view'),
path('schedule/needplans', helpers.get_needplans_count, name='need-plans-count'),
]
9 changes: 6 additions & 3 deletions agenda/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,18 @@ def get_context_data(self, **kwargs):
context['the_layout'] = layout

context['the_buttons'] = [
[AgendaLayoutChoices.ONE_LIST, _("All Upcoming Gigs"), 0, layout==AgendaLayoutChoices.ONE_LIST],
[AgendaLayoutChoices.NEED_RESPONSE, _('Needs Reponse'), 0, layout==AgendaLayoutChoices.NEED_RESPONSE],
[AgendaLayoutChoices.ONE_LIST, _("All Upcoming Gigs"), 0, layout==AgendaLayoutChoices.ONE_LIST, False],
[AgendaLayoutChoices.NEED_RESPONSE, _('Needs Reponse'), 0,
layout==AgendaLayoutChoices.NEED_RESPONSE, True],
]

bands = [a.band for a in self.request.user.confirmed_assocs if not a.hide_from_schedule]
if len(bands) > 1:
for b in bands:
context['the_buttons'].append(
[AgendaLayoutChoices.BY_BAND, b.shortname if b.shortname else b.name, b.id, layout==AgendaLayoutChoices.BY_BAND and layout_band==b]
[AgendaLayoutChoices.BY_BAND,
b.shortname if b.shortname else b.name, b.id,
layout==AgendaLayoutChoices.BY_BAND and layout_band==b, False]
)

return context
Expand Down
3 changes: 3 additions & 0 deletions templates/agenda/agenda.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
<input type="radio" name="options" id="option1" {% if button.3 %}checked{% endif %}
hx-get="{% url 'agenda-gigs' the_type=button.0 the_band=button.2 %}"
hx-target="#the-list">{{button.1}}
{% if button.4 %}
<span class="badge badge-secondary" id="needplan-badge"></span>
{% endif %}
</label>
{% if button.3 %}<span hx-get="{% url 'agenda-gigs' the_type=button.0 the_band=button.2 %}"
hx-target="#the-list" hx-trigger="load"></span>{% endif %}
Expand Down
2 changes: 2 additions & 0 deletions templates/agenda/agenda_gigs.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{% load i18n %}
{% load static %}
<div class="mx-auto col-md-10 col-12">
<span hx-get="{% url 'need-plans-count' %}" hx-target="#needplan-badge" hx-trigger="load"></span>

<div class="card mb-4">
<div class="card-header">
<div class="row titlerow">
Expand Down

0 comments on commit 939083e

Please sign in to comment.