mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46: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');
|
searchEl.find('input').off('keyup');
|
||||||
});
|
});
|
||||||
|
|
||||||
function loadList(query, callback) {
|
function loadList(search, callback) {
|
||||||
socket.emit('categories.categorySearch', {
|
socket.emit('categories.categorySearch', {
|
||||||
query: query,
|
search: search,
|
||||||
|
query: utils.params(),
|
||||||
parentCid: options.parentCid || 0,
|
parentCid: options.parentCid || 0,
|
||||||
selectedCids: options.selectedCids,
|
selectedCids: options.selectedCids,
|
||||||
privilege: options.privilege,
|
privilege: options.privilege,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ const meta = require('../../meta');
|
|||||||
const categories = require('../../categories');
|
const categories = require('../../categories');
|
||||||
const privileges = require('../../privileges');
|
const privileges = require('../../privileges');
|
||||||
const controllersHelpers = require('../../controllers/helpers');
|
const controllersHelpers = require('../../controllers/helpers');
|
||||||
|
const plugins = require('../../plugins');
|
||||||
|
|
||||||
module.exports = function (SocketCategories) {
|
module.exports = function (SocketCategories) {
|
||||||
// used by categorySearch module
|
// used by categorySearch module
|
||||||
@@ -17,7 +18,7 @@ module.exports = function (SocketCategories) {
|
|||||||
state => categories.watchStates[state]
|
state => categories.watchStates[state]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (data.query) {
|
if (data.search) {
|
||||||
({ cids, matchedCids } = await findMatchedCids(socket.uid, data));
|
({ cids, matchedCids } = await findMatchedCids(socket.uid, data));
|
||||||
} else {
|
} else {
|
||||||
cids = await loadCids(socket.uid, data.parentCid);
|
cids = await loadCids(socket.uid, data.parentCid);
|
||||||
@@ -40,13 +41,18 @@ module.exports = function (SocketCategories) {
|
|||||||
category.match = true;
|
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) {
|
async function findMatchedCids(uid, data) {
|
||||||
const result = await categories.search({
|
const result = await categories.search({
|
||||||
uid: uid,
|
uid: uid,
|
||||||
query: data.query,
|
query: data.search,
|
||||||
paginate: false,
|
paginate: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user