Browse Source

25 per page, simple pagination style

joel
Joel Galvez 1 year ago
parent
commit
54a7fab6da
5 changed files with 76 additions and 67 deletions
  1. +1
    -1
      web/app/book.py
  2. +1
    -1
      web/app/practice.py
  3. +8
    -6
      web/app/static/styles/main.css
  4. +65
    -58
      web/app/templates/resources.html
  5. +1
    -1
      web/app/tool.py

+ 1
- 1
web/app/book.py View File

@@ -47,7 +47,7 @@ def get_books():
books_query = books_query.filter_by(**kwargs)

# finalise the query and add pagination
books = books_query.order_by(Resource.name).paginate(page=page, per_page=5)
books = books_query.order_by(Resource.name).paginate(page=page, per_page=25)

# FILTERS MENU
# get values for filter menu dropdowns

+ 1
- 1
web/app/practice.py View File

@@ -49,7 +49,7 @@ def get_practices():
))

# finalise the query and add pagination
practices = practices_query.order_by(Resource.name).paginate(page=page, per_page=5)
practices = practices_query.order_by(Resource.name).paginate(page=page, per_page=25)

# POST-FILTERING PROCESSING
# if view is 'expanded' then append relationships

+ 8
- 6
web/app/static/styles/main.css View File

@@ -583,6 +583,14 @@ video {
margin-top: 1rem;
margin-bottom: 1rem;
}
.mx-2 {
margin-left: 0.5rem;
margin-right: 0.5rem;
}
.mx-1 {
margin-left: 0.25rem;
margin-right: 0.25rem;
}
.mb-2 {
margin-bottom: 0.5rem;
}
@@ -1159,12 +1167,6 @@ h2,h3 {
hyphens: auto;
}

h2 {
font-family: 'ag-fett';
font-size: 1.5rem;
line-height: 1.1;
}

h3 {
font-family: 'ag-fett';
}

+ 65
- 58
web/app/templates/resources.html View File

@@ -67,65 +67,72 @@
<div class="-m-4 mb-4 lg:m-0">
{{ view_switch() }}
</div>
{% if practices_filter%}
{{ filter_dropdown('practice', practices_filter, 'Practices') }}
{% endif %}
{% if year_filter %}
{{ filter_dropdown_nokey('year', year_filter, 'Year') }}
{% endif %}
{% if typology_filter %}
{{ filter_dropdown_nokey('typology', typology_filter, 'Typologies') }}
{% endif %}
{% if languages_filter %}
{{ filter_dropdown_nokey('scriptingLanguage', languages_filter, 'Scripting languages') }}
{% endif %}
{% if licenses_filter %}
{{ filter_dropdown_nokey('license', licenses_filter, 'Licenses') }}
{% endif %}
{% if status_filter %}
{{ filter_dropdown_nokey('status', status_filter, 'Maintenance status') }}
{% endif %}
{% if not practices_filter and not year_filter and not typology_filter and not languages_filter and not licenses_filter and not status_filter %}
{% else %}
<a href="{{ url_for(request.endpoint) }}?view={{ view }}">Reset</a>
{% endif %}
</div>
<div>
{% if view == 'list' %}
{% for resource in resources %}
{{ resource_list(resource, loop) }}
{% endfor %}
{% else %}
{% for resource in resources %}
{{ resource_with_related(resource, loop) }}
{% endfor %}
{% endif %}
</div>

{% macro render_pagination(pagination) %}
<div class=page-items>

{% if practices_filter%}
{{ filter_dropdown('practice', practices_filter, 'Practices') }}
{% endif %}
{% if year_filter %}
{{ filter_dropdown_nokey('year', year_filter, 'Year') }}
{% endif %}
{% if typology_filter %}
{{ filter_dropdown_nokey('typology', typology_filter, 'Typologies') }}
{% endif %}
{% if languages_filter %}
{{ filter_dropdown_nokey('scriptingLanguage', languages_filter, 'Scripting languages') }}
{% endif %}
{% if licenses_filter %}
{{ filter_dropdown_nokey('license', licenses_filter, 'Licenses') }}
{% endif %}
{% if status_filter %}
{{ filter_dropdown_nokey('status', status_filter, 'Maintenance status') }}
{% endif %}

{% if not practices_filter and not year_filter and not typology_filter and not languages_filter and not
licenses_filter and not status_filter %}
{% else %}
<a href="{{ url_for(request.endpoint) }}?view={{ view }}">Reset</a>
{% endif %}

</div>

<div>
{% if view == 'list' %}
{% for resource in resources %}
{{ resource_list(resource, loop) }}
{% endfor %}
{% else %}
{% for resource in resources %}
{{ resource_with_related(resource, loop) }}
{% endfor %}
{% endif %}
</div>

{% macro render_pagination(pagination) %}

<!-- <div class=page-items>
{{ pagination.first }} - {{ pagination.last }} of {{ pagination.total }}
</div>
<div class=pagination>
{% for page in pagination.iter_pages() %}
{% if page %}
{% if page != pagination.page %}
<a href="{{ url_for(request.endpoint, page=page) }}{% for key in request.args %}{% if key != 'page' %}&{{ key }}={{ request.args.get(key) }}{% endif %}{% endfor %}">{{ page }}</a>
{% else %}
<strong>{{ page }}</strong>
{% endif %}
{% else %}
<span class=ellipsis>…</span>
{% endif %}
{% endfor %}
</div>
{% endmacro %}

{{ render_pagination(resources) }}
</div> -->

<div class="pagination p-4">
<span class="mr-2">Page</span>
{% for page in pagination.iter_pages() %}
{% if page %}
{% if page != pagination.page %}

<a href="{{ url_for(request.endpoint, page=page) }}{% for key in request.args %}{% if key != 'page' %}&{{ key }}={{ request.args.get(key) }}{% endif %}{% endfor %}"
class="mx-1">{{
page }}</a>
{% else %}
<strong class="mx-1">{{ page }}</strong>
{% endif %}
{% else %}
<span class="ellipsis">…</span>
{% endif %}
{% endfor %}
</div>
{% endmacro %}

{{ render_pagination(resources) }}

</form>


+ 1
- 1
web/app/tool.py View File

@@ -50,7 +50,7 @@ def get_tools():
tools_query = tools_query.filter_by(**kwargs)

# finalise the query and add pagination
tools = tools_query.order_by(Resource.name).paginate(page=page, per_page=5)
tools = tools_query.order_by(Resource.name).paginate(page=page, per_page=25)

# FILTERS MENU
# get values for filter menu dropdowns

Loading…
Cancel
Save