File tree Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change 4848
4949<script >
5050import gql from ' graphql-tag' ;
51+ import _ from ' lodash' ;
5152
5253export default {
5354 name: ' Search' ,
@@ -114,7 +115,19 @@ export default {
114115 });
115116 }
116117 }
117- }
118+ },
119+ debouncedQuery: _ .debounce (async (val , self ) => {
120+ const result = await self .queryMunicipalities (val);
121+ self .municipalities = result .data .municipalities .edges ;
122+ self .municipalities .forEach ((item ) => {
123+ const nrScans = item .node .snapshots .length ;
124+ if (nrScans === 0 ) {
125+ item .node .fullnameWithSnapshots = ` ${ item .node .fullname } ` ;
126+ } else {
127+ item .node .fullnameWithSnapshots = ` ${ item .node .fullname } •` ;
128+ }
129+ });
130+ }, 500 )
118131 },
119132
120133 computed: {
@@ -128,16 +141,7 @@ export default {
128141
129142 watch: {
130143 async search (val ) {
131- const result = await this .queryMunicipalities (val);
132- this .municipalities = result .data .municipalities .edges ;
133- this .municipalities .forEach ((item ) => {
134- const nrScans = item .node .snapshots .length ;
135- if (nrScans === 0 ) {
136- item .node .fullnameWithSnapshots = ` ${ item .node .fullname } ` ;
137- } else {
138- item .node .fullnameWithSnapshots = ` ${ item .node .fullname } •` ;
139- }
140- });
144+ this .debouncedQuery (val, this );
141145 }
142146 }
143147};
You can’t perform that action at this time.
0 commit comments