Skip to content
Snippets Groups Projects
Commit 8a37ac0f authored by R En's avatar R En Committed by Eliot Berriot
Browse files

Resolve "No feedback when search does not raise any result"

parent a020afcb
No related branches found
No related tags found
No related merge requests found
...@@ -49,12 +49,17 @@ export default { ...@@ -49,12 +49,17 @@ export default {
jQuery(this.$el).search({ jQuery(this.$el).search({
type: 'category', type: 'category',
minCharacters: 3, minCharacters: 3,
showNoResults: true,
error: {
noResultsHeader: this.$pgettext('Sidebar/Search/Error', 'No matches found'),
noResults: this.$pgettext('Sidebar/Search/Error.Label', 'Sorry, there are no results for this search')
},
onSelect (result, response) { onSelect (result, response) {
router.push(result.routerUrl) router.push(result.routerUrl)
}, },
onSearchQuery (query) { onSearchQuery (query) {
self.$emit('search') self.$emit('search')
searchQuery = query; searchQuery = query
}, },
apiSettings: { apiSettings: {
beforeXHR: function (xhrObject) { beforeXHR: function (xhrObject) {
...@@ -65,7 +70,8 @@ export default { ...@@ -65,7 +70,8 @@ export default {
return xhrObject return xhrObject
}, },
onResponse: function (initialResponse) { onResponse: function (initialResponse) {
var results = {} let results = {}
let isEmptyResults = true
let categories = [ let categories = [
{ {
code: 'artists', code: 'artists',
...@@ -130,6 +136,7 @@ export default { ...@@ -130,6 +136,7 @@ export default {
results: [] results: []
} }
initialResponse[category.code].forEach(result => { initialResponse[category.code].forEach(result => {
isEmptyResults = false
let id = category.getId(result) let id = category.getId(result)
results[category.code].results.push({ results[category.code].results.push({
title: category.getTitle(result), title: category.getTitle(result),
...@@ -144,7 +151,9 @@ export default { ...@@ -144,7 +151,9 @@ export default {
}) })
}) })
}) })
return {results: results} return {
results: isEmptyResults ? {} : results
}
}, },
url: this.$store.getters['instance/absoluteUrl']('api/v1/search?query={query}') url: this.$store.getters['instance/absoluteUrl']('api/v1/search?query={query}')
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment