Merge pull request #133 from cthulahoops/shelf_selection

Add css dropdown to select alternative shelves.
This commit is contained in:
Mouse Reeve 2020-04-11 10:29:35 -07:00 committed by GitHub
commit 5d5e97a0cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 64 additions and 19 deletions

View file

@ -139,7 +139,9 @@ body {
.pulldown-container {
position: relative;
display: inline;
}
.pulldown {
display: none;
position: absolute;
@ -149,14 +151,62 @@ body {
right: 0;
box-shadow: 0 5px 10px rgba(0,0,0,0.15);
width: max-content;
border: 2px solid #247BA0;
align: left;
}
.pulldown-container:hover .pulldown {
display: block;
}
.pulldown li {
.pulldown a {
display: block;
margin-bottom: 0.5em;
}
div.pulldown-button {
background-color: #eee;
border: 2px solid #247BA0;
border-radius: 0.3em;
color: #247BA0;
width: max-content;
white-space: nowrap;
}
.pulldown-button form {
display: inline;
}
div.pulldown-button button {
display: inline;
border: none;
border-radius: 0;
background-color: inherit;
color: #247BA0;
}
ul.pulldown button {
display: block;
text-align: left;
width: 100%;
border: none;
border-radius: 0;
background-color: white;
color: #247BA0;
}
.pulldown button[disabled] {
color: #aaa;
}
.pulldown button[disabled]:hover {
background-color: white;
}
.pulldown button:hover {
background-color: #ddd;
}
/* content area */
.content-container {
margin: 1rem;

View file

@ -1,29 +1,24 @@
{% load fr_display %}
{% if request.user.is_authenticated %}
{% if not pulldown %}
<div class="pulldown-button">
<form name="shelve" action="/shelve/" method="post">
{% csrf_token %}
<input type="hidden" name="book" value="{{ book.id }}"></input>
<input type="hidden" name="shelf" value="{% shelve_button_identifier book %}"></input>
<button class="secondary" type="submit">{% shelve_button_text book %}</button>
</form>
{% else %}
<form name="shelve" action="/shelve/" method="post">
{% csrf_token %}
<input type="hidden" name="book" value="{{ book.id }}"></input>
<select name="shelf">
<button type="submit" style="">{% shelve_button_text book %}</button></form><div class="pulldown-container"><button>&dArr;</button>
<ul class="pulldown">
<form name="shelve" action="/shelve/" method="post">
{% csrf_token %}
<input type="hidden" name="book" value="{{ book.id }}"></input>
{% for shelf in request.user.shelf_set.all %}
<option value="{{ shelf.identifier }}" {% if book in shelf.books.all %} selected {% endif %}>
{{ shelf.name }}{% if book in shelf.books.all %} ✓ {% endif %}
</option>
<li>
<button name="shelf" type="submit" value="{{ shelf.identifier }}" {% if shelf in book.shelf_set.all %} disabled {% endif %}>{{ shelf.name }} {% if shelf in book.shelf_set.all %} ✓ {% endif %}</button>
</li>
{% endfor %}
</select>
<button class="secondary" type="submit">Shelve</button>
</form>
</form>
</ul>
</div>
</div>
{% endif %}
{% endif %}