feat: add filter:categories.categorySearch

v1.18.x
Barış Soner Uşaklı 4 years ago
parent 3cc3ef6e70
commit be19f27f40

@ -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,
});

Loading…
Cancel
Save