Problem: impossible to use global search after selecting channel
Solution: make global search a specific option in searchpopup
This commit is contained in:
parent
f559c237ca
commit
79b88d7a59
|
@ -17,6 +17,13 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<label for="global" class="radio"><input type="radio" name="channel" id="global" value="global" v-model="searchChannel"> Global</label>
|
||||
<label for="channel" class="radio"><input type="radio" name="channel" id="channel" value="channel" v-model="searchChannel"> Channel</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="timeline--item" v-for="item in searchItems" :key="item.id">
|
||||
<TimelineEntry :item="item" :is-main-entry="true" @debug="debug" />
|
||||
</div>
|
||||
|
@ -38,7 +45,8 @@ export default {
|
|||
return {
|
||||
query: '',
|
||||
loading: false,
|
||||
error: ''
|
||||
error: '',
|
||||
searchChannel: 'global'
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
|
@ -65,7 +73,7 @@ export default {
|
|||
search () {
|
||||
this.loading = true
|
||||
this.error = ''
|
||||
this.$store.dispatch('startQuery', this.query)
|
||||
this.$store.dispatch('startQuery', {query: this.query, channel: this.searchChannel})
|
||||
.then(result => {
|
||||
this.loading = false
|
||||
if (result.error) {
|
||||
|
|
14
src/store.js
14
src/store.js
|
@ -268,14 +268,22 @@ export default new Vuex.Store({
|
|||
commit('setSearchPopupState', false)
|
||||
},
|
||||
startQuery({state, commit}, query) {
|
||||
let channel = 'global'
|
||||
if (state.channel !== null && state.channel.uid !== null && state.channel.uid !== 'home') {
|
||||
let channel
|
||||
if (query.channel) {
|
||||
if (query.channel === 'global') {
|
||||
channel = 'global'
|
||||
} else if (query.channel === 'channel') {
|
||||
if (state.channel !== null && state.channel.uid !== null) {
|
||||
channel = state.channel.uid
|
||||
}
|
||||
} else {
|
||||
channel = 'global'
|
||||
}
|
||||
}
|
||||
const url = new URL(this.state.microsubEndpoint)
|
||||
url.searchParams.set('action', 'search')
|
||||
url.searchParams.set('channel', channel)
|
||||
url.searchParams.set('query', query)
|
||||
url.searchParams.set('query', query.query)
|
||||
return fetch(url.toString(), {
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + this.state.access_token
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<div class="column" style="padding-top: 20px">
|
||||
<button class="channels-toggle button" type="button" @click="showChannels">Channels</button>
|
||||
|
||||
<Channels :class="channelsClass" :channels="this.$store.state.channels">
|
||||
<Channels :class="channelsClass" :channels="this.channels">
|
||||
<div slot-scope="{ channel }">
|
||||
<Channel :channel="channel" @channel-selected="selectChannel"></Channel>
|
||||
</div>
|
||||
|
@ -80,6 +80,9 @@
|
|||
channel() {
|
||||
return this.$store.state.channel
|
||||
},
|
||||
channels() {
|
||||
return this.$store.state.channels
|
||||
},
|
||||
channelsClass () {
|
||||
return {
|
||||
'channels-open': this.channelsVisible,
|
||||
|
|
Loading…
Reference in New Issue
Block a user