Skip to content

Commit 1c63316

Browse files
committed
feat(InputText): add keypress enter event
1 parent 59c820b commit 1c63316

File tree

5 files changed

+61
-19
lines changed

5 files changed

+61
-19
lines changed

pages/administration/categories/index.vue

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
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

@@ -165,6 +165,22 @@
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

pages/administration/exercices/index.vue

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
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"
@@ -42,7 +41,7 @@
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

@@ -165,8 +164,6 @@
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');
@@ -359,11 +356,19 @@
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

pages/administration/tags/index.vue

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
<Panel>
1515
<PanelItem>
1616
<TagFilterPanel
17-
:reset-button="true"
1817
:search-mode="true"
1918
@reset="resetInput"/>
2019
</PanelItem>
@@ -27,7 +26,7 @@
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

@@ -219,6 +218,23 @@
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
*/

pages/exercices/index.vue

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
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>
@@ -41,8 +41,6 @@
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,
@@ -78,15 +76,15 @@
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 = ""

pages/gestion/mes-exercices/index.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
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"
@@ -40,7 +39,7 @@
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

@@ -312,11 +311,19 @@
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

0 commit comments

Comments
 (0)