Merge branch 'dev' of https://git.verdnatura.es/salix into dev
This commit is contained in:
commit
b8979e76f5
|
@ -1,4 +1,4 @@
|
|||
<mg-ajax path="/client/api/Clients/filter" options="vnIndexNonAuto"></mg-ajax>
|
||||
<mg-ajax path="/ticket/api/Tickets/filter" options="vnIndexNonAuto"></mg-ajax>
|
||||
<div margin-medium>
|
||||
<div class="vn-list">
|
||||
<vn-card>
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
module.exports = Self => {
|
||||
Self.installMethod('filter', filterParams);
|
||||
|
||||
function filterParams(params) {
|
||||
let filters = {
|
||||
where: {},
|
||||
skip: (params.page - 1) * params.size,
|
||||
limit: params.size,
|
||||
order: params.order || 'created DESC'
|
||||
};
|
||||
|
||||
delete params.page;
|
||||
delete params.size;
|
||||
delete params.order;
|
||||
|
||||
if (params.search) {
|
||||
filters.where.and = [
|
||||
{
|
||||
or: [
|
||||
{id: params.search},
|
||||
{name: {regexp: params.search}}
|
||||
]
|
||||
}
|
||||
];
|
||||
delete params.search;
|
||||
}
|
||||
|
||||
Object.keys(params).forEach(
|
||||
key => {
|
||||
if (filters.where.and) {
|
||||
let filter = {};
|
||||
filter[key] = (key === 'nickname') ? {regexp: params[key]} : params[key];
|
||||
filters.where.and.push(filter);
|
||||
} else {
|
||||
filters.where[key] = (key === 'nickname') ? {regexp: params[key]} : params[key];
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return filters;
|
||||
}
|
||||
};
|
|
@ -2,4 +2,5 @@
|
|||
module.exports = function(Self) {
|
||||
require('../methods/ticket/change-time.js')(Self);
|
||||
require('../methods/ticket/change-worker.js')(Self);
|
||||
require('../methods/ticket/filter.js')(Self);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue