forked from mirrors/bookwyrm
Merge pull request #2002 from bookwyrm-social/cw-refactor
Refactors content warning field
This commit is contained in:
commit
f2bf52ccb9
6 changed files with 37 additions and 49 deletions
|
@ -117,7 +117,7 @@
|
|||
<summary>
|
||||
<span role="heading" aria-level="3">
|
||||
{% trans "Add notes" %}
|
||||
<span class="details-close icon icon-plus" aria-hidden="true"></span>
|
||||
<span class="details-close icon icon-x" aria-hidden="true"></span>
|
||||
</span>
|
||||
</summary>
|
||||
{% include "lists/edit_item_form.html" with book=item.book %}
|
||||
|
|
|
@ -1,14 +1,23 @@
|
|||
{% load i18n %}
|
||||
<div
|
||||
class="field{% if not reply_parent.content_warning and not draft.content_warning %} is-hidden{% endif %}"
|
||||
id="spoilers_{{ uuid }}{{ local_uuid }}"
|
||||
<div class="field is-relative">
|
||||
<details
|
||||
{% if reply_parent.content_warning or draft.content_warning %}open{% endif %}
|
||||
>
|
||||
<summary class="is-flex">
|
||||
<span class="icon icon-warning is-size-5 mr-1" aria-hidden="true"></span>
|
||||
<span>
|
||||
{% trans "Include spoiler alert" %}
|
||||
</span>
|
||||
<span class="details-close icon icon-x" aria-hidden="true"></span>
|
||||
</summary>
|
||||
|
||||
<label
|
||||
class="label"
|
||||
for="id_content_warning_{{ uuid }}{{ local_uuid }}"
|
||||
>
|
||||
{% trans "Content warning:" %}
|
||||
{% trans "Spoilers/content warnings:" %}
|
||||
</label>
|
||||
<div class="control">
|
||||
<input
|
||||
type="text"
|
||||
name="content_warning"
|
||||
|
@ -20,3 +29,5 @@
|
|||
{% if not draft %}data-cache-draft="id_content_warning_{{ book.id }}_{{ type }}"{% endif %}
|
||||
>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
{% load i18n %}
|
||||
|
||||
<div class="control">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="is-hidden"
|
||||
name="sensitive"
|
||||
id="id_show_spoilers_{{ uuid }}{{ local_uuid }}"
|
||||
{% if draft.content_warning or status.content_warning %}checked{% endif %}
|
||||
aria-hidden="true"
|
||||
{% if not draft %}data-cache-draft="id_sensitive_{{ book.id }}_{{ type }}{{ reply_parent.id }}"{% endif %}
|
||||
>
|
||||
{% trans "Include spoiler alert" as button_text %}
|
||||
{% firstof draft.content_warning status.content_warning as pressed %}
|
||||
{% firstof local_uuid '' as local_uuid %}
|
||||
{% include 'snippets/toggle/toggle_button.html' with text=button_text icon="warning is-size-4" controls_text="spoilers" controls_uid=uuid|add:local_uuid focus="id_content_warning" checkbox="id_show_spoilers" class="toggle-button" pressed=pressed %}
|
||||
</div>
|
|
@ -37,8 +37,6 @@ reply_parent: the Status object this post will be in reply to, if applicable
|
|||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% include "snippets/create_status/content_warning_field.html" %}
|
||||
|
||||
{# fields that go between the content warnings and the content field (ie, quote) #}
|
||||
{% block pre_content_additions %}{% endblock %}
|
||||
|
||||
|
@ -55,6 +53,8 @@ reply_parent: the Status object this post will be in reply to, if applicable
|
|||
{# additional fields that go after the content block (ie, progress) #}
|
||||
{% block post_content_additions %}{% endblock %}
|
||||
|
||||
{% include "snippets/create_status/content_warning_field.html" %}
|
||||
|
||||
{% block options_block %}
|
||||
{# cw, post privacy, and submit button #}
|
||||
{% include "snippets/create_status/post_options_block.html" %}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
{% load i18n %}
|
||||
<div class="columns mt-1">
|
||||
<div class="field has-addons column">
|
||||
{% include "snippets/create_status/content_warning_toggle.html" %}
|
||||
<div class="field has-addons is-justify-content-end">
|
||||
<div class="control">
|
||||
{% if type == 'direct' %}
|
||||
<input type="hidden" name="privacy" value="direct">
|
||||
|
@ -14,12 +12,10 @@
|
|||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="column is-narrow control">
|
||||
<div class="control">
|
||||
<button class="button is-link" type="submit">
|
||||
<span class="icon icon-spinner" aria-hidden="true"></span>
|
||||
<span>{% trans "Post" %}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -85,9 +85,7 @@ class CreateStatus(View):
|
|||
if hasattr(status, "quote"):
|
||||
status.raw_quote = status.quote
|
||||
|
||||
if not status.sensitive and status.content_warning:
|
||||
# the cw text field remains populated when you click "remove"
|
||||
status.content_warning = None
|
||||
status.sensitive = status.content_warning not in [None, ""]
|
||||
status.save(broadcast=False)
|
||||
|
||||
# inspect the text for user tags
|
||||
|
|
Loading…
Reference in a new issue