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) {
|
function tabChange(e) {
|
||||||
e.preventDefault();
|
var target = e.target.parentElement.parentElement;
|
||||||
var target = e.target.parentElement;
|
|
||||||
var identifier = target.getAttribute('data-id');
|
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;
|
var tabs = target.parentElement.children;
|
||||||
for (i = 0; i < tabs.length; i++) {
|
for (i = 0; i < tabs.length; i++) {
|
||||||
if (tabs[i].getAttribute('data-id') == identifier) {
|
if (tabs[i].getAttribute('data-id') == identifier) {
|
||||||
|
@ -54,7 +45,6 @@ function tabChange(e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var el = document.getElementById(identifier);
|
var el = document.getElementById(identifier);
|
||||||
el.className = el.className.replace('hidden', '');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function ajaxPost(form) {
|
function ajaxPost(form) {
|
||||||
|
|
|
@ -4,13 +4,13 @@
|
||||||
<div class="tabs is-boxed">
|
<div class="tabs is-boxed">
|
||||||
<ul>
|
<ul>
|
||||||
<li class="is-active" data-id="tab-review-{{ book.id }}" data-category="tab-option-{{ book.id }}">
|
<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>
|
||||||
<li data-id="tab-comment-{{ book.id }}" data-category="tab-option-{{ book.id }}">
|
<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>
|
||||||
<li data-id="tab-quotation-{{ book.id }}" data-category="tab-option-{{ book.id }}">
|
<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>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -22,7 +22,10 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<form class="tab-option-{{ book.id }} column" name="review" action="/review/" method="post" id="tab-review-{{ book.id }}">
|
<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 %}
|
{% csrf_token %}
|
||||||
<input type="hidden" name="book" value="{{ book.id }}">
|
<input type="hidden" name="book" value="{{ book.id }}">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
|
@ -36,18 +39,36 @@
|
||||||
</div>
|
</div>
|
||||||
<button class="button is-primary" type="submit">post review</button>
|
<button class="button is-primary" type="submit">post review</button>
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
<form class="hidden tab-option-{{ book.id }} column" name="comment" action="/comment/" method="post" id="tab-comment-{{ book.id }}">
|
<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 %}
|
{% csrf_token %}
|
||||||
<input type="hidden" name="book" value="{{ book.id }}">
|
<input type="hidden" name="book" value="{{ book.id }}">
|
||||||
{{ comment_form.as_p }}
|
<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>
|
<button class="button is-primary" type="submit">post comment</button>
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
<form class="hidden tab-option-{{ book.id }} column" name="quotation" action="/quotate/" method="post" id="tab-quotation-{{ book.id }}">
|
<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 %}
|
{% csrf_token %}
|
||||||
<input type="hidden" name="book" value="{{ book.id }}">
|
<input type="hidden" name="book" value="{{ book.id }}">
|
||||||
{{ quotation_form.as_p }}
|
<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>
|
<button class="button is-primary" type="submit">post quote</button>
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -467,6 +467,8 @@ def book_page(request, book_id, tab='friends'):
|
||||||
'tags': tags,
|
'tags': tags,
|
||||||
'user_tags': user_tags,
|
'user_tags': user_tags,
|
||||||
'review_form': forms.ReviewForm(),
|
'review_form': forms.ReviewForm(),
|
||||||
|
'quotation_form': forms.QuotationForm(),
|
||||||
|
'comment_form': forms.CommentForm(),
|
||||||
'tag_form': forms.TagForm(),
|
'tag_form': forms.TagForm(),
|
||||||
'feed_tabs': [
|
'feed_tabs': [
|
||||||
{'id': 'friends', 'display': 'Friends'},
|
{'id': 'friends', 'display': 'Friends'},
|
||||||
|
|
Loading…
Reference in a new issue