mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
feat: add filter:categories.categorySearch
This commit is contained in:
@@ -66,9 +66,10 @@ define('categorySearch', function () {
|
||||
searchEl.find('input').off('keyup');
|
||||
});
|
||||
|
||||
function loadList(query, callback) {
|
||||
function loadList(search, callback) {
|
||||
socket.emit('categories.categorySearch', {
|
||||
query: query,
|
||||
search: search,
|
||||
query: utils.params(),
|
||||
parentCid: options.parentCid || 0,
|
||||
selectedCids: options.selectedCids,
|
||||
privilege: options.privilege,
|
||||
|
||||
@@ -6,6 +6,7 @@ const meta = require('../../meta');
|
||||
const categories = require('../../categories');
|
||||
const privileges = require('../../privileges');
|
||||
const controllersHelpers = require('../../controllers/helpers');
|
||||
const plugins = require('../../plugins');
|
||||
|
||||
module.exports = function (SocketCategories) {
|
||||
// used by categorySearch module
|
||||
@@ -17,7 +18,7 @@ module.exports = function (SocketCategories) {
|
||||
state => categories.watchStates[state]
|
||||
);
|
||||
|
||||
if (data.query) {
|
||||
if (data.search) {
|
||||
({ cids, matchedCids } = await findMatchedCids(socket.uid, data));
|
||||
} else {
|
||||
cids = await loadCids(socket.uid, data.parentCid);
|
||||
@@ -40,13 +41,18 @@ module.exports = function (SocketCategories) {
|
||||
category.match = true;
|
||||
}
|
||||
});
|
||||
return categoriesData;
|
||||
const result = await plugins.hooks.fire('filter:categories.categorySearch', {
|
||||
categories: categoriesData,
|
||||
...data,
|
||||
uid: socket.uid,
|
||||
})
|
||||
return result.categories;
|
||||
};
|
||||
|
||||
async function findMatchedCids(uid, data) {
|
||||
const result = await categories.search({
|
||||
uid: uid,
|
||||
query: data.query,
|
||||
query: data.search,
|
||||
paginate: false,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user