From 4e309b67f00b135d0d99eaab27d2cda7350e7766 Mon Sep 17 00:00:00 2001 From: Dani Herrero Date: Tue, 3 Oct 2017 09:16:02 +0200 Subject: [PATCH] bug fixed on LoadMore action in autocomplete --- client/core/src/drop-down/drop-down.html | 9 ++++++++- client/core/src/drop-down/drop-down.js | 7 +++++++ client/core/src/locale/es.json | 3 ++- services/client/common/models/address.js | 17 +++++++++-------- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/client/core/src/drop-down/drop-down.html b/client/core/src/drop-down/drop-down.html index c65feac28..61a16921f 100644 --- a/client/core/src/drop-down/drop-down.html +++ b/client/core/src/drop-down/drop-down.html @@ -16,7 +16,14 @@
{{item.name}}
- + \ No newline at end of file diff --git a/client/core/src/drop-down/drop-down.js b/client/core/src/drop-down/drop-down.js index 465137070..7c332fd94 100644 --- a/client/core/src/drop-down/drop-down.js +++ b/client/core/src/drop-down/drop-down.js @@ -135,6 +135,13 @@ export default class DropDown { } } + loadItems() { + if (this.showLoadMore && this.loadMore) { + this.loadMore(); + } + this.show = true; + } + $onInit() { if (this.parent) this.parent.addEventListener('keydown', e => this.onKeydown(e)); diff --git a/client/core/src/locale/es.json b/client/core/src/locale/es.json index 3ce07bc50..8a44ead1c 100644 --- a/client/core/src/locale/es.json +++ b/client/core/src/locale/es.json @@ -6,5 +6,6 @@ "Save": "Guardar", "Add": "Añadir", "Search": "Buscar", - "Load More": "Cargar más" + "Show More": "Ver más", + "No more results" : "No hay más resultados" } \ No newline at end of file diff --git a/services/client/common/models/address.js b/services/client/common/models/address.js index 6e85ed7f2..569882208 100644 --- a/services/client/common/models/address.js +++ b/services/client/common/models/address.js @@ -1,7 +1,7 @@ module.exports = function(Address) { Address.validate('default',isEnabled,{message: 'No se puede poner predeterminado un consignatario desactivado'}); function isEnabled(err) { - if (!this.isEnabled && this.default) err(); + if (!this.isEnabled && this.isDefaultAddress) err(); } Address.beforeRemote('create',function(ctx, modelInstance, next){ @@ -10,10 +10,11 @@ module.exports = function(Address) { }); function create(data, next){ - if(data.default){ - removeAllDefault(data.client); - } - next(); + if(data.isDefaultAddress){ + removeAllDefault(data.client, next); + } else { + next(); + } } Address.beforeRemote('prototype.patchAttributes',function(ctx, modelInstance, next){ @@ -42,10 +43,10 @@ module.exports = function(Address) { } function callbackGetAddress(ctx, newData, oldData, next){ - if (newData.default){ + if (newData.isDefaultAddress){ removeAllDefault(oldData.client, next); } - else if (oldData.default && newData.hasOwnProperty('default') && !newData.default) + else if (oldData.isDefaultAddress && newData.hasOwnProperty('isDefaultAddress') && !newData.isDefaultAddress) next(generateErrorDefaultAddress()); else next(); @@ -59,7 +60,7 @@ module.exports = function(Address) { } function removeAllDefault(client, next){ - Address.updateAll({clientFk: client.id, default: true}, {default: false}, next); + Address.updateAll({clientFk: client.id, isDefaultAddress: true}, {isDefaultAddress: false}, next); } function generateErrorDefaultAddress(){