From 48034b234f531235bcc17169f1e5c80f6af1a1d5 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 12 Jun 2020 10:53:33 +0200 Subject: [PATCH] 2325 - Search address --- front/core/components/searchbar/searchbar.html | 2 +- front/core/components/searchbar/searchbar.js | 7 ++++++- modules/client/front/address/index/index.html | 11 ++++++++++- modules/client/front/address/index/index.js | 9 +++++++++ modules/client/front/address/index/index.spec.js | 14 ++++++++++++++ modules/client/front/address/locale/es.yml | 2 ++ modules/ticket/front/weekly/index.html | 1 + modules/ticket/front/weekly/locale/es.yml | 3 ++- 8 files changed, 45 insertions(+), 4 deletions(-) diff --git a/front/core/components/searchbar/searchbar.html b/front/core/components/searchbar/searchbar.html index 1de40fa231..b41c050ebe 100644 --- a/front/core/components/searchbar/searchbar.html +++ b/front/core/components/searchbar/searchbar.html @@ -1,7 +1,7 @@
+ + + + @@ -35,7 +44,7 @@ -
{{::address.nickname}}
+
{{::address.nickname}} - #{{::address.id}}
{{::address.street}}
{{::address.city}}, {{::address.province.name}}
diff --git a/modules/client/front/address/index/index.js b/modules/client/front/address/index/index.js index 19f3524fbb..6a9d7507b9 100644 --- a/modules/client/front/address/index/index.js +++ b/modules/client/front/address/index/index.js @@ -68,6 +68,15 @@ class Controller extends Section { return this.isDefaultAddress(b) - this.isDefaultAddress(a); }); } + + exprBuilder(param, value) { + switch (param) { + case 'search': + return /^\d+$/.test(value) + ? {id: value} + : {nickname: {like: `%${value}%`}}; + } + } } Controller.$inject = ['$element', '$scope']; diff --git a/modules/client/front/address/index/index.spec.js b/modules/client/front/address/index/index.spec.js index d53abe8bea..4240e86292 100644 --- a/modules/client/front/address/index/index.spec.js +++ b/modules/client/front/address/index/index.spec.js @@ -67,5 +67,19 @@ describe('Client', () => { expect(controller.addresses[0].id).toEqual(123); }); }); + + describe('exprBuilder()', () => { + it('should return a filter based on a search by id', () => { + const filter = controller.exprBuilder('search', '123'); + + expect(filter).toEqual({id: '123'}); + }); + + it('should return a filter based on a search by name', () => { + const filter = controller.exprBuilder('search', 'Bruce Wayne'); + + expect(filter).toEqual({nickname: {like: '%Bruce Wayne%'}}); + }); + }); }); }); diff --git a/modules/client/front/address/locale/es.yml b/modules/client/front/address/locale/es.yml index dc39175d60..06d9e76f7b 100644 --- a/modules/client/front/address/locale/es.yml +++ b/modules/client/front/address/locale/es.yml @@ -1,6 +1,8 @@ # Index Set as default: Establecer como predeterminado Active first to set as default: Active primero para marcar como predeterminado +Search by address: Buscar por consignatario +You can search by address id or name: Puedes buscar por el id o nombre del consignatario # Edit Enabled: Activo Is equalizated: Recargo de equivalencia diff --git a/modules/ticket/front/weekly/index.html b/modules/ticket/front/weekly/index.html index 8411d4f723..92ee644784 100644 --- a/modules/ticket/front/weekly/index.html +++ b/modules/ticket/front/weekly/index.html @@ -10,6 +10,7 @@ diff --git a/modules/ticket/front/weekly/locale/es.yml b/modules/ticket/front/weekly/locale/es.yml index fa40fe96b3..7c7c6a1399 100644 --- a/modules/ticket/front/weekly/locale/es.yml +++ b/modules/ticket/front/weekly/locale/es.yml @@ -2,4 +2,5 @@ Ticket ID: ID Ticket Weekly tickets: Tickets programados You are going to delete this weekly ticket: Vas a eliminar este ticket programado This ticket will be removed from weekly tickets! Continue anyway?: Este ticket se eliminará de tickets programados! ¿Continuar de todas formas? -Search weekly ticket by id or client id: Busca tickets programados por el identificador o el identificador del cliente \ No newline at end of file +Search weekly ticket by id or client id: Busca tickets programados por el identificador o el identificador del cliente +Search by weekly ticket: Buscar por tickets programados \ No newline at end of file