new template _partials for apps.dashboard, incl. _form.html & _scripts.html; respective form, table & content code offloaded from base.html, home.html & list.html; functional_tests.test_my_list TODO resumed (only FT not currently passing, but this is as expected)
This commit is contained in:
17
src/templates/apps/dashboard/_partials/_form.html
Normal file
17
src/templates/apps/dashboard/_partials/_form.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<form method="POST" action="{{ form_action }}">
|
||||
{% csrf_token %}
|
||||
<input
|
||||
id="id_text"
|
||||
name="text"
|
||||
class="form-control form-control-lg{% if form.errors %} is-invalid{% endif %}"
|
||||
placeholder="Enter a to-do item"
|
||||
value="{{ form.text.value | default:'' }}"
|
||||
aria-describedby="id_text_feedback"
|
||||
required
|
||||
/>
|
||||
{% if form.errors %}
|
||||
<div id="id_text_feedback" class="invalid-feedback">
|
||||
{{ form.errors.text.0 }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</form>
|
||||
6
src/templates/apps/dashboard/_partials/_scripts.html
Normal file
6
src/templates/apps/dashboard/_partials/_scripts.html
Normal file
@@ -0,0 +1,6 @@
|
||||
<script src="/static/apps/scripts/dashboard.js"></script>
|
||||
<script>
|
||||
window.onload = () => {
|
||||
initialize("#id_text");
|
||||
};
|
||||
</script>
|
||||
@@ -3,4 +3,11 @@
|
||||
{% block title_text %}Start a new to-do list{% endblock title_text %}
|
||||
{% block header_text %}Start a new to-do list{% endblock header_text %}
|
||||
|
||||
{% block form_action %}{% url "new_list" %}{% endblock form_action %}
|
||||
{% block extra_header %}
|
||||
{% url "new_list" as form_action %}
|
||||
{% include "apps/dashboard/_partials/_form.html" with form=form form_action=form_action %}
|
||||
{% endblock extra_header %}
|
||||
|
||||
{% block scripts %}
|
||||
{% include "apps/dashboard/_partials/_scripts.html" %}
|
||||
{% endblock scripts %}
|
||||
|
||||
@@ -3,13 +3,24 @@
|
||||
{% block title_text %}Your to-do list{% endblock title_text %}
|
||||
{% block header_text %}Your to-do list{% endblock header_text %}
|
||||
|
||||
{% block form_action %}{% url "view_list" list.id %}{% endblock form_action %}
|
||||
|
||||
{% block table %}
|
||||
<table id="id_list_table" class="table">
|
||||
{% for item in list.item_set.all %}
|
||||
<tr><td>{{ forloop.counter }}. {{ item.text }}</td></tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endblock table %}
|
||||
{% block extra_header %}
|
||||
{% url "view_list" list.id as form_action %}
|
||||
{% include "apps/dashboard/_partials/_form.html" with form=form form_action=form_action %}
|
||||
{% endblock extra_header %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-6">
|
||||
<table id="id_list_table" class="table">
|
||||
{% for item in list.item_set.all %}
|
||||
<tr><td>{{ forloop.counter }}. {{ item.text }}</td></tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
||||
{% block scripts %}
|
||||
{% include "apps/dashboard/_partials/_scripts.html" %}
|
||||
{% endblock scripts %}
|
||||
|
||||
Reference in New Issue
Block a user