mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-01 21:30:30 +01:00
feat: switch to using topic/select component for merge
automatically add the selected tids to the merge modal
This commit is contained in:
@@ -113,8 +113,15 @@ define('forum/category/tools', [
|
||||
});
|
||||
|
||||
components.get('topic/merge').on('click', function () {
|
||||
var tids = topicSelect.getSelectedTids();
|
||||
require(['forum/topic/merge'], function (merge) {
|
||||
merge.init();
|
||||
merge.init(function () {
|
||||
if (tids.length) {
|
||||
tids.forEach(function (tid) {
|
||||
merge.addTopic(tid);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ define('forum/topic/merge', function () {
|
||||
|
||||
modal.find('.close,#merge_topics_cancel').on('click', closeModal);
|
||||
|
||||
$('#content').on('click', '[component="category"] [component="category/topic"] a', onTopicClicked);
|
||||
$('#content').on('click', '[component="topic/select"]', onTopicClicked);
|
||||
|
||||
showTopicsSelected();
|
||||
|
||||
@@ -69,6 +69,9 @@ define('forum/topic/merge', function () {
|
||||
};
|
||||
|
||||
function onTopicClicked(ev) {
|
||||
if (!modal) {
|
||||
return;
|
||||
}
|
||||
var tid = $(this).parents('[component="category/topic"]').attr('data-tid');
|
||||
Merge.addTopic(tid);
|
||||
|
||||
@@ -98,6 +101,9 @@ define('forum/topic/merge', function () {
|
||||
}
|
||||
|
||||
function showTopicsSelected() {
|
||||
if (!modal) {
|
||||
return;
|
||||
}
|
||||
var tids = Object.keys(selectedTids);
|
||||
tids.sort(function (a, b) {
|
||||
return a - b;
|
||||
@@ -134,7 +140,7 @@ define('forum/topic/merge', function () {
|
||||
modal = null;
|
||||
}
|
||||
selectedTids = {};
|
||||
$('#content').off('click', '[component="category"] [component="category/topic"] a', onTopicClicked);
|
||||
$('#content').off('click', '[component="topic/select"]', onTopicClicked);
|
||||
}
|
||||
|
||||
return Merge;
|
||||
|
||||
Reference in New Issue
Block a user