feat: closes #11424, add category selector to fork modal (#11491)

select the current category on open
This commit is contained in:
Barış Soner Uşaklı
2023-04-26 11:30:06 -04:00
committed by GitHub
parent d2066f59c0
commit 6b51dd5a2f
4 changed files with 31 additions and 6 deletions

View File

@@ -50,7 +50,7 @@ SocketTopics.createTopicFromPosts = async function (socket, data) {
throw new Error('[[error:invalid-data]]');
}
const result = await topics.createTopicFromPosts(socket.uid, data.title, data.pids, data.fromTid);
const result = await topics.createTopicFromPosts(socket.uid, data.title, data.pids, data.fromTid, data.cid);
await events.log({
type: `topic-fork`,
uid: socket.uid,

View File

@@ -9,7 +9,7 @@ const plugins = require('../plugins');
const meta = require('../meta');
module.exports = function (Topics) {
Topics.createTopicFromPosts = async function (uid, title, pids, fromTid) {
Topics.createTopicFromPosts = async function (uid, title, pids, fromTid, cid) {
if (title) {
title = title.trim();
}
@@ -27,7 +27,9 @@ module.exports = function (Topics) {
pids.sort((a, b) => a - b);
const mainPid = pids[0];
const cid = await posts.getCidByPid(mainPid);
if (!cid) {
cid = await posts.getCidByPid(mainPid);
}
const [postData, isAdminOrMod] = await Promise.all([
posts.getPostData(mainPid),

View File

@@ -10,7 +10,13 @@
<label class="form-label" for="fork-title"><strong>[[topic:title]]</strong></label>
<input id="fork-title" type="text" class="form-control" placeholder="[[topic:enter-new-topic-title]]">
</div>
<strong><span id="fork-pids"></span></strong>
<div class="mb-3">
<label class="form-label"><strong>[[category:category]]</strong></label>
<div>
<!-- IMPORT partials/category/selector-dropdown-right.tpl -->
</div>
</div>
<strong id="fork-pids"></strong>
</div>
<div class="card-footer text-end">
<button class="btn btn-link btn-sm" id="fork_thread_cancel">[[global:buttons.close]]</button>