File tree Expand file tree Collapse file tree 5 files changed +49
-7
lines changed Expand file tree Collapse file tree 5 files changed +49
-7
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,15 @@ module.exports = {
9
9
}
10
10
} ,
11
11
props : {
12
+ /**
13
+ * Decide whether to filter the results based on search query.
14
+ * Useful for async filtering, where we search through more complex data.
15
+ * @type {Boolean }
16
+ */
17
+ localSearch : {
18
+ type : Boolean ,
19
+ default : true
20
+ } ,
12
21
/**
13
22
* Array of available options: Objects, Strings or Integers.
14
23
* If array of objects, visible label will default to option.label.
@@ -176,9 +185,11 @@ module.exports = {
176
185
let options = this . hideSelected
177
186
? this . options . filter ( this . isNotSelected )
178
187
: this . options
179
- options = this . label
180
- ? options . filter ( ( option ) => option [ this . label ] . includes ( this . search ) )
181
- : options . filter ( ( option ) => option . includes ( this . search ) )
188
+ if ( this . localSearch ) {
189
+ options = this . label
190
+ ? options . filter ( ( option ) => option [ this . label ] . includes ( this . search ) )
191
+ : options . filter ( ( option ) => option . includes ( this . search ) )
192
+ }
182
193
if ( this . taggable && search . length && ! this . isExistingOption ( search ) ) {
183
194
options . unshift ( { isTag : true , label : search } )
184
195
}
Original file line number Diff line number Diff line change 84
84
"nightwatch" : " ^0.8.18" ,
85
85
"node-sass" : " ^3.4.2" ,
86
86
"ora" : " ^0.2.0" ,
87
+ "phantomjs-polyfill-includes" : " 0.0.1" ,
87
88
"phantomjs-prebuilt" : " ^2.1.3" ,
88
89
"sass-loader" : " ^3.2.0" ,
89
90
"selenium-server" : " ^2.53.0" ,
Original file line number Diff line number Diff line change @@ -9,6 +9,15 @@ module.exports = {
9
9
}
10
10
} ,
11
11
props : {
12
+ /**
13
+ * Decide whether to filter the results based on search query.
14
+ * Useful for async filtering, where we search through more complex data.
15
+ * @type {Boolean }
16
+ */
17
+ localSearch : {
18
+ type : Boolean ,
19
+ default : true
20
+ } ,
12
21
/**
13
22
* Array of available options: Objects, Strings or Integers.
14
23
* If array of objects, visible label will default to option.label.
@@ -176,9 +185,11 @@ module.exports = {
176
185
let options = this . hideSelected
177
186
? this . options . filter ( this . isNotSelected )
178
187
: this . options
179
- options = this . label
180
- ? options . filter ( ( option ) => option [ this . label ] . includes ( this . search ) )
181
- : options . filter ( ( option ) => option . includes ( this . search ) )
188
+ if ( this . localSearch ) {
189
+ options = this . label
190
+ ? options . filter ( ( option ) => option [ this . label ] . includes ( this . search ) )
191
+ : options . filter ( ( option ) => option . includes ( this . search ) )
192
+ }
182
193
if ( this . taggable && search . length && ! this . isExistingOption ( search ) ) {
183
194
options . unshift ( { isTag : true , label : search } )
184
195
}
Original file line number Diff line number Diff line change @@ -51,7 +51,10 @@ module.exports = function (config) {
51
51
browsers : [ 'PhantomJS' ] ,
52
52
frameworks : [ 'mocha' , 'sinon-chai' ] ,
53
53
reporters : [ 'spec' , 'coverage' ] ,
54
- files : [ './index.js' ] ,
54
+ files : [
55
+ '../../node_modules/phantomjs-polyfill-includes/includes-polyfill.js' ,
56
+ './index.js'
57
+ ] ,
55
58
preprocessors : {
56
59
'./index.js' : [ 'webpack' , 'sourcemap' ]
57
60
} ,
Original file line number Diff line number Diff line change @@ -1903,6 +1903,22 @@ describe('Multiselect.vue', () => {
1903
1903
expect ( vm . $children [ 0 ] . filteredOptions ) . to . deep . equal ( [ { isTag : true , label : '1' } , 10 ] )
1904
1904
expect ( vm . $children [ 0 ] . filteredOptions . length ) . to . equal ( 2 )
1905
1905
} )
1906
+
1907
+ it ( 'should not alter the available options when :local-search is FALSE' , ( ) => {
1908
+ const vm = new Vue ( {
1909
+ template : '<multiselect :selected="value" :options="source" :multiple="true" :local-search="false"></multiselect>' ,
1910
+ components : { Multiselect } ,
1911
+ data : {
1912
+ value : [ ] ,
1913
+ source : [ 10 , 20 , 30 ]
1914
+ }
1915
+ } ) . $mount ( )
1916
+ expect ( vm . $children [ 0 ] . filteredOptions ) . to . deep . equal ( [ 10 , 20 , 30 ] )
1917
+ expect ( vm . $children [ 0 ] . filteredOptions . length ) . to . equal ( 3 )
1918
+ vm . $children [ 0 ] . search = 'test'
1919
+ expect ( vm . $children [ 0 ] . filteredOptions ) . to . deep . equal ( [ 10 , 20 , 30 ] )
1920
+ expect ( vm . $children [ 0 ] . filteredOptions . length ) . to . equal ( 3 )
1921
+ } )
1906
1922
} )
1907
1923
1908
1924
describe ( '#onTag' , ( ) => {
You can’t perform that action at this time.
0 commit comments