mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-15 21:10:22 +01:00
fix: closes #13666, update category label
on topic move if we are not on category page
This commit is contained in:
@@ -284,8 +284,20 @@ define('forum/category/tools', [
|
|||||||
topic.find('[component="topic/locked"]').toggleClass('hidden', !data.isLocked);
|
topic.find('[component="topic/locked"]').toggleClass('hidden', !data.isLocked);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onTopicMoved(data) {
|
async function onTopicMoved(data) {
|
||||||
getTopicEl(data.tid).remove();
|
if (ajaxify.data.template.category) {
|
||||||
|
getTopicEl(data.tid).remove();
|
||||||
|
} else {
|
||||||
|
const category = await api.get(`/categories/${data.toCid}`);
|
||||||
|
const html = await app.parseAndTranslate('partials/topics_list', {
|
||||||
|
topics: [{
|
||||||
|
...data,
|
||||||
|
category,
|
||||||
|
}],
|
||||||
|
});
|
||||||
|
const categoryLabelSelector = `[component="category/topic"][data-tid="${data.tid}"] [component="topic/category"]`;
|
||||||
|
$(categoryLabelSelector).replaceWith(html.find(categoryLabelSelector));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onTopicPurged(data) {
|
function onTopicPurged(data) {
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ module.exports = function (utils, Benchpress, relative_path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const href = tag === 'a' ? `href="${relative_path}/category/${category.slug}"` : '';
|
const href = tag === 'a' ? `href="${relative_path}/category/${category.slug}"` : '';
|
||||||
return `<${tag} ${href} class="badge px-1 text-truncate text-decoration-none ${className}" style="color: ${category.color};background-color: ${category.bgColor};border-color: ${category.bgColor}!important; max-width: 70vw;">
|
return `<${tag} ${href} component="topic/category" class="badge px-1 text-truncate text-decoration-none ${className}" style="color: ${category.color};background-color: ${category.bgColor};border-color: ${category.bgColor}!important; max-width: 70vw;">
|
||||||
${category.icon && category.icon !== 'fa-nbb-none' ? `<i class="fa fa-fw ${category.icon}"></i>` : ''}
|
${category.icon && category.icon !== 'fa-nbb-none' ? `<i class="fa fa-fw ${category.icon}"></i>` : ''}
|
||||||
${category.name}
|
${category.name}
|
||||||
</${tag}>`;
|
</${tag}>`;
|
||||||
|
|||||||
@@ -309,6 +309,7 @@ topicsAPI.move = async (caller, { tid, cid }) => {
|
|||||||
throw new Error('[[error:no-privileges]]');
|
throw new Error('[[error:no-privileges]]');
|
||||||
}
|
}
|
||||||
const topicData = await topics.getTopicFields(tid, ['tid', 'cid', 'mainPid', 'slug', 'deleted']);
|
const topicData = await topics.getTopicFields(tid, ['tid', 'cid', 'mainPid', 'slug', 'deleted']);
|
||||||
|
topicData.toCid = cid;
|
||||||
if (!cids.includes(topicData.cid)) {
|
if (!cids.includes(topicData.cid)) {
|
||||||
cids.push(topicData.cid);
|
cids.push(topicData.cid);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user