submits category form on change

This commit is contained in:
Greg Newman
2023-02-01 10:30:33 -05:00
parent d3ac2d159d
commit ad8eb996a2
2 changed files with 20 additions and 21 deletions

View File

@@ -1,23 +1,23 @@
{% load static %}
<div class="md:flex rounded bg-charcoal p-3 md:p-5">
<div class="md:w-3/4 mb-4 space-y-4 md:space-y-2">
<h3 class="text-2xl mb-3 capitalize"><a href="{% url 'library-detail' slug=library.slug %}">{{ library.name }}</a></h3>
<p class="mb-3">{{ library.description }}</p>
<div class="md:flex text-sm">
<div class="md:mr-11">First Release: X.YY.Z</div>
<div class="mt-4 md:mt-0">Categories: {% for c in library.categories.all %}<a href="{% url 'libraries-by-category' category=c.slug %}" class="text-orange">{{ c.name }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}</div>
</div>
<div class="text-sm">C++ Standard Minimum Level: {{ library.cpp_standard_minimum }}</div>
</div>
<div class="md:w-1/4 mb-4 text-sm">
<div class="my-5 flex">
<div class="md:mr-5 w-1/3">Author(s):</div>
<div class="space-y-3">
{% for author in library.authors.all %}
<div><img src="{% static 'img/fpo/user.png' %}" alt="user" class="inline" /> {{ author.get_full_name }}</div>
{% endfor %}
</div>
</div>
<div class="md:w-3/4 mb-4 space-y-4 md:space-y-2">
<h3 class="text-2xl mb-3 capitalize"><a href="{% url 'library-detail' slug=library.slug %}">{{ library.name }}</a></h3>
<p class="mb-3">{{ library.description }}</p>
<div class="md:flex text-sm">
<div class="md:mr-11">First Release: X.YY.Z</div>
<div class="mt-4 md:mt-0">Categories: {% for c in library.categories.all %}<a href="{% url 'libraries-by-category' category=c.slug %}" class="text-orange">{{ c.name }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}</div>
</div>
<div class="text-sm">C++ Standard Minimum Level: {{ library.cpp_standard_minimum }}</div>
</div>
<div class="md:w-1/4 mb-4 text-sm">
<div class="my-5 flex">
<div class="md:mr-5 w-1/3">Author(s):</div>
<div class="space-y-3">
{% for author in library.authors.all %}
<div><img src="{% static 'img/fpo/user.png' %}" alt="user" class="inline" /> {{ author.get_full_name }}</div>
{% endfor %}
</div>
</div>
</div>
</div>

View File

@@ -24,11 +24,11 @@
</div>
<!-- Form to select a category -->
<form action="/libraries/" method="post" x-ref="categoryform">
<form action="/libraries/" method="post">
{% csrf_token %}
<div>
<label for="id_categories" hidden="true">Categories:</label>
<select x-on:input="$refs.categoryform.submit()" name="categories"
<select onchange="this.form.submit()" name="categories"
class="mb-3 md:mb-0 w-full md:w-auto cursor-pointer block sm:inline-block text-sm uppercase rounded-md bg-black text-orange border border-slate pl-5 pr-11 py-3 mr-3"
id="id_categories"
>
@@ -37,7 +37,6 @@
<option value="{{ c.pk }}" {% if category == c %}selected="selected"{% endif %}>{{ c.name }}</option>
{% endfor %}
</select>
<button class="bg-orange rounded p-2" @click="$refs.categoryform.submit()">Go</button>
</div>
</form>
</div>