mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
@@ -7,6 +7,8 @@
|
|||||||
"privileges": "Privileges",
|
"privileges": "Privileges",
|
||||||
"back-to-categories": "Back to categories",
|
"back-to-categories": "Back to categories",
|
||||||
"name": "Category Name",
|
"name": "Category Name",
|
||||||
|
"handle": "Category Handle",
|
||||||
|
"handle.help": "Your category handle is used as a representation of this category across other networks, similar to a username. A category handle must not match an existing username or user group.",
|
||||||
"description": "Category Description",
|
"description": "Category Description",
|
||||||
"bg-color": "Background Colour",
|
"bg-color": "Background Colour",
|
||||||
"text-color": "Text Colour",
|
"text-color": "Text Colour",
|
||||||
|
|||||||
@@ -264,6 +264,7 @@
|
|||||||
|
|
||||||
"topic-event-unrecognized": "Topic event '%1' unrecognized",
|
"topic-event-unrecognized": "Topic event '%1' unrecognized",
|
||||||
|
|
||||||
|
"category.handle-taken": "Category handle is already taken, please choose another.",
|
||||||
"cant-set-child-as-parent": "Can't set child as parent category",
|
"cant-set-child-as-parent": "Can't set child as parent category",
|
||||||
"cant-set-self-as-parent": "Can't set self as parent category",
|
"cant-set-self-as-parent": "Can't set self as parent category",
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ module.exports = function (Categories) {
|
|||||||
return await updateTagWhitelist(cid, value);
|
return await updateTagWhitelist(cid, value);
|
||||||
} else if (key === 'name') {
|
} else if (key === 'name') {
|
||||||
return await updateName(cid, value);
|
return await updateName(cid, value);
|
||||||
|
} else if (key === 'handle') {
|
||||||
|
return await updateHandle(cid, value);
|
||||||
} else if (key === 'order') {
|
} else if (key === 'order') {
|
||||||
return await updateOrder(cid, value);
|
return await updateOrder(cid, value);
|
||||||
}
|
}
|
||||||
@@ -142,4 +144,22 @@ module.exports = function (Categories) {
|
|||||||
await db.sortedSetAdd('categories:name', 0, `${newName.slice(0, 200).toLowerCase()}:${cid}`);
|
await db.sortedSetAdd('categories:name', 0, `${newName.slice(0, 200).toLowerCase()}:${cid}`);
|
||||||
await db.setObjectField(`category:${cid}`, 'name', newName);
|
await db.setObjectField(`category:${cid}`, 'name', newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function updateHandle(cid, handle) {
|
||||||
|
const existing = await Categories.getCategoryField(cid, 'handle');
|
||||||
|
if (existing === handle) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const taken = await meta.slugTaken(handle);
|
||||||
|
if (taken) {
|
||||||
|
throw new Error('[[error:category.handle-taken]]');
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
db.setObjectField(`category:${cid}`, 'handle', handle),
|
||||||
|
db.sortedSetRemove('categoryhandle:cid', existing),
|
||||||
|
db.sortedSetAdd('categoryhandle:cid', cid, handle),
|
||||||
|
]);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -19,6 +19,16 @@
|
|||||||
<input id="cid-{category.cid}-name" type="text" class="form-control" data-name="name" value="{category.name}" />
|
<input id="cid-{category.cid}-name" type="text" class="form-control" data-name="name" value="{category.name}" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label" for="cid-{category.cid}-handle">
|
||||||
|
[[admin/manage/categories:handle]]
|
||||||
|
</label>
|
||||||
|
<input id="cid-{category.cid}-handle" type="text" class="form-control" data-name="handle" value="{category.handle}" />
|
||||||
|
<p class="form-text">
|
||||||
|
[[admin/manage/categories:handle.help]]
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label" for="cid-{category.cid}-description">
|
<label class="form-label" for="cid-{category.cid}-description">
|
||||||
[[admin/manage/categories:description]]
|
[[admin/manage/categories:description]]
|
||||||
|
|||||||
Reference in New Issue
Block a user