autocomplete bug fixed in loadMore button

This commit is contained in:
dherrero 2017-10-10 12:56:03 +02:00
parent bf903d8b1e
commit 1bc3a0bdd7
4 changed files with 13 additions and 4 deletions

View File

@ -7,6 +7,7 @@
filter="true"
load-more="$ctrl.getItems()"
show-load-more="$ctrl.maxRow"
remove-load-more="$ctrl.removeLoadMore"
filter-action="$ctrl.findItems(search)"
item-width="$ctrl.width"
multiple="$ctrl.multiple"

View File

@ -23,6 +23,7 @@ class Autocomplete extends Component {
this.displayValueMultiCheck = [];
this._multiField = [];
this.readonly = true;
this.removeLoadMore = false;
}
get showDropDown() {
@ -229,9 +230,11 @@ class Autocomplete extends Component {
let json = JSON.stringify(filter);
this.removeLoadMore = false;
this.$http.get(`${this.url}?filter=${json}`).then(
json => {
if (json.data.length)
if (json.data.length) {
json.data.forEach(
el => {
if (this.multiple) {
@ -240,8 +243,12 @@ class Autocomplete extends Component {
this.items.push(el);
}
);
else
if (filter.skip === 0 && this.maxRow && json.data.length < this.maxRow) {
this.removeLoadMore = true;
}
} else {
this.maxRow = false;
}
}
);
}

View File

@ -17,7 +17,7 @@
<div ng-transclude="vnItem">{{item.name}}</div>
</li>
<li
ng-if="$ctrl.loadMore"
ng-if="$ctrl.loadMore&&!$ctrl.removeLoadMore"
class="dropdown__loadMore"
tabIndex="-1"
ng-class="{'active': $ctrl.itemsFiltered.length === $ctrl.activeOption, 'noMore' : !$ctrl.showLoadMore}"

View File

@ -57,7 +57,7 @@ export default class DropDown {
this.$timeout(() => {
this._activeOption = value;
// AutoLoad items with "scroll" (1st version):
if (value && value >= this.items.length - 3) {
if (value && value >= this.items.length - 3 && !this.removeLoadMore) {
this.loadItems();
}
});
@ -174,6 +174,7 @@ module.component('vnDropDown', {
selected: '=',
search: '=?',
loadMore: '&?',
removeLoadMore: '<?',
filterAction: '&?',
showLoadMore: '<?',
top: '<?',