Browse Source

Say "Ignore this post" in topic actions menu

This should be a little more clear about what the Ignore function does
(as opposed to thinking that it might ignore the user that posted the
topic, one of the topic's tags, etc.).

Not a huge fan of this implementation, but it seems to work okay.
merge-requests/89/head
Deimos 5 years ago
parent
commit
2434e06e93
  1. 13
      tildes/tildes/templates/macros/buttons.jinja2
  2. 2
      tildes/tildes/templates/macros/topics.jinja2

13
tildes/tildes/templates/macros/buttons.jinja2

@ -1,7 +1,7 @@
{# Copyright (c) 2019 Tildes contributors <code@tildes.net> #} {# Copyright (c) 2019 Tildes contributors <code@tildes.net> #}
{# SPDX-License-Identifier: AGPL-3.0-or-later #} {# SPDX-License-Identifier: AGPL-3.0-or-later #}
{% macro post_action_toggle_button(name, subject, is_toggled) %}
{% macro post_action_toggle_button(name, subject, is_toggled, trigger_name=None) %}
{% if subject is comment %} {% if subject is comment %}
{% set type_name = "comment" %} {% set type_name = "comment" %}
{% elif subject is topic %} {% elif subject is topic %}
@ -9,12 +9,21 @@
{% endif %} {% endif %}
{% set route_name = "ic_" + type_name + "_" + name %} {% set route_name = "ic_" + type_name + "_" + name %}
{# If not specified, set the trigger_name from the one in the request (if any) #}
{% set trigger_name = trigger_name or request.params.get("ic-trigger-name") %}
{% if name == "bookmark" %} {% if name == "bookmark" %}
{% set normal_label = "Bookmark" %} {% set normal_label = "Bookmark" %}
{% set toggled_label = "Unbookmark" %} {% set toggled_label = "Unbookmark" %}
{% elif name == "ignore" %} {% elif name == "ignore" %}
{% set normal_label = "Ignore" %} {% set normal_label = "Ignore" %}
{% set toggled_label = "Unignore" %} {% set toggled_label = "Unignore" %}
{% if trigger_name and trigger_name.startswith("topic-actions-") %}
{# For the topic actions menu, say "(Un)ignore this post" for clarity" #}
{% set normal_label = "Ignore this post" %}
{% set toggled_label = "Unignore this post" %}
{% endif %}
{% elif name == "lock" %} {% elif name == "lock" %}
{% set normal_label = "Lock" %} {% set normal_label = "Lock" %}
{% set toggled_label = "Unlock" %} {% set toggled_label = "Unlock" %}
@ -39,12 +48,14 @@
<li> <li>
{% if not is_toggled %} {% if not is_toggled %}
<button class="btn-post-action" <button class="btn-post-action"
{% if trigger_name %}name="{{ trigger_name }}"{% endif %}
data-ic-put-to="{{ _post_action_toggle_button_url(route_name, subject) }}" data-ic-put-to="{{ _post_action_toggle_button_url(route_name, subject) }}"
data-ic-replace-target="true" data-ic-replace-target="true"
{% if normal_confirm %}data-ic-confirm="{{ normal_confirm }}"{% endif %} {% if normal_confirm %}data-ic-confirm="{{ normal_confirm }}"{% endif %}
>{{ normal_label }}</button> >{{ normal_label }}</button>
{% else %} {% else %}
<button class="btn-post-action btn-post-action-used" <button class="btn-post-action btn-post-action-used"
{% if trigger_name %}name="{{ trigger_name }}"{% endif %}
data-ic-delete-from="{{ _post_action_toggle_button_url(route_name, subject) }}" data-ic-delete-from="{{ _post_action_toggle_button_url(route_name, subject) }}"
data-ic-replace-target="true" data-ic-replace-target="true"
{% if toggled_confirm %}data-ic-confirm="{{ toggled_confirm }}"{% endif %} {% if toggled_confirm %}data-ic-confirm="{{ toggled_confirm }}"{% endif %}

2
tildes/tildes/templates/macros/topics.jinja2

@ -205,7 +205,7 @@
{% endif %} {% endif %}
{% if request.has_permission("ignore", topic) %} {% if request.has_permission("ignore", topic) %}
{{ post_action_toggle_button("ignore", topic, is_toggled=topic.user_ignored) }}
{{ post_action_toggle_button("ignore", topic, is_toggled=topic.user_ignored, trigger_name="topic-actions-ignore") }}
{% endif %} {% endif %}
</ul> </ul>
</div> </div>

Loading…
Cancel
Save