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