Filter changes
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
8daa3ae89c
commit
f56b0607ee
|
@ -690,9 +690,11 @@ INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `life`,`workerFk
|
|||
|
||||
INSERT INTO `vn`.`ink`(`id`, `name`, `picture`, `showOrder`)
|
||||
VALUES
|
||||
('YEL', 'Yellow', 1, 1),
|
||||
('BLU', 'Blue', 1, 2),
|
||||
('RED', 'Red', 1, 3);
|
||||
('YEL', 'Yellow', 1, 1),
|
||||
('BLU', 'Blue', 1, 2),
|
||||
('RED', 'Red', 1, 3),
|
||||
('SILVER', 'Silver', 1, 4),
|
||||
('BROWN', 'Brown', 1, 5);
|
||||
|
||||
INSERT INTO `vn`.`origin`(`id`,`code`, `name`)
|
||||
VALUES
|
||||
|
|
|
@ -22,8 +22,8 @@ module.exports = Self => {
|
|||
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string'
|
||||
},
|
||||
{
|
||||
arg: 'tags',
|
||||
type: ['Object'],
|
||||
arg: 'tagGroups',
|
||||
type: [['Object']],
|
||||
description: 'Filter by tag'
|
||||
},
|
||||
],
|
||||
|
@ -37,7 +37,7 @@ module.exports = Self => {
|
|||
},
|
||||
});
|
||||
|
||||
Self.catalogFilter = async(orderFk, orderBy, filter, tags) => {
|
||||
Self.catalogFilter = async(orderFk, orderBy, filter, tagGroups) => {
|
||||
let conn = Self.dataSource.connector;
|
||||
const stmts = [];
|
||||
let stmt;
|
||||
|
@ -55,10 +55,15 @@ module.exports = Self => {
|
|||
JOIN vn.itemType it ON it.id = i.typeFk
|
||||
JOIN vn.itemCategory ic ON ic.id = it.categoryFk`);
|
||||
|
||||
console.log(tagGroups);
|
||||
// Filter by tag
|
||||
if (tags) {
|
||||
let i = 1;
|
||||
for (const tag of tags) {
|
||||
if (tagGroups) {
|
||||
/* for (const [group, i] of tagGroups.entries()) {
|
||||
for (const tag of group)
|
||||
console.log(tag);
|
||||
}
|
||||
*/
|
||||
/* for (const tag of tags) {
|
||||
const tAlias = `it${i++}`;
|
||||
|
||||
if (tag.tagFk) {
|
||||
|
@ -68,6 +73,19 @@ module.exports = Self => {
|
|||
AND ${tAlias}.value LIKE ?`,
|
||||
params: [tag.tagFk, `%${tag.value}%`],
|
||||
});
|
||||
// Convertir:
|
||||
JOIN vn.itemTag it1 ON it1.itemFk = i.id
|
||||
AND (
|
||||
(it1.tagFk = ? AND it1.value LIKE ?)
|
||||
OR (it1.tagFk = ? AND it1.value LIKE ?)
|
||||
OR (it1.tagFk = ? AND it1.value LIKE ?)
|
||||
)
|
||||
JOIN vn.itemTag it2 ON it2.itemFk = i.id
|
||||
AND (
|
||||
(it2.tagFk = ? AND it2.value LIKE ?)
|
||||
OR (it2.tagFk = ? AND it2.value LIKE ?)
|
||||
OR (it2.tagFk = ? AND it2.value LIKE ?)
|
||||
)
|
||||
} else {
|
||||
stmt.merge({
|
||||
sql: `JOIN vn.itemTag ${tAlias} ON ${tAlias}.itemFk = i.id
|
||||
|
@ -75,7 +93,7 @@ module.exports = Self => {
|
|||
params: [`%${tag.value}%`],
|
||||
});
|
||||
}
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
||||
stmt.merge(conn.makeWhere(filter.where));
|
||||
|
|
|
@ -70,18 +70,6 @@
|
|||
tabindex="-1">
|
||||
</vn-icon-button>
|
||||
</vn-horizontal>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<vn-horizontal class="vn-mt-lg">
|
||||
<vn-submit label="Search"></vn-submit>
|
||||
</vn-horizontal>
|
||||
|
|
|
@ -6,7 +6,8 @@ class Controller extends Section {
|
|||
constructor($element, $) {
|
||||
super($element, $);
|
||||
this.itemTypes = [];
|
||||
this._tags = [];
|
||||
// this._tags = [];
|
||||
this._tagGroups = [];
|
||||
|
||||
// Static autocomplete data
|
||||
this.orderWays = [
|
||||
|
@ -54,8 +55,8 @@ class Controller extends Section {
|
|||
if (this.$params.typeId)
|
||||
this.typeId = parseInt(this.$params.typeId);
|
||||
|
||||
if (this.$params.tags)
|
||||
this.tags = JSON.parse(this.$params.tags);
|
||||
/* if (this.$params.tags)
|
||||
this.tags = JSON.parse(this.$params.tags); */
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -83,8 +84,8 @@ class Controller extends Section {
|
|||
|
||||
this.updateStateParams();
|
||||
|
||||
if (this.tags.length > 0)
|
||||
this.applyFilters();
|
||||
/* if (this.tags.length > 0)
|
||||
this.applyFilters(); */
|
||||
|
||||
if (value)
|
||||
this.updateItemTypes();
|
||||
|
@ -104,11 +105,26 @@ class Controller extends Section {
|
|||
|
||||
this.updateStateParams();
|
||||
|
||||
if (value || this.tags.length > 0)
|
||||
/* if (value || this.tags.length > 0)
|
||||
this.applyFilters(); */
|
||||
if (value)
|
||||
this.applyFilters();
|
||||
}
|
||||
|
||||
get tags() {
|
||||
get tagGroups() {
|
||||
return this._tagGroups;
|
||||
}
|
||||
|
||||
set tagGroups(value) {
|
||||
this._tagGroups = value;
|
||||
|
||||
this.updateStateParams();
|
||||
|
||||
if (value.length)
|
||||
this.applyFilters();
|
||||
}
|
||||
|
||||
/* get tags() {
|
||||
return this._tags;
|
||||
}
|
||||
|
||||
|
@ -119,7 +135,7 @@ class Controller extends Section {
|
|||
|
||||
if (value.length)
|
||||
this.applyFilters();
|
||||
}
|
||||
} */
|
||||
|
||||
/**
|
||||
* Get order way ASC/DESC
|
||||
|
@ -150,7 +166,9 @@ class Controller extends Section {
|
|||
* Apply order to model
|
||||
*/
|
||||
applyOrder() {
|
||||
if (this.typeId || this.tags.length > 0)
|
||||
/* if (this.typeId || this.tags.length > 0)
|
||||
this.$.model.addFilter(null, {orderBy: this.getOrderBy()}); */
|
||||
if (this.typeId)
|
||||
this.$.model.addFilter(null, {orderBy: this.getOrderBy()});
|
||||
}
|
||||
|
||||
|
@ -224,11 +242,11 @@ class Controller extends Section {
|
|||
|
||||
if (this.typeId)
|
||||
newFilter.typeFk = this.typeId;
|
||||
|
||||
console.log(this.tagGroups);
|
||||
newParams = {
|
||||
orderFk: this.$params.id,
|
||||
orderBy: this.getOrderBy(),
|
||||
tags: this.tags,
|
||||
tagGroups: this.tagGroups,
|
||||
};
|
||||
|
||||
return model.applyFilter({where: newFilter}, newParams);
|
||||
|
@ -243,11 +261,12 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
onPanelSubmit(filter) {
|
||||
console.log(filter);
|
||||
/* this.$.popover.hide();
|
||||
this.tags.push(filter);
|
||||
this.updateStateParams();
|
||||
this.applyFilters(); */
|
||||
this.$.popover.hide();
|
||||
if (filter.tags && filter.tags.length) {
|
||||
this.tagGroups.push(filter.tags);
|
||||
this.updateStateParams();
|
||||
this.applyFilters();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -264,7 +283,7 @@ class Controller extends Section {
|
|||
if (this.typeId)
|
||||
params.typeId = this.typeId;
|
||||
|
||||
params.tags = undefined;
|
||||
/* params.tags = undefined;
|
||||
if (this.tags.length) {
|
||||
const tags = [];
|
||||
for (let tag of this.tags) {
|
||||
|
@ -281,7 +300,7 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
params.tags = JSON.stringify(tags);
|
||||
}
|
||||
} */
|
||||
|
||||
this.$state.go(this.$state.current.name, params);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue