File tree Expand file tree Collapse file tree 5 files changed +61
-19
lines changed
Expand file tree Collapse file tree 5 files changed +61
-19
lines changed Original file line number Diff line number Diff line change 1818 <div class =" header-wrapper" >
1919 <div class =" input-wrapper--with-icon" >
2020 <Icon type =" search" />
21- <input ref =" inputText" class =" input--primary-color" type =" text" v-model = " searchModel "
21+ <input ref =" inputText" class =" input--primary-color" type =" text" @input = " resetIfEmpty " @keypress.enter = " debounceInput "
2222 placeholder =" Rechercher" >
2323 </div >
2424
165165 })
166166 }
167167
168+ /**
169+ * Event for the input html element
170+ * Search with the title entered and update the store
171+ */
172+ debounceInput(e : any ) {
173+ this .searchModel = e .target .value ;
174+ }
175+
176+ resetIfEmpty(e : any ) {
177+ const value: string = e .target .value ;
178+
179+ if (value === ' ' ) {
180+ this .searchModel = " " ;
181+ }
182+ }
183+
168184 /**
169185 * Add or remove an id from the selected tags array
170186 * Add if state of the checkbox is true and the item is not in the array
Original file line number Diff line number Diff line change 1515 <PanelItem >
1616 <FilterPanel strategy =" admin" :radio-button-rating =" true"
1717 :radio-button-state =" true"
18- :reset-button =" true"
1918 :favorite =" true"
2019 :search-mode =" true"
2120 :historical-mode =" true"
4241 <div class =" header-wrapper" >
4342 <div class =" input-wrapper--with-icon" >
4443 <Icon type =" search" />
45- <input ref =" inputText" class =" input--primary-color" type =" text" v-on: input =" debounceInput"
44+ <input ref =" inputText" class =" input--primary-color" type =" text" @ input= " resetIfEmpty " @keypress.enter =" debounceInput"
4645 placeholder =" Rechercher" >
4746 </div >
4847
165164 import {User } from " ~/assets/js/api/user" ;
166165 import {AxiosError } from " axios" ;
167166
168- const debounce = require (' lodash.debounce' );
169-
170167 const ratio = .2 ;
171168
172169 const download = require (' downloadjs' );
359356 * Event for the input html element
360357 * Search with the title entered and update the store
361358 */
362- debounceInput = debounce (( e : any ) => {
359+ debounceInput( e : any ) {
363360 const value = e .target .value ;
364361 this .$accessor .exercises .fetch ({data: {title: value }});
365362 this .$accessor .historical .addHistorical ({tags: this .$accessor .tags .selectedTags , title: value })
366- }, 300 );
363+ }
364+
365+ resetIfEmpty(e : any ) {
366+ const value: string = e .target .value ;
367+
368+ if (value === ' ' ) {
369+ this .$accessor .exercises .fetch ({data: {title: ' ' }});
370+ }
371+ }
367372
368373 /**
369374 * Reset the input value
Original file line number Diff line number Diff line change 1414 <Panel >
1515 <PanelItem >
1616 <TagFilterPanel
17- :reset-button =" true"
1817 :search-mode =" true"
1918 @reset =" resetInput" />
2019 </PanelItem >
2726 <div class =" header-wrapper" >
2827 <div class =" input-wrapper--with-icon" >
2928 <Icon type =" search" />
30- <input ref =" inputText" class =" input--primary-color" type =" text" v-model = " searchModel "
29+ <input ref =" inputText" class =" input--primary-color" type =" text" @input = " resetIfEmpty " @keypress.enter = " debounceInput "
3130 placeholder =" Rechercher" >
3231 </div >
3332
219218 this .$accessor .tags .addOrRemoveTag ({... tag , isSelected: state })
220219 }
221220
221+
222+ /**
223+ * Event for the input html element
224+ * Search with the title entered and update the store
225+ */
226+ debounceInput(e : any ) {
227+ this .searchModel = e .target .value ;
228+ }
229+
230+ resetIfEmpty(e : any ) {
231+ const value: string = e .target .value ;
232+
233+ if (value === ' ' ) {
234+ this .searchModel = " " ;
235+ }
236+ }
237+
222238 /**
223239 * Remove from the databases the tags and update the tag store
224240 */
Original file line number Diff line number Diff line change 33 <div class =" banner search-banner" >
44 <div class =" input-wrapper--with-icon" >
55 <Icon type =" search" />
6- <input ref =" inputText" class =" input--primary-color" type =" text" v-on:input =" debounceInput"
6+ <input ref =" inputText" class =" input--primary-color" type =" text" @keypress.enter =" debounceInput"
77 placeholder =" Rechercher" >
88 </div >
99 </div >
1010
1111 <div class =" wrapper wrapper--with-panel" >
1212 <Panel >
1313 <PanelItem >
14- <FilterPanel :reset-button = " true " : radio-button-rating =" true" :favorite =" true" :search-mode =" true"
14+ <FilterPanel :radio-button-rating =" true" :favorite =" true" :search-mode =" true"
1515 :historical-mode =" true"
1616 @reset =" resetInput" />
1717 </PanelItem >
4141 import RadioButtonSelecter from " ~/components/Search/RadioButtonSelecter.vue" ;
4242 import {AxiosError } from " axios" ;
4343
44- const debounce = require (' lodash.debounce' );
45-
4644 @Component ({
4745 components: {
4846 RadioButtonSelecter ,
7876 export default class extends Vue {
7977 @Ref () inputText! : HTMLInputElement ;
8078
81- debounceInput = debounce (( e : any ) => {
79+ debounceInput( e : any ) {
8280 const value = e .target .value ;
8381 this .$accessor .exercises .fetch ({data: {title: value }});
8482 this .$accessor .historical .addHistorical ({
8583 tags: this .$accessor .tags .selectedTags ,
8684 title: value ,
8785 vote: this .$accessor .exercises .search_criterion .vote
8886 })
89- }, 300 );
87+ }
9088
9189 resetInput() {
9290 this .inputText .value = " "
Original file line number Diff line number Diff line change 1515 <PanelItem >
1616 <FilterPanel strategy =" user" :radio-button-rating =" true"
1717 :radio-button-state =" true"
18- :reset-button =" true"
1918 :favorite =" true"
2019 :search-mode =" true"
2120 :historical-mode =" true"
4039 <div class =" header-wrapper" >
4140 <div class =" input-wrapper--with-icon" >
4241 <Icon type =" search" />
43- <input ref =" inputText" class =" input--primary-color" type =" text" v-on: input =" debounceInput"
42+ <input ref =" inputText" class =" input--primary-color" type =" text" @ input= " resetIfEmpty " @keypress.enter =" debounceInput"
4443 placeholder =" Rechercher" >
4544 </div >
4645
312311 * Event for the input html element
313312 * Search with the title entered and update the store
314313 */
315- debounceInput = debounce (( e : any ) => {
314+ debounceInput( e : any ) {
316315 const value = e .target .value ;
317316 this .$accessor .exercises .fetch ({data: {title: value }});
318317 this .$accessor .historical .addHistorical ({tags: this .$accessor .tags .selectedTags , title: value })
319- }, 300 );
318+ }
319+
320+ resetIfEmpty(e : any ) {
321+ const value: string = e .target .value ;
322+
323+ if (value === ' ' ) {
324+ this .$accessor .exercises .fetch ({data: {title: " " }});
325+ }
326+ }
320327
321328 /**
322329 * Reset the input value
You can’t perform that action at this time.
0 commit comments