add entities per page dropdown

This commit is contained in:
Manuel Gugger 2022-07-26 22:34:33 +02:00
parent 130a2b4098
commit 38792b0fb5
3 changed files with 107 additions and 73 deletions

View File

@ -1,8 +1,11 @@
{% extends "base.html" %}
{% block content %}
<article>
<form method="post">
{% for model_field in view_model.fields -%}
<label for="{{ model_field.field_name }}">
{{ model_field.field_name }}
{% if model_field.select_list != "" %}
<select name="{{ model_field.field_name }}">
{% if model_field.is_option %}
@ -16,10 +19,13 @@
</select>
{% else %}
<input type="{{ model_field.html_input_type }}" name="{{ model_field.field_name }}"
placeholder="{{ model_field.field_name }}" aria-label="{{ model_field.field_name }}"><!-- required="" -->
placeholder="{{ model_field.field_name }}" aria-label="{{ model_field.field_name }}">
<!-- required="" -->
{% endif %}
</label>
{%- endfor %}
<button type="submit">Save</button>
<a href="{{ list_link }}" role="button" class="secondary">Cancel</a>
</form>
</article>
{% endblock content %}

View File

@ -1,24 +1,33 @@
{% extends "base.html" %}
{% block content %}
<article>
<form method="post">
<div>
{% for model_field in view_model.fields -%}
<label for="{{ model_field.field_name }}">
{{ model_field.field_name }}
{% if model_field.select_list != "" %}
<select name="{{ model_field.field_name }}">
{% if model_field.is_option %}
<option value=""></option>
{% endif %}
{% for select_list_item in select_lists[model_field.field_name] -%}
<option {% if select_list_item[0] == model.values | get(key=model_field.field_name) %} selected {% endif %} value="{{ select_list_item[0] }}">{{ select_list_item[1] }}</option>
<option {% if select_list_item[0]==model.values | get(key=model_field.field_name) %} selected {%
endif %} value="{{ select_list_item[0] }}">{{ select_list_item[1] }}</option>
{%- endfor %}
</select>
</label>
{% else %}
<input type="{{ model_field.html_input_type }}" value="{{ model.values | get(key=model_field.field_name) }}" name="{{ model_field.field_name }}" placeholder="{{ model_field.field_name }}" aria-label="{{ model_field.field_name }}"><!-- required="" -->
<input type="{{ model_field.html_input_type }}" value="{{ model.values | get(key=model_field.field_name) }}"
name="{{ model_field.field_name }}" placeholder="{{ model_field.field_name }}"
aria-label="{{ model_field.field_name }}"><!-- required="" -->
{% endif %}
</label>
{%- endfor %}
<button type="submit">Save</button>
<a href="{{ list_link }}" role="button" class="secondary">Cancel</a>
</div>
</form>
</article>
{% endblock content %}

View File

@ -1,7 +1,13 @@
{% extends "base.html" %}
{% block content %}
<article>
<div class="grid">
<div>
<a href="create" role="button">&#43;</a>
</div>
</div>
<table role="grid">
<thead>
<tr>
@ -31,8 +37,7 @@
</tbody>
<tfoot>
<tr>
<td colspan="{{ num_pages + 2 }}">
<div>
<td colspan="{{ view_model.fields | length + 2 }}">
<a href="?page={{ page - 1 }}&entities_per_page={{ entities_per_page }}">&laquo;</a>
{% for i in range(end=num_pages) %}
<a href="?page={{ i + 1 }}&entities_per_page={{ entities_per_page }}">{{ i + 1 }}</a>
@ -42,4 +47,18 @@
</tr>
</tfoot>
</table>
<div class="grid">
<div>
<form>
<label for="entities_per_page">Entities per Page
<select name="entities_per_page" onchange="this.form.submit()">
{% for a in [10,20,50,100,] %}
<option {% if entities_per_page == a %}selected{% endif %} value="{{ a }}">{{ a }}</option>
{% endfor %}
</select>
</label>
</form>
</div>
</div>
</article>
{% endblock content %}