1
1
<template >
2
2
<b-field label-position =" on-border" expanded >
3
3
<b-autocomplete
4
- v-model =" query"
5
4
:data =" data"
6
5
:placeholder =" $t('common.field.searchPlaceholder')"
7
6
field =" title"
29
28
</div >
30
29
</template >
31
30
32
- <!-- <template slot="empty">-->
33
- <!-- <span v-show="data.length === 0"-->
34
- <!-- class="has-text-grey has-text-centered"> {{$t('topNavbar.search.footer')}} </span>-->
35
- <!-- </template>-->
36
-
37
31
<template slot="header">
38
32
<div >
39
33
<b-button type =" is-text" icon-left =" toy-brick-search-outline" @click =" gotoSearchPage" >
@@ -88,28 +82,34 @@ export default class SearchBar extends Vue {
88
82
})
89
83
}
90
84
85
+ clearOldSearchData () {
86
+ this .data = []
87
+ this .page = 1
88
+ this .totalPages = 1
89
+ }
90
+
91
91
searchByName (newQuery : string ) {
92
92
if (! this .authUser ) {
93
93
return showWarningToaster (this .$t (' notification.search.notAllowedToSearch' ))
94
94
}
95
- // String update
96
- if (this .query !== newQuery ) {
97
- this .query = newQuery
98
- this .data = []
99
- this .page = 1
100
- this .totalPages = 1
101
- }
102
- // String cleared
95
+
96
+ // String cleared, don't search
103
97
if (! newQuery .length ) {
104
- this .data = []
105
- this .page = 1
106
- this .totalPages = 1
98
+ this .clearOldSearchData ()
107
99
return
108
100
}
101
+
102
+ // String update, refresh search
103
+ if (this .query !== newQuery ) {
104
+ this .query = newQuery
105
+ this .clearOldSearchData ()
106
+ }
107
+
109
108
// Reached last page
110
109
if (this .page > this .totalPages ) {
111
110
return
112
111
}
112
+
113
113
this .isFetching = true
114
114
searchUsers (newQuery , this .page , 5 )
115
115
.then ((pagingResponse ) => {
@@ -132,7 +132,6 @@ export default class SearchBar extends Vue {
132
132
query
133
133
? await this .$router .push (getPageRouteWithQuery (Routes .SEARCH , query ))
134
134
: await this .$router .push (Routes .SEARCH )
135
- console .log (' gotoSearchPage' , this .query )
136
135
}
137
136
138
137
async gotoProfile (username : string ) {
0 commit comments