autocomplete bug fixed in loadMore button
This commit is contained in:
parent
bf903d8b1e
commit
1bc3a0bdd7
|
@ -7,6 +7,7 @@
|
||||||
filter="true"
|
filter="true"
|
||||||
load-more="$ctrl.getItems()"
|
load-more="$ctrl.getItems()"
|
||||||
show-load-more="$ctrl.maxRow"
|
show-load-more="$ctrl.maxRow"
|
||||||
|
remove-load-more="$ctrl.removeLoadMore"
|
||||||
filter-action="$ctrl.findItems(search)"
|
filter-action="$ctrl.findItems(search)"
|
||||||
item-width="$ctrl.width"
|
item-width="$ctrl.width"
|
||||||
multiple="$ctrl.multiple"
|
multiple="$ctrl.multiple"
|
||||||
|
|
|
@ -23,6 +23,7 @@ class Autocomplete extends Component {
|
||||||
this.displayValueMultiCheck = [];
|
this.displayValueMultiCheck = [];
|
||||||
this._multiField = [];
|
this._multiField = [];
|
||||||
this.readonly = true;
|
this.readonly = true;
|
||||||
|
this.removeLoadMore = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
get showDropDown() {
|
get showDropDown() {
|
||||||
|
@ -229,9 +230,11 @@ class Autocomplete extends Component {
|
||||||
|
|
||||||
let json = JSON.stringify(filter);
|
let json = JSON.stringify(filter);
|
||||||
|
|
||||||
|
this.removeLoadMore = false;
|
||||||
|
|
||||||
this.$http.get(`${this.url}?filter=${json}`).then(
|
this.$http.get(`${this.url}?filter=${json}`).then(
|
||||||
json => {
|
json => {
|
||||||
if (json.data.length)
|
if (json.data.length) {
|
||||||
json.data.forEach(
|
json.data.forEach(
|
||||||
el => {
|
el => {
|
||||||
if (this.multiple) {
|
if (this.multiple) {
|
||||||
|
@ -240,8 +243,12 @@ class Autocomplete extends Component {
|
||||||
this.items.push(el);
|
this.items.push(el);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
else
|
if (filter.skip === 0 && this.maxRow && json.data.length < this.maxRow) {
|
||||||
|
this.removeLoadMore = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
this.maxRow = false;
|
this.maxRow = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<div ng-transclude="vnItem">{{item.name}}</div>
|
<div ng-transclude="vnItem">{{item.name}}</div>
|
||||||
</li>
|
</li>
|
||||||
<li
|
<li
|
||||||
ng-if="$ctrl.loadMore"
|
ng-if="$ctrl.loadMore&&!$ctrl.removeLoadMore"
|
||||||
class="dropdown__loadMore"
|
class="dropdown__loadMore"
|
||||||
tabIndex="-1"
|
tabIndex="-1"
|
||||||
ng-class="{'active': $ctrl.itemsFiltered.length === $ctrl.activeOption, 'noMore' : !$ctrl.showLoadMore}"
|
ng-class="{'active': $ctrl.itemsFiltered.length === $ctrl.activeOption, 'noMore' : !$ctrl.showLoadMore}"
|
||||||
|
|
|
@ -57,7 +57,7 @@ export default class DropDown {
|
||||||
this.$timeout(() => {
|
this.$timeout(() => {
|
||||||
this._activeOption = value;
|
this._activeOption = value;
|
||||||
// AutoLoad items with "scroll" (1st version):
|
// AutoLoad items with "scroll" (1st version):
|
||||||
if (value && value >= this.items.length - 3) {
|
if (value && value >= this.items.length - 3 && !this.removeLoadMore) {
|
||||||
this.loadItems();
|
this.loadItems();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -174,6 +174,7 @@ module.component('vnDropDown', {
|
||||||
selected: '=',
|
selected: '=',
|
||||||
search: '=?',
|
search: '=?',
|
||||||
loadMore: '&?',
|
loadMore: '&?',
|
||||||
|
removeLoadMore: '<?',
|
||||||
filterAction: '&?',
|
filterAction: '&?',
|
||||||
showLoadMore: '<?',
|
showLoadMore: '<?',
|
||||||
top: '<?',
|
top: '<?',
|
||||||
|
|
Loading…
Reference in New Issue