new autoComplete option to custom filter
This commit is contained in:
parent
ed64c3b50a
commit
a84fc8c1b6
|
@ -28,7 +28,9 @@
|
||||||
show-field="name"
|
show-field="name"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
select-fields="surname"
|
select-fields="surname"
|
||||||
label="Salesperson">
|
label="Salesperson"
|
||||||
|
filter-search="{where: {or: [{name: {regexp: 'search'}}, {surname: {regexp: 'search'}}]}}"
|
||||||
|
>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-autocomplete vn-one
|
<vn-autocomplete vn-one
|
||||||
initial-data="$ctrl.client.contactChannel"
|
initial-data="$ctrl.client.contactChannel"
|
||||||
|
|
|
@ -191,10 +191,17 @@ class Autocomplete extends Component {
|
||||||
findItems(search) {
|
findItems(search) {
|
||||||
if (this.url && search && !this.finding) {
|
if (this.url && search && !this.finding) {
|
||||||
this.maxRow = false;
|
this.maxRow = false;
|
||||||
let filter = {where: {name: {regexp: search}}};
|
let filter = {};
|
||||||
if (this.filter && this.filter.where) {
|
if (this.filterSearch) {
|
||||||
Object.assign(filter.where, this.filter.where);
|
let toSearch = this.filterSearch.replace(/search/g, search);
|
||||||
|
filter = this.$scope.$eval(toSearch);
|
||||||
|
} else {
|
||||||
|
filter = {where: {name: {regexp: search}}};
|
||||||
|
if (this.filter && this.filter.where) {
|
||||||
|
Object.assign(filter.where, this.filter.where);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
filter.order = this.order;
|
||||||
let json = JSON.stringify(filter);
|
let json = JSON.stringify(filter);
|
||||||
this.finding = true;
|
this.finding = true;
|
||||||
this.$http.get(`${this.url}?filter=${json}`).then(
|
this.$http.get(`${this.url}?filter=${json}`).then(
|
||||||
|
@ -339,7 +346,8 @@ module.component('vnAutocomplete', {
|
||||||
label: '@',
|
label: '@',
|
||||||
multiple: '@?',
|
multiple: '@?',
|
||||||
order: '@?',
|
order: '@?',
|
||||||
filter: '<?'
|
filter: '<?',
|
||||||
|
filterSearch: '@?'
|
||||||
},
|
},
|
||||||
transclude: {
|
transclude: {
|
||||||
tplItem: '?tplItem'
|
tplItem: '?tplItem'
|
||||||
|
|
Loading…
Reference in New Issue