2022-11-24 01:00:30 +01:00
< template lang = "pug" >
2022-11-25 09:21:22 +01:00
# navsearch . mt - 2. mt - sm - 4 ( v - if = 'showCollectionsBar || showSearchBar' )
v - text - field . mx - 2 ( v - if = 'showSearchBar' outlined dense hide - details : placeholder = '$t("common.search")' : append - icon = 'mdiMagnify' @ input = 'search' clearable : clear - icon = 'mdiClose' )
2022-11-24 01:00:30 +01:00
template ( v - slot : prepend - inner )
Calendar ( v - if = '!settings.hide_calendar' )
2022-11-25 09:21:22 +01:00
v - btn . ml - 2. mt - 2. gap - 2 ( v - if = 'showCollectionsBar' small outlined v - for = 'collection in collections' color = 'primary' : key = 'collection.id' : to = '`/collection/${encodeURIComponent(collection.name)}`' ) { { collection . name } }
2022-11-24 01:00:30 +01:00
< / template >
< script >
import { mapState } from 'vuex'
import Calendar from '@/components/Calendar'
2022-11-24 17:28:00 +01:00
import { mdiMagnify , mdiClose } from '@mdi/js'
2022-11-24 01:00:30 +01:00
export default {
data : ( ) => ( {
2022-11-24 17:28:00 +01:00
mdiMagnify , mdiClose ,
2022-11-24 01:00:30 +01:00
collections : [ ]
} ) ,
async fetch ( ) {
this . collections = await this . $axios . $get ( 'collections' ) . catch ( _e => [ ] )
} ,
components : { Calendar } ,
2022-11-25 09:21:22 +01:00
computed : {
showSearchBar ( ) {
return this . $route . name === 'index'
} ,
showCollectionsBar ( ) {
return [ 'index' , 'collection-collection' ] . includes ( this . $route . name )
} ,
... mapState ( [ 'settings' ] )
} ,
2022-11-24 17:28:00 +01:00
methods : {
search ( ev ) {
this . $root . $emit ( 'search' , ev )
}
}
2022-11-24 01:00:30 +01:00
}
< / script >
< style >
# navsearch {
margin : 0 auto ;
max - width : 800 px ;
}
< / style >