has visible disabled temporally
gitea/salix/master This commit looks good Details

This commit is contained in:
Gerard 2019-03-13 12:03:06 +01:00
parent 21c1b8f56f
commit fd4fe288a5
2 changed files with 19 additions and 14 deletions

View File

@ -89,12 +89,12 @@ module.exports = Self => {
}
});
filter = mergeFilters(ctx.args.filter, {where});
/* case 'hasVisible':
return value ? {'v.visible': {gt: 0}} : {'v.visible': {or: [{lte: 0}, {neq: null}]}}; */
filter = mergeFilters(ctx.args.filter, {where});
let stmts = [];
let stmt;
if (ctx.args.hasVisible === true)
stmts.push('CALL cache.visible_refresh(@visibleCalc, true, 1)');
stmt = new ParameterizedSQL(
`SELECT i.id, i.image, i.name, i.description,
@ -106,7 +106,7 @@ module.exports = Self => {
intr.description AS intrastat, i.stems,
ori.code AS origin, t.name AS type,
ic.name AS category, i.density,
b.grouping, b.packing, itn.code AS niche
b.grouping, b.packing, itn.code AS niche, @visibleCalc
FROM item i
LEFT JOIN itemType t ON t.id = i.typeFk
LEFT JOIN itemCategory ic ON ic.id = t.categoryFk
@ -120,13 +120,18 @@ module.exports = Self => {
LEFT JOIN itemPlacement itn ON itn.itemFk = i.id AND itn.warehouseFk = t.warehouseFk`
);
if (ctx.args.hasVisible === true) {
/* if (ctx.args.hasVisible !== undefined) {
stmts.push('CALL cache.visible_refresh(@visibleCalc, false, 1)');
stmts.push('CALL cache.visible_refresh(@visibleCalc, false, 44)');
let joinAvailable = new ParameterizedSQL(
`JOIN cache.visible v
ON v.item_id = i.id AND v.calc_id = @visibleCalc`
`LEFT JOIN cache.visible v
ON v.item_id = i.id`
);
stmt.merge(joinAvailable);
}
} */
/* where v.visible > 0
where v.visible <= 0 OR v.visible IS NULL
*/
if (ctx.args.tags) {
let i = 1;
@ -150,7 +155,12 @@ module.exports = Self => {
}
}
stmt.merge(conn.makeSuffix(filter));
stmt.merge(conn.makeWhere(filter.where));
/* if (ctx.args.hasVisible !== undefined)
stmt.merge(`GROUP BY i.id`);
*/
stmt.merge(conn.makePagination(filter));
let itemsIndex = stmts.push(stmt) - 1;
let sql = ParameterizedSQL.join(stmts, ';');

View File

@ -42,11 +42,6 @@
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-check
vn-one
label="With visible"
field="filter.hasVisible">
</vn-check>
<vn-check
vn-one
label="Active"