Skip to content

Commit

Permalink
fix: closes #12474, fix search dropdown on mobile for merge
Browse files Browse the repository at this point in the history
add remove topic buttons
  • Loading branch information
barisusakli committed Apr 22, 2024
1 parent d85aae3 commit ce03680
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 16 deletions.
4 changes: 2 additions & 2 deletions install/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@
"nodebb-plugin-ntfy": "1.7.4",
"nodebb-plugin-spam-be-gone": "2.2.2",
"nodebb-rewards-essentials": "1.0.0",
"nodebb-theme-harmony": "1.2.49",
"nodebb-theme-harmony": "1.2.50",
"nodebb-theme-lavender": "7.1.8",
"nodebb-theme-peace": "2.2.4",
"nodebb-theme-persona": "13.3.14",
"nodebb-theme-persona": "13.3.15",
"nodebb-widget-essentials": "7.0.15",
"nodemailer": "6.9.13",
"nprogress": "0.2.0",
Expand Down
29 changes: 26 additions & 3 deletions public/src/client/topic/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,22 @@ define('forum/topic/merge', ['search', 'alerts', 'api'], function (search, alert
searchOptions: {
in: 'titles',
},
dropdown: {
maxWidth: '400px',
maxHeight: '350px',
},
});
modal.on('click', '[data-tid]', function () {
if ($(this).attr('data-tid')) {
Merge.addTopic($(this).attr('data-tid'));
const addTid = $(this).attr('data-tid');
if (addTid) {
Merge.addTopic(addTid);
}
return false;
});
modal.on('click', '[data-remove-tid]', function () {
const removeTid = $(this).attr('data-remove-tid');
if (removeTid) {
Merge.removeTopic(removeTid);
}
return false;
});
Expand All @@ -65,6 +77,14 @@ define('forum/topic/merge', ['search', 'alerts', 'api'], function (search, alert
}).catch(alerts.error);
};

Merge.removeTopic = function (tid) {
if (selectedTids[tid]) {
delete selectedTids[tid];
}
checkButtonEnable();
showTopicsSelected();
};

function onTopicClicked(ev) {
if (!modal) {
return;
Expand Down Expand Up @@ -116,10 +136,13 @@ define('forum/topic/merge', ['search', 'alerts', 'api'], function (search, alert
topics: topics,
}, function (html) {
modal.find('.topics-section').html(html.find('.topics-section').html());
modal.find('.merge-main-topic-select').html(html.find('.merge-main-topic-select').html());
modal.find('.merge-main-topic-select').html(
html.find('.merge-main-topic-select').html()
);
});
} else {
modal.find('.topics-section').translateHtml('[[error:no-topics-selected]]');
modal.find('.merge-main-topic-select').html('');
}
}

Expand Down
1 change: 1 addition & 0 deletions public/src/modules/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ define('search', [
text.slice(start, start + 80) +
(text.length - start > 80 ? '...' : ''));
});
data.dropdown = { maxWidth: '400px', maxHeight: '500px', ...options.dropdown };
app.parseAndTranslate('partials/quick-search-results', data, function (html) {
if (html.length) {
html.find('.timeago').timeago();
Expand Down
27 changes: 16 additions & 11 deletions src/views/modals/merge-topic.tpl
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<div class="tool-modal d-flex">
<div class="position-relative">
<div class="quick-search-container dropdown-menu d-block p-2 hidden" style="right: 10px;">
<div class="text-center loading-indicator"><i class="fa fa-spinner fa-spin"></i></div>
<div class="quick-search-results-container"></div>
</div>
</div>


<div class="card shadow">
<h5 class="card-header">[[topic:thread-tools.merge-topics]]</h5>
Expand All @@ -17,13 +12,23 @@
<input class="form-control topic-search-input" type="text">
<span class="input-group-text"><i class="fa fa-search"></i></span>
</div>

<div class="quick-search-container dropdown-menu d-block p-2 hidden">
<div class="text-center loading-indicator"><i class="fa fa-spinner fa-spin"></i></div>
<div class="quick-search-results-container"></div>
</div>
</p>

<p><strong>[[topic:merge-topic-list-title]]</strong></p>
<ul class="topics-section">
{{{each topics}}}
<li><a href="{config.relative_path}/topic/{topics.tid}"><strong>{topics.title}</strong></a></li>
{{{end}}}
{{{ each topics }}}
<li class="mb-1">
<div class="d-flex justify-content-between align-items-center gap-2">
<a href="{config.relative_path}/topic/{./tid}"><strong>{./title}</strong></a>
<button class="btn btn-sm btn-light" data-remove-tid="{./tid}"><i class="fa fa-times text-danger"></i></button>
</div>
</li>
{{{ end }}}
</ul>
<p>
<strong>[[topic:merge-options]]</strong>
Expand All @@ -34,9 +39,9 @@
</p>
<p>
<select class="form-select merge-main-topic-select">
{{{each topics}}}
{{{ each topics }}}
<option value="{topics.tid}">{topics.title}</option>
{{{end}}}
{{{ end }}}
</select>
</p>
<p>
Expand Down

0 comments on commit ce03680

Please sign in to comment.