Skip to content

Commit

Permalink
feat: switch to using topic/select component for merge
Browse files Browse the repository at this point in the history
automatically add the selected tids to the merge modal
  • Loading branch information
barisusakli committed Sep 9, 2020
1 parent 66ef90d commit f6d5646
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
9 changes: 8 additions & 1 deletion public/src/client/category/tools.js
Expand Up @@ -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);
});
}
});
});
});

Expand Down
10 changes: 8 additions & 2 deletions public/src/client/topic/merge.js
Expand Up @@ -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();

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f6d5646

Please sign in to comment.