Uses modal template for progress modal

This commit is contained in:
Mouse Reeve 2021-08-28 09:41:36 -07:00
parent ae840002de
commit 3a8eeb35a7
3 changed files with 31 additions and 45 deletions

View file

@ -0,0 +1,27 @@
{% load i18n %}
<div class="field has-addons">
<div class="control">
<input
type="number"
name="progress"
class="input"
id="id_progress_{{ readthrough.id }}"
value="{{ readthrough.progress }}"
{% if progress_required %}required{% endif %}
>
</div>
<div class="control select">
<select name="progress_mode" aria-label="Progress mode">
<option
value="PG"
{% if readthrough.progress_mode == 'PG' %}selected{% endif %}>
{% trans "pages" %}
</option>
<option
value="PCT"
{% if readthrough.progress_mode == 'PCT' %}selected{% endif %}>
{% trans "percent" %}
</option>
</select>
</div>
</div>

View file

@ -1,4 +1,4 @@
{% extends 'components/modal.html' %} {% extends 'snippets/reading_modals/layout.html' %}
{% load i18n %} {% load i18n %}
{% block modal-title %} {% block modal-title %}
@ -7,40 +7,9 @@
{% block modal-form-open %} {% block modal-form-open %}
<form action="{% url 'edit-readthrough' %}" method="POST"> <form action="{% url 'edit-readthrough' %}" method="POST">
{% endblock %}
{% block modal-body %}
{% csrf_token %} {% csrf_token %}
<input type="hidden" name="id" value="{{ readthrough.id }}"/>
<div class="field">
<label class="label is-align-self-center mb-0 pr-2" for="progress">{% trans "Progress:" %}</label>
<div class="field has-addons mb-0">
<div class="control">
<input
aria-label="{% if readthrough.progress_mode == 'PG' %}Current page{% else %}Percent read{% endif %}"
class="input"
type="number"
min="0"
name="progress"
size="3"
value="{{ readthrough.progress|default:'' }}">
</div>
<div class="control select">
<select name="progress_mode" aria-label="Progress mode">
<option value="PG" {% if readthrough.progress_mode == 'PG' %}selected{% endif %}>{% trans "pages" %}</option>
<option value="PCT" {% if readthrough.progress_mode == 'PCT' %}selected{% endif %}>{% trans "percent" %}</option>
</select>
</div>
</div>
{% if readthrough.progress_mode == 'PG' and book.pages %}
<p class="help">{% blocktrans with pages=book.pages %}of {{ pages }} pages{% endblocktrans %}</p>
{% endif %}
</div>
{% endblock %} {% endblock %}
{% block modal-footer %} {% block reading-dates %}
<button class="button is-success" type="submit">{% trans "Save" %}</button> {% include "snippets/progress_field.html" with progress_required=True %}
{% trans "Cancel" as button_text %}
{% include 'snippets/toggle/toggle_button.html' with text=button_text %}
{% endblock %} {% endblock %}
{% block modal-form-close %}</form>{% endblock %}

View file

@ -13,17 +13,7 @@
<label class="label" for="id_progress_{{ readthrough.id }}"> <label class="label" for="id_progress_{{ readthrough.id }}">
{% trans "Progress" %} {% trans "Progress" %}
</label> </label>
<div class="field has-addons"> {% include "snippets/progress_field.html" %}
<div class="control">
<input type="number" name="progress" class="input" id="id_progress_{{ readthrough.id }}" value="{{ readthrough.progress }}">
</div>
<div class="control select">
<select name="progress_mode" aria-label="Progress mode">
<option value="PG" {% if readthrough.progress_mode == 'PG' %}selected{% endif %}>{% trans "pages" %}</option>
<option value="PCT" {% if readthrough.progress_mode == 'PCT' %}selected{% endif %}>{% trans "percent" %}</option>
</select>
</div>
</div>
{% endif %} {% endif %}
<div class="field"> <div class="field">
<label class="label" for="id_finish_date_{{ readthrough.id }}"> <label class="label" for="id_finish_date_{{ readthrough.id }}">