From dac8ec3a01a099bd582ee50f9dcddeae88ce0afc Mon Sep 17 00:00:00 2001 From: Deimos Date: Sun, 15 Nov 2020 15:49:06 -0700 Subject: [PATCH] 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. --- tildes/scss/modules/_topic.scss | 11 ++++++++++- .../intercooler/topic_title_edit.jinja2 | 2 +- tildes/tildes/templates/macros/comments.jinja2 | 4 ++-- tildes/tildes/templates/macros/topics.jinja2 | 16 ++++++++++++++-- tildes/tildes/templates/topic.jinja2 | 14 +++++++------- 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/tildes/scss/modules/_topic.scss b/tildes/scss/modules/_topic.scss index 474ee9b..bd96e56 100644 --- a/tildes/scss/modules/_topic.scss +++ b/tildes/scss/modules/_topic.scss @@ -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; } diff --git a/tildes/tildes/templates/intercooler/topic_title_edit.jinja2 b/tildes/tildes/templates/intercooler/topic_title_edit.jinja2 index 117f530..a805e09 100644 --- a/tildes/tildes/templates/intercooler/topic_title_edit.jinja2 +++ b/tildes/tildes/templates/intercooler/topic_title_edit.jinja2 @@ -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 > diff --git a/tildes/tildes/templates/macros/comments.jinja2 b/tildes/tildes/templates/macros/comments.jinja2 index 299e1d9..353d27f 100644 --- a/tildes/tildes/templates/macros/comments.jinja2 +++ b/tildes/tildes/templates/macros/comments.jinja2 @@ -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 @@ -241,7 +241,7 @@ {% endif %} -
+
{% endif %} {% endmacro %} diff --git a/tildes/tildes/templates/macros/topics.jinja2 b/tildes/tildes/templates/macros/topics.jinja2 index af740a7..b7e38fb 100644 --- a/tildes/tildes/templates/macros/topics.jinja2 +++ b/tildes/tildes/templates/macros/topics.jinja2 @@ -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) %} {% endif %} +
{% endmacro %} {% macro topic_classes(topic) %} diff --git a/tildes/tildes/templates/topic.jinja2 b/tildes/tildes/templates/topic.jinja2 index dc678a6..bfbd101 100644 --- a/tildes/tildes/templates/topic.jinja2 +++ b/tildes/tildes/templates/topic.jinja2 @@ -30,7 +30,7 @@ {% endblock %} {% block content %} -
+
{{ topic_voting(topic) }}

{{ topic.title }}

@@ -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 {% 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 {% 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 {% 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 {% 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 @@ -208,7 +208,7 @@ {% endif %} -
+
{% if topic.is_locked %}
This topic is locked. New comments can not be posted.