|
59 | 59 | type: Boolean,
|
60 | 60 | default: false
|
61 | 61 | },
|
| 62 | + cleanSearch:{ |
| 63 | + type: Boolean, |
| 64 | + default: true |
| 65 | + }, |
62 | 66 | placeholder: {
|
63 | 67 | type: String,
|
64 | 68 | default: ''
|
|
114 | 118 | filteredOptions () {
|
115 | 119 | if (this.searchText) {
|
116 | 120 | return this.nonSelectOptions.filter(option => {
|
117 |
| - return option.text.match(new RegExp(this.searchText, 'i')) |
| 121 | + if(this.cleanSearch){ |
| 122 | + var cleanedText = this.accentsTidy(option.text) |
| 123 | + return cleanedText.match(new RegExp(this.searchText, 'i')) |
| 124 | + }else{ |
| 125 | + return option.text.match(new RegExp(this.searchText, 'i')) |
| 126 | + } |
118 | 127 | })
|
119 | 128 | } else {
|
120 | 129 | return this.nonSelectOptions
|
|
138 | 147 | },
|
139 | 148 | prevItem () {
|
140 | 149 | common.prevItem(this)
|
| 150 | + this.closeOptions(); |
| 151 | + this.openOptions(); |
141 | 152 | },
|
142 | 153 | nextItem () {
|
143 | 154 | common.nextItem(this)
|
| 155 | + this.closeOptions(); |
| 156 | + this.openOptions(); |
144 | 157 | },
|
145 | 158 | enterItem () {
|
146 | 159 | common.enterItem(this)
|
|
156 | 169 | },
|
157 | 170 | selectItem (option) {
|
158 | 171 | const selectedOptions = _.unionWith(this.selectedOptions, [option], _.isEqual)
|
159 |
| - this.closeOptions() |
160 |
| - this.$emit('select', selectedOptions, option) |
| 172 | + this.closeOptions(); |
| 173 | + this.openOptions(); |
| 174 | + this.searchText=''; |
| 175 | + this.$emit('select', selectedOptions,option,'insert') |
161 | 176 | },
|
162 | 177 | deleteItem (option) {
|
163 | 178 | const selectedOptions = _.reject(this.selectedOptions, option)
|
164 |
| - this.$emit('select', selectedOptions, option) |
165 |
| - } |
| 179 | + this.$emit('select', selectedOptions,option,'delete') |
| 180 | + }, |
| 181 | + accentsTidy(s){ |
| 182 | + var r=s.toString().toLowerCase(); |
| 183 | + r = r.replace(new RegExp("[àáâãäå]", 'g'),"a"); |
| 184 | + r = r.replace(new RegExp("æ", 'g'),"ae"); |
| 185 | + r = r.replace(new RegExp("ç", 'g'),"c"); |
| 186 | + r = r.replace(new RegExp("[èéêë]", 'g'),"e"); |
| 187 | + r = r.replace(new RegExp("[ìíîï]", 'g'),"i"); |
| 188 | + r = r.replace(new RegExp("ñ", 'g'),"n"); |
| 189 | + r = r.replace(new RegExp("[òóôõö]", 'g'),"o"); |
| 190 | + r = r.replace(new RegExp("œ", 'g'),"oe"); |
| 191 | + r = r.replace(new RegExp("[ùúûü]", 'g'),"u"); |
| 192 | + r = r.replace(new RegExp("[ýÿ]", 'g'),"y"); |
| 193 | + return r; |
| 194 | + } |
166 | 195 | }
|
167 | 196 | }
|
168 | 197 | </script>
|
|
0 commit comments