forked from mirrors/bookwyrm
Status form in book page
This commit is contained in:
parent
61fa15a0c2
commit
dbc6fb1d18
3 changed files with 52 additions and 39 deletions
|
@ -32,18 +32,9 @@ function rate_stars(e) {
|
|||
}
|
||||
|
||||
function tabChange(e) {
|
||||
e.preventDefault();
|
||||
var target = e.target.parentElement;
|
||||
var target = e.target.parentElement.parentElement;
|
||||
var identifier = target.getAttribute('data-id');
|
||||
|
||||
var options_class = target.getAttribute('data-category');
|
||||
var options = document.getElementsByClassName(options_class);
|
||||
for (var i = 0; i < options.length; i++) {
|
||||
if (!options[i].className.includes('hidden')) {
|
||||
options[i].className += ' hidden';
|
||||
}
|
||||
}
|
||||
|
||||
var tabs = target.parentElement.children;
|
||||
for (i = 0; i < tabs.length; i++) {
|
||||
if (tabs[i].getAttribute('data-id') == identifier) {
|
||||
|
@ -54,7 +45,6 @@ function tabChange(e) {
|
|||
}
|
||||
|
||||
var el = document.getElementById(identifier);
|
||||
el.className = el.className.replace('hidden', '');
|
||||
}
|
||||
|
||||
function ajaxPost(form) {
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
<div class="tabs is-boxed">
|
||||
<ul>
|
||||
<li class="is-active" data-id="tab-review-{{ book.id }}" data-category="tab-option-{{ book.id }}">
|
||||
<a href="/book/{{ book.id }}/review" onclick="tabChange(event)">Review</a>
|
||||
<label for="review-{{ book.id }}" onclick="tabChange(event)"><a>Review</a></label>
|
||||
</li>
|
||||
<li data-id="tab-comment-{{ book.id }}" data-category="tab-option-{{ book.id }}">
|
||||
<a href="/book/{{ book.id }}/comment" onclick="tabChange(event)">Comment</a>
|
||||
<label for="comment-{{ book.id}}" onclick="tabChange(event)"><a>Comment</a></label>
|
||||
</li>
|
||||
<li data-id="tab-quotation-{{ book.id }}" data-category="tab-option-{{ book.id }}">
|
||||
<a href="/book/{{ book.id }}/quotation" onclick="tabChange(event)">Quote</a>
|
||||
<label for="quote-{{ book.id }}" onclick="tabChange(event)"><a>Quote</a></label>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -22,32 +22,53 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
<form class="tab-option-{{ book.id }} column" name="review" action="/review/" method="post" id="tab-review-{{ book.id }}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="book" value="{{ book.id }}">
|
||||
<div class="control">
|
||||
<label class="label" for="id_name">Title:</label>
|
||||
{{ review_form.name }}
|
||||
<div class="column">
|
||||
<div>
|
||||
<input class="toggle-control" type="radio" name="status-tabs" id="review-{{ book.id }}" checked>
|
||||
<form class="toggle-content hidden tab-option-{{ book.id }}" name="review" action="/review/" method="post" id="tab-review-{{ book.id }}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="book" value="{{ book.id }}">
|
||||
<div class="control">
|
||||
<label class="label" for="id_name">Title:</label>
|
||||
{{ review_form.name }}
|
||||
</div>
|
||||
<div class="control">
|
||||
<label class="label" for="id_content">Review:</label>
|
||||
{% include 'snippets/rate_form.html' with book=book %}
|
||||
{{ review_form.content }}
|
||||
</div>
|
||||
<button class="button is-primary" type="submit">post review</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="control">
|
||||
<label class="label" for="id_content">Review:</label>
|
||||
{% include 'snippets/rate_form.html' with book=book %}
|
||||
{{ review_form.content }}
|
||||
|
||||
<div>
|
||||
<input class="toggle-control" type="radio" name="status-tabs" id="comment-{{ book.id }}">
|
||||
<form class="toggle-content hidden tab-option-{{ book.id }}" name="comment" action="/comment/" method="post" id="tab-comment-{{ book.id }}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="book" value="{{ book.id }}">
|
||||
<div class="control">
|
||||
<label class="label" for="id_content">Comment:</label>
|
||||
{{ comment_form.content }}
|
||||
</div>
|
||||
<button class="button is-primary" type="submit">post comment</button>
|
||||
</form>
|
||||
</div>
|
||||
<button class="button is-primary" type="submit">post review</button>
|
||||
</form>
|
||||
|
||||
<form class="hidden tab-option-{{ book.id }} column" name="comment" action="/comment/" method="post" id="tab-comment-{{ book.id }}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="book" value="{{ book.id }}">
|
||||
{{ comment_form.as_p }}
|
||||
<button class="button is-primary" type="submit">post comment</button>
|
||||
</form>
|
||||
|
||||
<form class="hidden tab-option-{{ book.id }} column" name="quotation" action="/quotate/" method="post" id="tab-quotation-{{ book.id }}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="book" value="{{ book.id }}">
|
||||
{{ quotation_form.as_p }}
|
||||
<button class="button is-primary" type="submit">post quote</button>
|
||||
</form>
|
||||
<div>
|
||||
<input class="toggle-control" type="radio" name="status-tabs" id="quote-{{ book.id }}">
|
||||
<form class="toggle-content hidden tab-option-{{ book.id }}" name="quotation" action="/quotate/" method="post" id="tab-quotation-{{ book.id }}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="book" value="{{ book.id }}">
|
||||
<div class="control">
|
||||
<label class="label" for="id_quote">Quote:</label>
|
||||
{{ quotation_form.quote }}
|
||||
</div>
|
||||
<div class="control">
|
||||
<label class="label" for="id_content">Comment:</label>
|
||||
{{ quotation_form.content }}
|
||||
</div>
|
||||
<button class="button is-primary" type="submit">post quote</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -467,6 +467,8 @@ def book_page(request, book_id, tab='friends'):
|
|||
'tags': tags,
|
||||
'user_tags': user_tags,
|
||||
'review_form': forms.ReviewForm(),
|
||||
'quotation_form': forms.QuotationForm(),
|
||||
'comment_form': forms.CommentForm(),
|
||||
'tag_form': forms.TagForm(),
|
||||
'feed_tabs': [
|
||||
{'id': 'friends', 'display': 'Friends'},
|
||||
|
|
Loading…
Reference in a new issue