Merge pull request #332

feat: add today button to MonthYearPicker
This commit is contained in:
Herculino Trotta
2025-08-15 22:54:21 -03:00
committed by GitHub
2 changed files with 51 additions and 40 deletions
+7
View File
@@ -91,6 +91,12 @@ def month_year_picker(request):
for date in all_months for date in all_months
] ]
today_url = (
reverse(url, kwargs={"month": current_date.month, "year": current_date.year})
if url
else ""
)
return render( return render(
request, request,
"common/fragments/month_year_picker.html", "common/fragments/month_year_picker.html",
@@ -98,6 +104,7 @@ def month_year_picker(request):
"month_year_data": result, "month_year_data": result,
"current_month": current_month, "current_month": current_month,
"current_year": current_year, "current_year": current_year,
"today_url": today_url,
}, },
) )
@@ -5,9 +5,9 @@
{% block title %}{% translate 'Pick a month' %}{% endblock %} {% block title %}{% translate 'Pick a month' %}{% endblock %}
{% block body %} {% block body %}
{% regroup month_year_data by year as years_list %} {% regroup month_year_data by year as years_list %}
<ul class="nav nav-pills nav-fill" id="yearTabs" role="tablist"> <ul class="nav nav-pills nav-fill" id="yearTabs" role="tablist">
{% for x in years_list %} {% for x in years_list %}
<li class="nav-item" role="presentation"> <li class="nav-item" role="presentation">
<button class="nav-link{% if x.grouper == current_year %} active{% endif %}" <button class="nav-link{% if x.grouper == current_year %} active{% endif %}"
@@ -22,8 +22,8 @@
</button> </button>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
<div class="tab-content" id="yearTabsContent" hx-boost="true"> <div class="tab-content" id="yearTabsContent" hx-boost="true">
{% for x in years_list %} {% for x in years_list %}
<div class="tab-pane fade{% if x.grouper == current_year %} show active{% endif %} mt-2" <div class="tab-pane fade{% if x.grouper == current_year %} show active{% endif %} mt-2"
id="{{ x.grouper }}-pane" id="{{ x.grouper }}-pane"
@@ -47,5 +47,9 @@
</ul> </ul>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
<hr>
<div class="w-full text-end">
<a class="btn btn-outline-primary btn-sm" href="{{ today_url }}" role="button" hx-boost="true">{% trans 'Today' %}</a>
</div>
{% endblock %} {% endblock %}