navigation: show search results length badge

This commit is contained in:
Jonas Heinrich 2020-11-11 10:51:20 +01:00
parent 1cf223395a
commit f421548979
6 changed files with 24 additions and 15 deletions

View File

@ -68,10 +68,9 @@ return [
], ],
[ [
'name' => 'page#index', 'name' => 'page#index',
'url' => '/search/{query}', 'url' => '/search',
'verb' => 'GET', 'verb' => 'GET',
'postfix' => 'search', 'postfix' => 'search',
'requirements' => ['query' => '.+'],
], ],
// Settings // Settings

View File

@ -23,3 +23,4 @@
@include icon-black-white('recent', 'radio', 1); @include icon-black-white('recent', 'radio', 1);
@include icon-black-white('radio', 'radio', 1); @include icon-black-white('radio', 'radio', 1);
@include icon-black-white('radio-trans', 'radio', 1);

View File

@ -69,8 +69,8 @@ class SearchProvider implements IProvider {
$result['favicon'], $result['favicon'],
$result['name'], $result['name'],
str_replace(",",", ",$result['tags']), str_replace(",",", ",$result['tags']),
$this->url->linkToRouteAbsolute('radio.page.index') . 'search/'.$term.'#/search/'.$term, $this->url->linkToRouteAbsolute('radio.page.index') . 'search#'.$term,
'icon-radio' 'icon-radio-trans'
); );
}, $parsed); }, $parsed);

View File

@ -1,6 +1,7 @@
<template> <template>
<Content app-name="radio"> <Content app-name="radio">
<Navigation /> <Navigation
:station-data="tableData" />
<AppContent> <AppContent>
<Breadcrumbs class="breadcrumbs"> <Breadcrumbs class="breadcrumbs">
<Breadcrumb title="Home" href="/" /> <Breadcrumb title="Home" href="/" />
@ -192,7 +193,7 @@ export default {
let queryURI = queryBase let queryURI = queryBase
if (menuState === 'SEARCH') { if (menuState === 'SEARCH') {
const searchQuery = vm.$route.params.query const searchQuery = vm.$route.hash.substr(1)
queryURI = queryBase + '/byname/' + searchQuery queryURI = queryBase + '/byname/' + searchQuery
} else if (menuState === 'FAVORITES') { } else if (menuState === 'FAVORITES') {
queryURI = generateUrl('/apps/radio/api/favorites') queryURI = generateUrl('/apps/radio/api/favorites')

View File

@ -26,8 +26,10 @@
:to="{ name: 'SEARCH' }" :to="{ name: 'SEARCH' }"
icon="icon-search" icon="icon-search"
:title="t('radio', 'Search')"> :title="t('radio', 'Search')">
<AppNavigationCounter slot="counter" :highlighted="true"> <AppNavigationCounter
99+ slot="counter"
:highlighted="true">
{{ stationData.length }}
</AppNavigationCounter> </AppNavigationCounter>
</AppNavigationItem> </AppNavigationItem>
</template> </template>
@ -52,6 +54,12 @@ export default {
AppNavigationCounter, AppNavigationCounter,
Player, Player,
}, },
props: {
stationData: {
type: Array,
default() { return [] },
},
},
computed: { computed: {
isSearch() { isSearch() {
return this.$route.name === 'SEARCH' return this.$route.name === 'SEARCH'
@ -59,3 +67,9 @@ export default {
}, },
} }
</script> </script>
<style>
.app-navigation-entry__utils {
margin-right: 10px;
}
</style>

View File

@ -39,7 +39,7 @@ const router = new Router({
name: 'CATEGORIES', name: 'CATEGORIES',
}, },
{ {
path: '/search/:query', path: '/search',
component: Main, component: Main,
name: 'SEARCH', name: 'SEARCH',
}, },
@ -48,12 +48,6 @@ const router = new Router({
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
if (to.hash) {
const hashPath = to.hash.substr(1)
next(hashPath)
return
}
if (to.name) { if (to.name) {
store.dispatch('setMenuState', to.name) store.dispatch('setMenuState', to.name)
next() next()