Browse Source

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.
merge-requests/126/merge
Deimos 4 years ago
parent
commit
dac8ec3a01
  1. 11
      tildes/scss/modules/_topic.scss
  2. 2
      tildes/tildes/templates/intercooler/topic_title_edit.jinja2
  3. 4
      tildes/tildes/templates/macros/comments.jinja2
  4. 16
      tildes/tildes/templates/macros/topics.jinja2
  5. 14
      tildes/tildes/templates/topic.jinja2

11
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;
}

2
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
>
<label class="form-label" for="title">Title:</label>

4
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</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 %}

16
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) %}
<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) %}

14
tildes/tildes/templates/topic.jinja2

@ -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>

Loading…
Cancel
Save