tagid instead of tagname
This commit is contained in:
parent
d71eece80e
commit
9a3b494a94
@ -46,10 +46,10 @@ const flash = ({ type, msg }) => {
|
||||
e.preventDefault();
|
||||
if(!confirm("Do you really want to delete this tag?"))
|
||||
return;
|
||||
const tag = e.target.parentElement.innerText.slice(0, -2);
|
||||
if(!tags.includes(tag))
|
||||
return alert("wtf");
|
||||
const res = await deleteTag(postid, tag);
|
||||
const tagid = +e.target.parentElement.dataset.tagid;
|
||||
/*if(!tags.includes(tag))
|
||||
return alert("wtf");*/
|
||||
const res = await deleteTag(postid, tagid);
|
||||
if(!res.success)
|
||||
return alert("uff");
|
||||
tags = res.tags.map(t => t.tag);
|
||||
@ -73,9 +73,9 @@ const flash = ({ type, msg }) => {
|
||||
tag: tag
|
||||
})).json();
|
||||
|
||||
const deleteTag = async (postid, tag) => await (await post("/api/v2/admin/tags/delete", {
|
||||
const deleteTag = async (postid, tagid) => await (await post("/api/v2/admin/tags/delete", {
|
||||
postid: postid,
|
||||
tag: tag
|
||||
tagid: tagid
|
||||
})).json();
|
||||
|
||||
const renderTags = _tags => {
|
||||
@ -85,11 +85,13 @@ const flash = ({ type, msg }) => {
|
||||
a.href = `/tag/${tag.tag}`;
|
||||
a.target = "_blank";
|
||||
a.style = "color: inherit !important";
|
||||
a.innerText = tag.tag;
|
||||
a.innerHTML = tag.tag;
|
||||
|
||||
const span = document.createElement("span");
|
||||
span.classList.add("badge", "badge-light", "mr-2");
|
||||
span.title = tag.user;
|
||||
span.dataset.tagid = tag.id;
|
||||
|
||||
if(tag.tag == "sfw") {
|
||||
span.classList.remove("badge-light");
|
||||
span.classList.add("badge-success");
|
||||
|
@ -136,7 +136,7 @@ export default (router, tpl) => {
|
||||
});
|
||||
|
||||
group.post(/\/admin\/tags\/delete$/, auth, async (req, res) => {
|
||||
if(!req.post.postid || !req.post.tag) {
|
||||
if(!req.post.postid || !req.post.tagid) {
|
||||
return res.reply({ body: JSON.stringify({
|
||||
success: false,
|
||||
msg: "missing postid or tag"
|
||||
@ -144,15 +144,14 @@ export default (router, tpl) => {
|
||||
}
|
||||
|
||||
const postid = +req.post.postid;
|
||||
const tag = req.post.tag;
|
||||
const tagid = +req.post.tagid;
|
||||
|
||||
const tags = await lib.getTags(postid);
|
||||
|
||||
const tagid = tags.filter(t => t.tag === tag)[0]?.id ?? null;
|
||||
if(!tagid || tagid?.length === 0) {
|
||||
const tagcheck = tags.filter(t => t.id === tagid)[0]?.id ?? null;
|
||||
if(!tagcheck || !tagid || tagid?.length === 0) {
|
||||
return res.reply({ body: JSON.stringify({
|
||||
success: false,
|
||||
tag: tag,
|
||||
msg: "tag is not assigned",
|
||||
tags: await lib.getTags(postid)
|
||||
})});
|
||||
@ -165,7 +164,6 @@ export default (router, tpl) => {
|
||||
|
||||
return res.reply({ body: JSON.stringify({
|
||||
success: reply,
|
||||
tag: tag,
|
||||
tagid: tagid,
|
||||
tags: await lib.getTags(postid)
|
||||
})});
|
||||
|
Loading…
Reference in New Issue
Block a user