[Posts] Add a set navbar button to remove the post from that said (#775)

This commit is contained in:
Cinder 2024-10-29 07:38:29 -07:00 committed by GitHub
parent 21c486a475
commit 7318b2ddcb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 3 deletions

View File

@ -1,4 +1,5 @@
import {SendQueue} from "./send_queue";
import Page from "./utility/page";
import LStorage from "./utility/storage";
let PostSet = {};
@ -175,10 +176,22 @@ PostSet.update_sets_menu = function () {
});
};
PostSet.initialize_remove_from_set_links = function () {
$("a.set-nav-remove-link").on("click", (event) => {
event.preventDefault();
const target = $(event.currentTarget);
const setID = target.data("setId");
const postID = target.data("postId");
PostSet.remove_post(setID, postID);
});
};
$(function () {
if ($("#c-posts").length && $("#a-show").length) {
PostSet.initialize_add_to_set_link();
}
if (!Page.matches("posts", "show")) return;
PostSet.initialize_add_to_set_link();
PostSet.initialize_remove_from_set_links();
});
export default PostSet;

View File

@ -26,6 +26,7 @@
<% end -%>
<span class="nav-name">
<a href="#" class="set-nav-remove-link" data-post-id="<%= post.id %>" data-set-id="<%= post_set.id %>" title="Remove from set"><i class="fas fa-times"></i></a>
<%= link_to("Set: #{post_set.name}", post_set_path(post_set), title: "page #{post_set.page_number(post.id)}/#{post_set.post_count}") -%>
</span>