Persit checkbox state

This commit is contained in:
Ondřej Nývlt 2023-08-21 11:12:33 +02:00
parent 89f2a7c866
commit 901817409e

View file

@ -36,64 +36,66 @@
<input type="hidden" name="page" value="{{ page }}" /> <input type="hidden" name="page" value="{{ page }}" />
{% endif %} {% endif %}
<label class="checkbox"> <label class="checkbox">
<input type="checkbox" name="expand_diffs" value="true" /> <input type="checkbox" name="expand_diffs" value="true" {{ "checked" if expand_diffs else "" }} />
<p>Expand diffs</p> <p>Expand diffs</p>
</label> </label>
</form> </form>
</div> </div>
</div> </div>
<div class="container mb-8" id="diff-list"> <div id="diff-list">
{% for diff in diffs %} <div class="container mb-8">
<article class="card px-5 py-4 mb-4"> {% for diff in diffs %}
<p class="flex gap-x-4 gap-y-2 mb-3 flex-wrap shrink-0"> <article class="card px-5 py-4 mb-4">
<span class="text-sm font-medium">{{ diff.feed_name }}</span> <p class="flex gap-x-4 gap-y-2 mb-3 flex-wrap shrink-0">
<time class="text-sm font-medium">{{ diff.diff_time }}</time> <span class="text-sm font-medium">{{ diff.feed_name }}</span>
<a class="action-link" href="{{ diff.article_url }}"> <time class="text-sm font-medium">{{ diff.diff_time }}</time>
<svg class="w-4 fill-current" viewBox="0 0 24 24"><path d="M10 6V8H5V19H16V14H18V20C18 20.5523 17.5523 21 17 21H4C3.44772 21 3 20.5523 3 20V7C3 6.44772 3.44772 6 4 6H10ZM21 3V11H19L18.9999 6.413L11.2071 14.2071L9.79289 12.7929L17.5849 5H13V3H21Z"></path></svg> <a class="action-link" href="{{ diff.article_url }}">
Display current article <svg class="w-4 fill-current" viewBox="0 0 24 24"><path d="M10 6V8H5V19H16V14H18V20C18 20.5523 17.5523 21 17 21H4C3.44772 21 3 20.5523 3 20V7C3 6.44772 3.44772 6 4 6H10ZM21 3V11H19L18.9999 6.413L11.2071 14.2071L9.79289 12.7929L17.5849 5H13V3H21Z"></path></svg>
</a> Display current article
<a class="action-link" href="/article/{{ diff.article_id }}"> </a>
<svg class="w-4 fill-current" viewBox="0 0 24 24"><path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM13 12H17V14H11V7H13V12Z"></path></svg> <a class="action-link" href="/article/{{ diff.article_id }}">
Show change history <svg class="w-4 fill-current" viewBox="0 0 24 24"><path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM13 12H17V14H11V7H13V12Z"></path></svg>
</a> Show change history
</p> </a>
</p>
{% if expand_diffs %} {% if expand_diffs %}
<div class="md:hidden"> <div class="md:hidden">
<div class="mb-2"> <div class="mb-2">
<div class="text-sm text-muted">Before</div> <div class="text-sm text-muted">Before</div>
<div class="diff-before text-lg">{{ diff.diff_html|safe }}</div> <div class="diff-before text-lg">{{ diff.diff_html|safe }}</div>
</div>
<div>
<div class="text-sm text-muted">After</div>
<div class="diff-after text-lg">{{ diff.diff_html|safe }}</div>
</div>
</div> </div>
<div>
<div class="text-sm text-muted">After</div>
<div class="diff-after text-lg">{{ diff.diff_html|safe }}</div>
</div>
</div>
<table class="display-none md:display-table"> <table class="display-none md:display-table">
<tr> <tr>
<th class="text-caption pr-2">Before</th> <th class="text-caption pr-2">Before</th>
<td class="diff-before text-lg">{{ diff.diff_html|safe }}</td> <td class="diff-before text-lg">{{ diff.diff_html|safe }}</td>
</tr> </tr>
<tr> <tr>
<th class="text-caption pr-2">After</th> <th class="text-caption pr-2">After</th>
<td class="diff-after text-lg">{{ diff.diff_html|safe }}</td> <td class="diff-after text-lg">{{ diff.diff_html|safe }}</td>
</tr> </tr>
</table> </table>
{% else %} {% else %}
<div class="text-lg">{{ diff.diff_html|safe }}</div> <div class="text-lg">{{ diff.diff_html|safe }}</div>
{% endif %} {% endif %}
</article> </article>
{% endfor %} {% endfor %}
</div> </div>
<div class="overflow-x-auto"> <div class="overflow-x-auto">
<div class="container mb-3"> <div class="container mb-3">
{{ pagination.links }} {{ pagination.links }}
</div>
</div>
<div class="container text-sm text-gray-500">
{{ pagination.info }}
</div> </div>
</div> </div>
<div class="container text-sm text-gray-500">
{{ pagination.info }}
</div>
{% endblock body %} {% endblock body %}