much better

This commit is contained in:
2025-11-09 20:44:26 -08:00
parent b3a96cab1e
commit bafa9190e2
7 changed files with 362 additions and 140 deletions

View File

@@ -1,74 +1,31 @@
<div class="flex justify-between items-center mt-4 px-2">
<div class="text-sm text-gray-700">
Showing {{ ((current_page - 1) * per_page) + 1 }} to
{% if current_page * per_page < total_projects %}
{{ current_page * per_page }}
{% else %}
{{ total_projects }}
{% endif %}
of {{ total_projects }} projects
</div>
{% if total_pages > 1 %}
<div class="flex justify-center items-center mt-6 space-x-2">
{% if current_page > 1 %}
<a href="{{ url_for(request.endpoint, page=current_page - 1) }}" class="px-3 py-2 text-sm text-slate-600 bg-white border border-slate-300 rounded-md hover:bg-slate-50">
Previous
</a>
{% else %}
<span class="px-3 py-2 text-sm text-slate-400 bg-white border border-slate-300 rounded-md cursor-not-allowed">Previous</span>
{% endif %}
<div class="flex space-x-2">
<!-- Previous Button -->
{% if current_page > 1 %}
<a href="{{ url_for('dashboard', page=current_page - 1) }}"
class="px-3 py-1 text-sm bg-gray-100 text-gray-700 rounded hover:bg-gray-200 transition-colors">
Previous
</a>
{% else %}
<span class="px-3 py-1 text-sm text-gray-400 bg-gray-50 rounded cursor-not-allowed">
Previous
</span>
{% for page in range(1, total_pages + 1) %}
{% if page == current_page %}
<span class="px-3 py-2 text-sm font-medium text-white bg-blue-600 border border-blue-600 rounded-md">{{ page }}</span>
{% elif page == 1 or page == total_pages or (page >= current_page - 2 and page <= current_page + 2) %}
<a href="{{ url_for(request.endpoint, page=page) }}" class="px-3 py-2 text-sm text-slate-600 bg-white border border-slate-300 rounded-md hover:bg-slate-50">
{{ page }}
</a>
{% elif page == current_page - 3 or page == current_page + 3 %}
<span class="px-3 py-2 text-sm text-slate-400">...</span>
{% endif %}
<!-- Page Numbers -->
{% set start_page = [1, current_page - 2]|max %}
{% set end_page = [total_pages, current_page + 2]|min %}
{% if start_page > 1 %}
<a href="{{ url_for('dashboard', page=1) }}"
class="px-3 py-1 text-sm bg-gray-100 text-gray-700 rounded hover:bg-gray-200 transition-colors">
1
</a>
{% if start_page > 2 %}
<span class="px-3 py-1 text-sm text-gray-400">...</span>
{% endif %}
{% endif %}
{% for page_num in range(start_page, end_page + 1) %}
{% if page_num == current_page %}
<span class="px-3 py-1 text-sm bg-blue-600 text-white rounded">
{{ page_num }}
</span>
{% else %}
<a href="{{ url_for('dashboard', page=page_num) }}"
class="px-3 py-1 text-sm bg-gray-100 text-gray-700 rounded hover:bg-gray-200 transition-colors">
{{ page_num }}
</a>
{% endif %}
{% endfor %}
{% if end_page < total_pages %}
{% if end_page < total_pages - 1 %}
<span class="px-3 py-1 text-sm text-gray-400">...</span>
{% endif %}
<a href="{{ url_for('dashboard', page=total_pages) }}"
class="px-3 py-1 text-sm bg-gray-100 text-gray-700 rounded hover:bg-gray-200 transition-colors">
{{ total_pages }}
</a>
{% endif %}
<!-- Next Button -->
{% if current_page < total_pages %}
<a href="{{ url_for('dashboard', page=current_page + 1) }}"
class="px-3 py-1 text-sm bg-gray-100 text-gray-700 rounded hover:bg-gray-200 transition-colors">
Next
</a>
{% else %}
<span class="px-3 py-1 text-sm text-gray-400 bg-gray-50 rounded cursor-not-allowed">
Next
</span>
{% endif %}
</div>
</div>
{% endfor %}
{% if current_page < total_pages %}
<a href="{{ url_for(request.endpoint, page=current_page + 1) }}" class="px-3 py-2 text-sm text-slate-600 bg-white border border-slate-300 rounded-md hover:bg-slate-50">
Next
</a>
{% else %}
<span class="px-3 py-2 text-sm text-slate-400 bg-white border border-slate-300 rounded-md cursor-not-allowed">Next</span>
{% endif %}
</div>
{% endif %}