Node.js based forum software built for the modern web
fix: closes #13666, update category label
Barış Soner Uşaklı193aaf55d5e2
diff --git a/public/src/client/category/tools.js b/public/src/client/category/tools.jsindex b372d7a2f6..42160e6e6a 100644--- a/public/src/client/category/tools.js+++ b/public/src/client/category/tools.js@@ -284,8 +284,20 @@ define('forum/category/tools', [topic.find('[component="topic/locked"]').toggleClass('hidden', !data.isLocked);}- function onTopicMoved(data) {- getTopicEl(data.tid).remove();+ async function onTopicMoved(data) {+ 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) {diff --git a/public/src/modules/helpers.common.js b/public/src/modules/helpers.common.jsindex 1350ff4ce7..a4b77c0802 100644--- a/public/src/modules/helpers.common.js+++ b/public/src/modules/helpers.common.js@@ -113,7 +113,7 @@ module.exports = function (utils, Benchpress, relative_path) {}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.name}</${tag}>`;diff --git a/src/api/topics.js b/src/api/topics.jsindex 91e0882db4..80f2b28cb7 100644--- a/src/api/topics.js+++ b/src/api/topics.js@@ -309,6 +309,7 @@ topicsAPI.move = async (caller, { tid, cid }) => {throw new Error('[[error:no-privileges]]');}const topicData = await topics.getTopicFields(tid, ['tid', 'cid', 'mainPid', 'slug', 'deleted']);+ topicData.toCid = cid;if (!cids.includes(topicData.cid)) {cids.push(topicData.cid);}