Browse Source

fix: predefined filter in shared grid view

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/679/head
Pranav C 3 years ago
parent
commit
941b23fcc0
  1. 46
      packages/nocodb/src/lib/noco/meta/NcMetaMgrEE.ts

46
packages/nocodb/src/lib/noco/meta/NcMetaMgrEE.ts

@ -170,8 +170,50 @@ export default class NcMetaMgrEE extends NcMetaMgr {
where += req.query.where;
}
if (queryParams.where) {
where += where ? `~and(${queryParams.where})` : queryParams.where;
// todo: move this logic to a common library
const privateViewWhere = queryParams.filters?.reduce?.(
(condition, filt, i) => {
if (!i && !filt.logicOp) {
return condition;
}
if (!(filt.field && filt.op)) {
return condition;
}
condition += i ? `~${filt.logicOp}` : '';
switch (filt.op) {
case 'is equal':
return condition + `(${filt.field},eq,${filt.value})`;
case 'is not equal':
return condition + `~not(${filt.field},eq,${filt.value})`;
case 'is like':
return condition + `(${filt.field},like,%${filt.value}%)`;
case 'is not like':
return condition + `~not(${filt.field},like,%${filt.value}%)`;
case 'is empty':
return condition + `(${filt.field},in,)`;
case 'is not empty':
return condition + `~not(${filt.field},in,)`;
case 'is null':
return condition + `(${filt.field},is,null)`;
case 'is not null':
return condition + `~not(${filt.field},is,null)`;
case '<':
return condition + `(${filt.field},lt,${filt.value})`;
case '<=':
return condition + `(${filt.field},le,${filt.value})`;
case '>':
return condition + `(${filt.field},gt,${filt.value})`;
case '>=':
return condition + `(${filt.field},ge,${filt.value})`;
}
return condition;
},
''
);
if (privateViewWhere) {
where += where ? `~and(${privateViewWhere})` : privateViewWhere;
}
if (queryParams.sortList) {
sort.push(

Loading…
Cancel
Save