Add ability to edit topic title from listing pages

This adds an "Edit title" choice in the actions dropdown for topics on
listing pages, instead of needing to go to the comments page.

Some pieces of this feel a little hack-ish (like needing to reduce the
bottom padding because of the usually-empty div that the title-editing
input gets put into), so I'll probably want to try and find a better
overall approach to this eventually, but it should do the job for now.
This commit is contained in:
Deimos
2020-11-15 15:49:06 -07:00
parent 8c913d595c
commit dac8ec3a01
5 changed files with 34 additions and 13 deletions

View File

@@ -20,7 +20,8 @@
grid-template-areas:
"title voting"
"metadata voting"
"info actions";
"info actions"
"action-settings action-settings";
grid-template-columns: 1fr auto;
grid-gap: 0.2rem;
@@ -37,10 +38,14 @@
position: relative;
// smaller bottom padding to account for the empty .post-action-settings div
padding: 0.2rem;
padding-bottom: 0;
@media (min-width: $size-sm) {
// smaller bottom padding to account for the empty .post-action-settings div
padding: 0.4rem;
padding-bottom: 0.2rem;
}
font-size: 0.6rem;
@@ -49,6 +54,10 @@
grid-area: title;
}
.post-action-settings {
grid-area: action-settings;
}
.topic-metadata {
grid-area: metadata;
}

View File

@@ -7,7 +7,7 @@
'ic_topic',
topic_id36=topic.topic_id36,
) }}"
data-ic-target=".topic-full h1:first"
data-ic-target="#topic-{{ topic.topic_id36 }} h1:first"
data-js-remove-on-success
>
<label class="form-label" for="title">Title:</label>

View File

@@ -217,7 +217,7 @@
comment_id36=comment.comment_id36,
) }}"
data-ic-swap-style="replace"
data-ic-target="#comment-{{ comment.comment_id36 }} .btn-post:first + .btn-post-settings"
data-ic-target="#comment-{{ comment.comment_id36 }} .btn-post:first + .post-action-settings"
>View Markdown</button>
</li>
</menu>
@@ -241,7 +241,7 @@
</li>
{% endif %}
</menu>
<div class="btn-post-settings"></div>
<div class="post-action-settings"></div>
{% endif %}
</div>
{% endmacro %}

View File

@@ -203,7 +203,7 @@
{% endmacro %}
{% macro topic_actions(topic) %}
{% if request.has_any_permission(("bookmark", "ignore"), topic) %}
{% if request.has_any_permission(("bookmark", "ignore", "edit_title"), topic) %}
<div class="dropdown dropdown-right topic-actions">
<button class="btn dropdown-toggle">
Actions
@@ -217,9 +217,21 @@
{% if request.has_permission("ignore", topic) %}
<li>{{ post_action_toggle_button("ignore", topic, is_toggled=topic.user_ignored, trigger_name="topic-actions-ignore") }}</li>
{% endif %}
</ul>
{% if request.has_permission("edit_title", topic) %}
<li><button class="btn-post-action" name="edit-title"
data-ic-get-from="{{ request.route_url(
'ic_topic_title',
topic_id36=topic.topic_id36,
) }}"
data-ic-swap-style="replace"
data-ic-target="#topic-{{ topic.topic_id36 }} .post-action-settings"
>Edit title</button>
{% endif %}
</menu>
</div>
{% endif %}
<div class="post-action-settings"></div>
{% endmacro %}
{% macro topic_classes(topic) %}

View File

@@ -30,7 +30,7 @@
{% endblock %}
{% block content %}
<article class="topic-full">
<article id="topic-{{ topic.topic_id36 }}" class="topic-full">
<header>
{{ topic_voting(topic) }}
<h1>{{ topic.title }}</h1>
@@ -117,7 +117,7 @@
topic_id36=topic.topic_id36,
) }}"
data-ic-swap-style="replace"
data-ic-target=".topic-full .btn-post:first + .btn-post-settings"
data-ic-target=".topic-full .btn-post:first + .post-action-settings"
>Tag</button></li>
{% endif %}
@@ -138,7 +138,7 @@
topic_id36=topic.topic_id36,
) }}"
data-ic-swap-style="replace"
data-ic-target=".topic-full .btn-post:first + .btn-post-settings"
data-ic-target=".topic-full .btn-post:first + .post-action-settings"
>Move</button>
{% endif %}
@@ -149,7 +149,7 @@
topic_id36=topic.topic_id36,
) }}"
data-ic-swap-style="replace"
data-ic-target=".topic-full .btn-post:first + .btn-post-settings"
data-ic-target=".topic-full .btn-post:first + .post-action-settings"
>Edit title</button>
{% endif %}
@@ -160,7 +160,7 @@
topic_id36=topic.topic_id36,
) }}"
data-ic-swap-style="replace"
data-ic-target=".topic-full .btn-post:first + .btn-post-settings"
data-ic-target=".topic-full .btn-post:first + .post-action-settings"
>Edit link</button>
{% endif %}
@@ -200,7 +200,7 @@
topic_id36=topic.topic_id36,
) }}"
data-ic-swap-style="replace"
data-ic-target=".topic-full .btn-post:first + .btn-post-settings"
data-ic-target=".topic-full .btn-post:first + .post-action-settings"
>View Markdown</button>
</li>
</menu>
@@ -208,7 +208,7 @@
</li>
{% endif %}
</menu>
<div class="btn-post-settings"></div>
<div class="post-action-settings"></div>
{% if topic.is_locked %}
<div class="toast toast-warning">This topic is locked. New comments can not be posted.</div>