From a45a76018b90eb012428f7eb13df569ae7284f3c Mon Sep 17 00:00:00 2001 From: bernat Date: Thu, 14 Jan 2021 09:26:50 +0100 Subject: [PATCH] entry search panel changes --- e2e/helpers/selectors.js | 6 +++--- modules/entry/back/methods/entry/filter.js | 8 +++++++- modules/entry/front/main/index.html | 2 +- modules/entry/front/search-panel/index.html | 5 ++++- modules/entry/front/search-panel/locale/es.yml | 3 ++- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 8d40542b8..eb2dce909 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -721,9 +721,9 @@ export default { }, workerSummary: { header: 'vn-worker-summary h5', - id: 'vn-worker-summary vn-one:nth-child(1) > vn-label-value:nth-child(2) > section > span', - email: 'vn-worker-summary vn-one:nth-child(1) > vn-label-value:nth-child(3) > section > span', - department: 'vn-worker-summary vn-one:nth-child(1) > vn-label-value:nth-child(4) > section > span', + id: 'vn-worker-summary vn-one:nth-child(1) > vn-label-value:nth-child(3) > section > span', + email: 'vn-worker-summary vn-one:nth-child(1) > vn-label-value:nth-child(4) > section > span', + department: 'vn-worker-summary vn-one:nth-child(1) > vn-label-value:nth-child(5) > section > span', userId: 'vn-worker-summary vn-one:nth-child(2) > vn-label-value:nth-child(2) > section > span', userName: 'vn-worker-summary vn-one:nth-child(2) > vn-label-value:nth-child(3) > section > span', role: 'vn-worker-summary vn-one:nth-child(2) > vn-label-value:nth-child(4) > section > span', diff --git a/modules/entry/back/methods/entry/filter.js b/modules/entry/back/methods/entry/filter.js index daee3aa05..42dbe3078 100644 --- a/modules/entry/back/methods/entry/filter.js +++ b/modules/entry/back/methods/entry/filter.js @@ -93,7 +93,12 @@ module.exports = Self => { let where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'search': - return {'e.id': value}; + return /^\d+$/.test(value) + ? {'e.id': value} + : {or: [ + {'s.name': {like: `%${value}%`}}, + {'s.nickname': {like: `%${value}%`}} + ]}; case 'ref': param = `e.${param}`; return {[param]: {like: `%${value}%`}}; @@ -141,6 +146,7 @@ module.exports = Self => { e.invoiceInFk, t.landed, s.name AS supplierName, + s.nickname AS supplierAlias, co.code AS companyCode, cu.code AS currencyCode FROM vn.entry e diff --git a/modules/entry/front/main/index.html b/modules/entry/front/main/index.html index f19db2151..541a9948a 100644 --- a/modules/entry/front/main/index.html +++ b/modules/entry/front/main/index.html @@ -8,7 +8,7 @@ diff --git a/modules/entry/front/search-panel/index.html b/modules/entry/front/search-panel/index.html index cff555e91..074bb35fd 100644 --- a/modules/entry/front/search-panel/index.html +++ b/modules/entry/front/search-panel/index.html @@ -5,7 +5,7 @@ vn-one label="General search" ng-model="filter.search" - info="Search entries by id" + info="Search entries by id, supplier name or supplier alias" vn-focus> @@ -45,8 +45,11 @@ label="Supplier" ng-model="filter.supplierFk" url="Suppliers" + fields="['name','nickname']" + search-function="{or: [{nickname: {like: '%'+ $search +'%'}}, {name: {like: '%'+ $search +'%'}}]}" show-field="name" value-field="id"> + {{name}}: {{nickname}}