From ae7a8f12453c84d06bfb23db39ca20a17eff5d97 Mon Sep 17 00:00:00 2001 From: Juan Date: Tue, 3 Apr 2018 19:37:37 +0200 Subject: [PATCH] Bugs solved on method Client.activeSalesPerson() --- e2e/paths/client-module/02_edit_basic_data.spec.js | 2 +- .../common/methods/client/activeSalesPerson.js | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/e2e/paths/client-module/02_edit_basic_data.spec.js b/e2e/paths/client-module/02_edit_basic_data.spec.js index ea58176cf5..671f64fd0c 100644 --- a/e2e/paths/client-module/02_edit_basic_data.spec.js +++ b/e2e/paths/client-module/02_edit_basic_data.spec.js @@ -116,7 +116,7 @@ describe('Edit basicData path', () => { return nightmare .getInputValue(selectors.clientBasicData.salesPersonInput) .then(result => { - expect(result).toEqual('accessory accessory'); + expect(result).toEqual('accessory'); }); }); diff --git a/services/loopback/common/methods/client/activeSalesPerson.js b/services/loopback/common/methods/client/activeSalesPerson.js index 53e1769cbc..b5baa072f2 100644 --- a/services/loopback/common/methods/client/activeSalesPerson.js +++ b/services/loopback/common/methods/client/activeSalesPerson.js @@ -27,10 +27,16 @@ module.exports = Self => { let params = []; if (where) { - sqlWhere = `AND (em.firstName REGEXP ? OR em.name REGEXP ?)`; - let search = where.firstName.regexp; - params.push(search); - params.push(search); + if (where.firstName) { + sqlWhere = `AND (em.firstName REGEXP ? OR em.name REGEXP ?)`; + let search = where.firstName.regexp; + params.push(search); + params.push(search); + } + if (where.id) { + sqlWhere = `AND em.id = ?`; + params.push(where.id); + } } if (filter.limit) { sqlLimit = `LIMIT ?`;