Merge branch 'dev' of https://git.verdnatura.es/salix into dev
* 'dev' of https://git.verdnatura.es/salix: bug fixed on LoadMore action in autocomplete
This commit is contained in:
commit
7d1bc60112
|
@ -16,7 +16,14 @@
|
|||
<input type="checkbox" ng-checked="item.checked" ng-if="$ctrl.multiple">
|
||||
<div ng-transclude="vnItem">{{item.name}}</div>
|
||||
</li>
|
||||
<li ng-if="$ctrl.showLoadMore" class="dropdown__loadMore" tabIndex="-1" ng-class="{'active': $ctrl.itemsFiltered.length === $ctrl.activeOption}" ng-click="$ctrl.loadMore();$ctrl.show = true;" translate="Load More"></li>
|
||||
<li
|
||||
ng-if="$ctrl.loadMore"
|
||||
class="dropdown__loadMore"
|
||||
tabIndex="-1"
|
||||
ng-class="{'active': $ctrl.itemsFiltered.length === $ctrl.activeOption}"
|
||||
ng-click="$ctrl.loadItems()"
|
||||
translate="{{$ctrl.showLoadMore ? 'Show More' : 'No more results'}}"
|
||||
></li>
|
||||
</ul>
|
||||
</vn-one>
|
||||
</vn-vertical>
|
|
@ -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));
|
||||
|
|
|
@ -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"
|
||||
}
|
|
@ -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(){
|
||||
|
|
Loading…
Reference in New Issue